This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Any advice for nRF52832 to nRF24L01+ communication?

Hi, I tried establish a communication between nRF52832 DK(PCA10040) to nRF24L01+ Module with Arduino UNO(via SPI). I used the EnhancedShockburst examples from nRF5 SDK 11.0.0 but couldn't receive any data from nRF52. I use TMRh20's RF24 libraries in Arduino. This is my config:

#include <SPI.h>
#include <RF24.h>
#include "nRF24L01.h"
#include "printf.h"
RF24 radio(7, 8);
#define SERIAL_DEBUG
uint8_t message[1];
const uint64_t pipes[2] = {0xE7E7E7E7E7LL,0xC2C2C2C2C2LL};
void setup()
{
Serial.begin(57600);
printf_begin();
radio.begin();
radio.setRetries(15, 15);
radio.setChannel(2);
radio.setPALevel(RF24_PA_MAX);
radio.setCRCLength(RF24_CRC_8);
radio.setDataRate(RF24_2MBPS);
radio.setPayloadSize(1);
radio.enableAckPayload();
radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(0, pipes[0]); 

radio.startListening();
radio.printDetails();
}

void loop()
{
radio.startListening(); // Start listening for incoming messages

while ( ! radio.available() ) { // Wait for a message
 delayMicroseconds(10);
}

radio.read( &message, 1); // Get the message
Serial.print(" DATA:      ");
Serial.print(message[0]);
Serial.println("  END  ");
}

The nRF52 side, I didn't change anything expect choose legacy config parameters like:

#define NRF_ESB_LEGACY

There is no data received that can I see. Is there any idea about mistakes?

Sincerely,

thanks.

Parents
  • Hi,

    I have found out that when we call radio.read the complete payload list is sent to the Arduino and erased in the nrf24l01 pipe, thus when you call radio.read to store the payload in a single byte (uint8_t incoming_data) the first byte of the payload is stored and the rest is discarded.

    Below is the Arduino code that worked for me thanks to moso(I'm using Arduino mega 2560):

    #include <SPI.h>
    #include <nRF24L01.h>
    #include <RF24.h>
    #include "printf.h"
    
    RF24 radio(7, 8);
    int packetCounter = 0;
    uint8_t incoming_data[8];
    uint8_t message[1];
    
    int64_t pipe_adress[2] = {0xC2C2C2C2C2, 0xE7E7E7E7E7};
    
    void setupRadio()
    {
      radio.begin();
      radio.setRetries(15, 15);
      radio.setChannel(2);
      radio.setDataRate(RF24_2MBPS);
      radio.setPALevel(RF24_PA_MAX);
      radio.enableDynamicPayloads();
      radio.openReadingPipe(0, pipe_adress[1]);
      radio.openReadingPipe(1, pipe_adress[0]);
      radio.startListening();
      radio.printDetails();
    }
    
    void setup() {
      Serial.begin(115200);
      printf_begin();
      
      setupRadio();
    }
    void loop() {
    
      if (radio.available()) {
        radio.read(incoming_data, 8);
    
        Serial.println("DATA:    ");
    
        Serial.println(incoming_data[1], BIN);
        Serial.println(incoming_data[1], OCT);
        Serial.println(incoming_data[1], DEC);
        Serial.println(incoming_data[1], HEX);
        delay(50);
      }
    }

    And here is a sample output:

    DATA:    
    1111101
    175
    125
    7D
    DATA:    
    1111110
    176
    126
    7E
    DATA:    
    1111111
    177
    127
    7F
    DATA:    
    10000000
    200
    128
    80
    

Reply
  • Hi,

    I have found out that when we call radio.read the complete payload list is sent to the Arduino and erased in the nrf24l01 pipe, thus when you call radio.read to store the payload in a single byte (uint8_t incoming_data) the first byte of the payload is stored and the rest is discarded.

    Below is the Arduino code that worked for me thanks to moso(I'm using Arduino mega 2560):

    #include <SPI.h>
    #include <nRF24L01.h>
    #include <RF24.h>
    #include "printf.h"
    
    RF24 radio(7, 8);
    int packetCounter = 0;
    uint8_t incoming_data[8];
    uint8_t message[1];
    
    int64_t pipe_adress[2] = {0xC2C2C2C2C2, 0xE7E7E7E7E7};
    
    void setupRadio()
    {
      radio.begin();
      radio.setRetries(15, 15);
      radio.setChannel(2);
      radio.setDataRate(RF24_2MBPS);
      radio.setPALevel(RF24_PA_MAX);
      radio.enableDynamicPayloads();
      radio.openReadingPipe(0, pipe_adress[1]);
      radio.openReadingPipe(1, pipe_adress[0]);
      radio.startListening();
      radio.printDetails();
    }
    
    void setup() {
      Serial.begin(115200);
      printf_begin();
      
      setupRadio();
    }
    void loop() {
    
      if (radio.available()) {
        radio.read(incoming_data, 8);
    
        Serial.println("DATA:    ");
    
        Serial.println(incoming_data[1], BIN);
        Serial.println(incoming_data[1], OCT);
        Serial.println(incoming_data[1], DEC);
        Serial.println(incoming_data[1], HEX);
        delay(50);
      }
    }

    And here is a sample output:

    DATA:    
    1111101
    175
    125
    7D
    DATA:    
    1111110
    176
    126
    7E
    DATA:    
    1111111
    177
    127
    7F
    DATA:    
    10000000
    200
    128
    80
    

Children
Related