This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

want nrf24l01 communication with nrf51822

hello,will you please tell me which code i have to use in the sdk 12.2.0 for rf communication with nrf51822 and nrf24l01 .and also tell me which settings i have to do for nrf24l01 side as a transmitter.so that i can receive data on nrf51822 side.

  • hello sir , this is working code.now it is compiled.previously i have added wrong file thats why its not compiled but now it is compiled but i am not receing data on other side.i aqm using nrf24l01 module.i am not using nrf24l01+ Pallavi

  • Hi Pallavi
    Could you send me a link to the type of module you are using?
    In general I would strongly recommend using the nRF24L01+. The price should be the same, and it comes with some improvements over the nRF24L01 that are useful to have.

    With the nRF24L01 you have to run a special command called ACTIVATE to enable the use of features such as dynamic payload length, dynamic ACK, and ACK payload. This command has to be run before you turn on these features (through the DYNPD and FEATURE registers).

    Could you try to include the following function in the code I sent you, and call it before you configure the other registers?

    void hal_nrf_activate()
    {
        uint8_t spi_tx_data[2];
        uint8_t spi_rx_data[2];
    
        CSN_LOW();
        spi_tx_data[0] = 0x50;
        spi_tx_data[1] = 0x73;
        nrf_drv_spi_transfer(&m_current_l01_instance->spi_instance, spi_tx_data, 2, spi_rx_data, 2);
        CSN_HIGH();
    }
    

    Best regards
    Torbjørn

  • Hello Sir,

    My intention is to run a simple transmitter and receiver between NRF51822 and Arduino Uno +NRF24L01.

    Please see below working code for a Transmitter and Receiver both using Arduino Uno + NRF24L01 Library for NRF24L01 (http://tmrh20.github.io/RF24/)

    Pin Configuration: NRF24 Arduino 1 GND GND 2 VCC VCC 3 CE Analog 4 4 CSN Analog 5 5 SCK digIO 13 6 MOSI digIO 11 7 MISO digIO 12

    Transmitter Code with its Configurations

    #include <SPI.h> #include <nRF24L01.h> #include <RF24.h> #define CE 18 #define CSN 19 RF24 radio(CE, CSN); unsigned char values; const byte rxAddr[5] = {0xC0,0x01,0x23,0x45,0x67};

    void setup() { Serial.begin(9600); radio.begin(); radio.setPALevel(RF24_PA_MAX); radio.setDataRate(RF24_1MBPS); radio.setChannel(7); radio.openWritingPipe(rxAddr); radio.stopListening();

    }

    void loop() { values = 0x10; radio.write(&values,1); delay(2000); // Serial.print(value); //prints the character just read }

    Receiver Code with its Configurations

    #include <SPI.h> #include <nRF24L01.h> #include <RF24.h> #define CE 18 #define CSN 19 RF24 radio(CE, CSN); unsigned char values; const byte rxAddr[5] = {0xC0,0x01,0x23,0x45,0x67};

    void setup() { Serial.begin(9600); radio.begin(); radio.setPALevel(RF24_PA_MAX); radio.setDataRate(RF24_1MBPS); radio.setChannel(7); radio.openReadingPipe(0, rxAddr); radio.startListening(); }

    void loop() { if (radio.available()) { char text; radio.read(&text, 1); Serial.print(text); } }

    Please suggest whats should i do with respect to NRF51822 to work with these transmitter and receiver code respectively. We have been discussing all for so long but haven't come to a conclusion. So can you help me in code with simple configuration mentioned in the code above and run transmitter and receiver successfully.

    Regards Pallavi

  • Hello Sir,

    My intention is to run a simple transmitter and receiver between NRF51822 and Arduino Uno +NRF24L01.

    Please see below working code for a Transmitter and Receiver both using Arduino Uno + NRF24L01 Library for NRF24L01 (http://tmrh20.github.io/RF24/)

    Pin Configuration: NRF24 Arduino 1 GND GND 2 VCC VCC 3 CE Analog 4 4 CSN Analog 5 5 SCK digIO 13 6 MOSI digIO 11 7 MISO digIO 12

    Transmitter Code with its Configurations

        #include <SPI.h>
        #include <nRF24L01.h>
        #include <RF24.h>
        #define CE 18
        #define CSN 19
        RF24 radio(CE, CSN);
        unsigned char values;
        const byte rxAddr[5] = {0xC0,0x01,0x23,0x45,0x67};
        
        void setup()
        {
          Serial.begin(9600);
          radio.begin();
          radio.setPALevel(RF24_PA_MAX);
          radio.setDataRate(RF24_1MBPS);
          radio.setChannel(7);
          radio.openWritingPipe(rxAddr);
          radio.stopListening();
        
        }
    
    void loop()
    {
             values = 0x10;
             radio.write(&values,1);
             delay(2000);
          //  Serial.print(value);  //prints the character just read
     }
    

    Receiver Code with its Configurations

    #include <SPI.h>
    #include <nRF24L01.h>
    #include <RF24.h>
    #define CE 18
    #define CSN 19
    RF24 radio(CE, CSN);
    unsigned char values;
    const byte rxAddr[5] = {0xC0,0x01,0x23,0x45,0x67};
    
    void setup()
    {
      Serial.begin(9600);
      radio.begin();
      radio.setPALevel(RF24_PA_MAX);
      radio.setDataRate(RF24_1MBPS);
      radio.setChannel(7);
      radio.openReadingPipe(0, rxAddr);
      radio.startListening();
    }
    
    void loop()
    {
      if (radio.available())
      {
        char text;
        radio.read(&text, 1);
        Serial.print(text);
      }
    }
    

    Please suggest whats should i do with respect to NRF51822 to work with these transmitter and receiver code respectively. We have been discussing all for so long but haven't come to a conclusion. So can you help me in code with simple configuration mentioned in the code above and run transmitter and receiver successfully.

    Regards Pallavi

  • It seems the code has changed a bit since we started this discussion. Can you send me the latest result when calling the printDetails() function? Then I can try to configure an nRF24L01+ module on my end, and see how to make the nRF51 code compatible.

    Best regards

Related