No ACK received with atmega328p

Started by bitswap, April 07, 2025, 11:53:21 AM

bitswap

I have the RFM69 units hooked on an atmega328p. All works well except for the ACK reply.

Using the radio.send command I do get both units to communicate both ways but I soon as I request a ACK things go wrong.

Here my minimal code for the sender:


#include <RFM69.h>
#define MYNODE 1
#define EXNODE 2
RFM69 radio;

void setup() {
  Serial.begin(115200);
  radio.setCS(10);
  radio.initialize(RF69_433MHZ, MYNODE, 0);
  radio.setHighPower();
}

void loop() {
  delay(2500);

  if (radio.sendWithRetry(EXNODE, "ok", 2, 1, 100)) {
    Serial.println("ACK received!");
  }
  else {
    Serial.println("no ACK received");
  }
}



Here is my minimal code for the receiver

#include <RFM69.h>
#define MYNODE 2
#define EXNODE 1
RFM69 radio;

void setup() {
  Serial.begin(115200);
  radio.setCS(10);
  radio.initialize(RF69_433MHZ, MYNODE, 0);
  radio.setHighPower();
}

void loop() {
  if (radio.receiveDone()) {
    if (radio.ACKRequested()) {
      radio.sendACK();
      Serial.println("ACK sent");
    }
    Serial.print("received from node ");
    Serial.print(radio.SENDERID, DEC);
    Serial.print(", message [");
    for (byte i = 0; i < radio.DATALEN; i++) {
      Serial.print((char)radio.DATA[i]);
    }
    Serial.print("], RSSI ");
    Serial.println(radio.RSSI);
  }
}



The replay I get from the sender is
no ACK received


The reply I get from the receiver is
ACK sent
received from node 1, message [], RSSI -52


Strangely the message is empty when this is not the case when sending with radio.send().


Would you be able to help and point me in the right direction to diagnose this?

I had a look at the examples which basically do the same as I am doing here. Nothing obvious to find there hence. Strange how both units do communicate well but the ACK fails.

Felix

To eliminate the hardware as a suspect, can you please try the Node and Gateway examples (with the appropriate adjustments for frequency, leave everything untouched).

bitswap

#2
Thank you for the guidance.

Interestingly one units gets the ACK whereas the other one is intermittent.

Sending[1]: 1 ok!
Sending[2]: 12 ok!
Sending[3]: 123 ok!
Sending[4]: 123  ok!
Sending[5]: 123 A ok!
Sending[6]: 123 AB ok!
[1] ACK TEST   [RX_RSSI:-50] - ACK sent
Sending[7]: 123 ABC ok!
Sending[8]: 123 ABCD ok!
Sending[9]: 123 ABCDE ok!
Sending[10]: 123 ABCDEF ok!
Sending[11]: 123 ABCDEFG ok!
Sending[12]: 123 ABCDEFGH ok!
Sending[13]: 123 ABCDEFGHI ok!
Sending[14]: 123 ABCDEFGHIJ ok!
Sending[15]: 123 ABCDEFGHIJK ok!
Sending[16]: 123 ABCDEFGHIJKL ok!
Sending[17]: 123 ABCDEFGHIJKLM ok!
Sending[18]: 123 ABCDEFGHIJKLMN ok!
[1] ACK TEST   [RX_RSSI:-37] - ACK sent
Sending[19]: 123 ABCDEFGHIJKLMNO ok!
Sending[20]: 123 ABCDEFGHIJKLMNOP ok!
Sending[21]: 123 ABCDEFGHIJKLMNOPQ ok!
Sending[22]: 123 ABCDEFGHIJKLMNOPQR ok!
Sending[23]: 123 ABCDEFGHIJKLMNOPQRS ok!
Sending[24]: 123 ABCDEFGHIJKLMNOPQRST ok!


#[136][2] 1] 1   [RX_RSSI:-28] - ACK sent.
#[137][2] 1] 12   [RX_RSSI:-28] - ACK sent. Pinging node 2 - ACK...nothing
#[138][2] 1] 123   [RX_RSSI:-28] - ACK sent.
#[139][2] 1] 123    [RX_RSSI:-28] - ACK sent.
#[140][2] 1] 123 A   [RX_RSSI:-28] - ACK sent. Pinging node 2 - ACK...nothing
#[141][2] 1]    [RX_RSSI:-28]
#[142][2] 1] 123 AB   [RX_RSSI:-21] - ACK sent.
#[143][2] 1] 123 ABC   [RX_RSSI:-28] - ACK sent.
#[144][2] 1] 123 ABCD   [RX_RSSI:-28] - ACK sent. Pinging node 2 - ACK...nothing
#[145][2] 1] 123 ABCDE   [RX_RSSI:-28] - ACK sent.
#[146][2] 1] 123 ABCDEF   [RX_RSSI:-28] - ACK sent.
#[147][2] 1] 123 ABCDEFG   [RX_RSSI:-28] - ACK sent. Pinging node 2 - ACK...nothing
#[148][2] 1] 123 ABCDEFGH   [RX_RSSI:-28] - ACK sent.
#[149][2] 1] 123 ABCDEFGHI   [RX_RSSI:-28] - ACK sent.
#[150][2] 1] 123 ABCDEFGHIJ   [RX_RSSI:-28] - ACK sent. Pinging node 2 - ACK...nothing
#[151][2] 1] 123 ABCDEFGHIJK   [RX_RSSI:-28] - ACK sent.
#[152][2] 1] 123 ABCDEFGHIJKL   [RX_RSSI:-28] - ACK sent.
#[153][2] 1] 123 ABCDEFGHIJKLM   [RX_RSSI:-28] - ACK sent. Pinging node 2 - ACK...ok!
#[154][2] 1] 123 ABCDEFGHIJKLMN   [RX_RSSI:-28] - ACK sent.
#[155][2] 1] 123 ABCDEFGHIJKLMNO   [RX_RSSI:-28] - ACK sent.
#[156][2] 1] 123 ABCDEFGHIJKLMNOP   [RX_RSSI:-28] - ACK sent. Pinging node 2 - ACK...nothing
#[157][2] 1]    [RX_RSSI:-28]
#[158][2] 1] 123 ABCDEFGHIJKLMNOPQ   [RX_RSSI:-28] - ACK sent.
#[159][2] 1] 123 ABCDEFGHIJKLMNOPQR   [RX_RSSI:-27] - ACK sent.
#[160][2] 1] 123 ABCDEFGHIJKLMNOPQRS   [RX_RSSI:-28] - ACK sent. Pinging node 2 - ACK...nothing
#[161][2] 1] 123 ABCDEFGHIJKLMNOPQRST   [RX_RSSI:-28] - ACK sent.
#[162][2] 1] 123 ABCDEFGHIJKLMNOPQRSTU   [RX_RSSI:-28] - ACK sent.
#[163][2] 1] 123 ABCDEFGHIJKLMNOPQRSTUV   [RX_RSSI:-27] - ACK sent. Pinging node 2 - ACK...nothing


I then swapped the 2 roles and the node this time got many "nothing" instead of "ok!". So one of the two units has a hardware issue. I suspect I must have fried one of them. I'll replace the rfm69 and see.

Also the unit having ACK problems has an i2c oled connected. Not sure if this would have an impact.

I was assuming that just sending and receiving ok would validate a good hardware. I am still unsure why a ACK transmission is more hardware sensitive. I'll have to study that.

It is rather late in my part of the world here. I will have a closer look at the hardware tomorrow.


Felix

Rather than guess your way through the hardware, I would recommend using tested (known to work) hardware.
I have have seen many (and this forum is testament to this) who have tried to wire a RFM69 to an Arduino UNO or Arduino Micro and in a lot of cases it just leads to poor signals, intermittent transmissions, ghosts and goblins and endless frustration.

As an example, the Moteino are just one board family that can be configured with your desired radio and guaranteed to work out of box (they are tested with the Node sketches I linked above - against a Gateway Moteino). They are not only designed around the RFM69 radio, but also tuned for ultra low power (when programmed and used correctly) to yield a very long life on small batteries (demonstrated to last many years!). The RFM69 library that you are using has been developed on and for Moteino boards specifically.

bitswap

#4
working solid and strong now. I found a weak soldering somewhere.

My Minimal Reproductible Code above has a design mistake on the receiver end.

sendACK must be issued after printing the message not before. Which explains why I was seeing 0 length messages. sendACK logically writing to the buffer that we want to read.

Felix

Thanks for the follow up, it's good information for others to check when they see failures.