I'm using nRF24L01+PA+LNA to communicate between my Arduino Mega and ESP32. I'm trying to run a basic bidirectional sketch that worked well just a few weeks ago but now, on the Mega side, I see bad data coming back from the ESP32. My bidirectional sketch is to test acknowledgement payloads - the Mega transmits "Hello ESP32" to the ESP32 while the ESP32 returns dummy data after it has received the Mega's message. Now, on the Mega side, all I see coming back is 216 | ovf | ovf | 55512. Attached is my code below.
// Mega Code
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN for Mega
const byte address[6] = "00001";
struct __attribute__((packed)) returnData {
uint8_t gpsStatus;
float lat;
float lon;
uint16_t hdg;
} ackData;
void setup() {
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.enableAckPayload();
}
void loop() {
const char text[] = "Hello ESP32";
radio.write(&text, sizeof(text));
Serial.println();
if (radio.isAckPayloadAvailable()) {
radio.read(&ackData, sizeof(ackData));
Serial.print(ackData.gpsStatus); Serial.print("|");
Serial.print(ackData.lat); Serial.print("|"); Serial.print(ackData.lon);
Serial.print("|"); Serial.print(ackData.hdg);
Serial.println();
}
delay(1000);
}
// ESP32 Code
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(4, 5); // CE, CSN
const byte address[6] = "00001";
struct __attribute__((packed)) returnData {
uint8_t gpsStatus;
float lat;
float lon;
uint16_t hdg;
} ackData;
void setup() {
Serial.begin(115200);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.enableAckPayload();
radio.startListening();
}
void loop() {
if (radio.available()) {
char text[32] = "";
radio.read(&text, sizeof(text));
Serial.println(text);
ackData.gpsStatus = 1;
ackData.lat = 50.8759;
ackData.lon = -110.5749;
ackData.hdg = 200;
radio.writeAckPayload(0, &ackData, sizeof(ackData));
}
}
Any help would be very much appreciated! Thank you!