I have a project which uses two nRF24 for one-way communication. Currently it uses a PIC on each end to send/receive the data. Which works perfectly. However, I would like to swap out the Receiver PIC and swap in an ESP32 connected to a nRF24 and use the Arduino IDE.
I used the Arduino nRF24 "Getting Started" example with two ESP32's connected to a nRF24 each and got that working (so the hardware is confirmed), I modified the example program settings to match the existing PIC's nRF24 register setup code.
I have a B/B+ understanding of how to set up the nRF24. I know the transmitter works, but I can't seem to get a response from the nRF24 receiver. I expect it's something I don't understand regarding addressing, pipes, payload size, or...?
Here are (what I think are) the relevant info on the PIC's set registers code (I attached the full .c and .h, zip file):
uint8_t RXTX_ADDR[3] = { 0xB5, 0x23, 0xA5 }; //Randomly chosen address
WriteRegister(NRF_CONFIG, 0x0B); //1 uint8_t CRC, POWER UP, PRX
WriteRegister(EN_AA, 0x00); //Disable auto ack
WriteRegister(EN_RXADDR, 0x01); //Enable data pipe 0
WriteRegister(SETUP_AW, 0x01); //3 uint8_t address
WriteRegister(SETUP_RETR, 0x00); //Retransmit disabled
WriteRegister(RF_CH, 0x01); //Randomly chosen RF channel
WriteRegister(RF_SETUP, 0x26); //250kbps, 0dBm
WriteRegister(RX_PW_P0, 0x01); //RX payload = 1 uint8_t
WriteAddress(RX_ADDR_P0, 3, RXTX_ADDR);
WriteAddress(TX_ADDR, 3, RXTX_ADDR);
//--------------------
Arudio Code Example Changes - (I attached the full program, zip file)
//--------------------
#define ce 4 //for ESP32
#define csn 5 //for ESP32
// instantiate an object for the nRF24L01 transceiver
RF24 radio(ce, csn); // using pin 7 for the CE pin, and pin 8 for the CSN pin
// Let these addresses be used for the pair
//uint8_t address[][6] = {"1Node", "2Node"};
uint8_t address[][6] = { 0xB5, 0x23, 0xA5, 0xB5, 0x23, 0xA5 }; //match PIC
void customSetup(){
radio.setAddressWidth( 3 ); //Match PIC
radio.setPayloadSize(1); //Match PIC
radio.setDataRate( RF24_250KBPS ); //Match PIC
radio.setChannel( 0x01 ); //Match PIC
radio.setAutoAck( false ); //Match PIC
}
Setup changes:
customSetup();
// save on transmission time by setting the radio to only transmit the
// number of bytes we need to transmit a float
// radio.setPayloadSize(sizeof(payload)); // float datatype occupies 4 bytes
radio.setPayloadSize( 1 ); //Match PIC
Loop changes:
// set the RX address of the TX node into a RX pipe
// radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
//*************************************************************
radio.openReadingPipe(1, address[radioNumber]); // using pipe 1 - not sure about pipes, etc... tried to match PIC
//**************************************************************
If anyone is willing to take a look at my code. It would be greatly appreciated! Thanks in advance...PIC-ESP32-Aduino files.zip (7.4 KB)