I have a Mega R3, NRF24L01+, the socket adapter module board for NRF24L01+, Nano ESP32, and an UNO R3.
When transmitting data between the Mega and UNO (UNO as transmitter) everything works perfectly. Data received! When wiring it up the exact same way to use the Nano ESP32 as transmitter, no data is sent. I even tried using a logic converter to bring the Nano's 3.3v up to 5 since the UNO logic pins are 5v. I'm not sure if I'm doing something wrong or if its not meant to work with ESP32 infrastructure.
Transmitter Code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define radioce 7
#define radiocsn 8
RF24 radio(radioce, radiocsn); // CE, CSN
const byte address[6] = "00001";
struct Data_Package_T {
int x = 5;
int y = -5;
};
Data_Package_T datat;
void setup() {
Serial.begin(9600);
while (!Serial);
if (!radio.begin()) {
Serial.println(F("radio hardware is not responding!!"));
while (1) {} // hold in infinite loop
}
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MAX);
radio.stopListening();
Serial.println("Made it through Setup");
}
void loop() {
delay(1000);
radio.write(&datat, sizeof(Data_Package_T));
}
Receiver Code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
struct Data_Package_T {
int x;
int y;
};
Data_Package_T datat;
void setup() {
Serial.begin(9600);
while (!Serial);
if (!radio.begin()) {
Serial.println(F("radio hardware is not responding!!"));
while (1) {} // hold in infinite loop
}
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
Serial.println("Made it through Setup");
}
void loop() {
radio.startListening();
while (!radio.available());
if (radio.available()){
radio.read(&datat, sizeof(Data_Package_T));
}
Serial.print("X RPM: "); Serial.println(datat.x);
Serial.print("Y RPM: "); Serial.println(datat.y);
}