-1

I have been trying to connect a nRF24L01 to a Cubecell AB01 without much luck. Most of the time, the radio.available() function always returns true resulting in a bunch of garbage. I have figured out that the nRF24L01 doesn't want to configure properly. With printPrettyDetails() I can confirm that the settings are not stored.

However, with the example sketch contained within the RF24 library, everything works fine (confirming that the AB01 and nRF24L01 are working fine). But as soon as I change the datatype of the receiver payload to uint8_t, the radio.available() is always true, resulting in a bunch of received messages with garbage. PrintPrettyDetails() also shows the wrong settings.

Does anyone have experience with this? I have also tried the example sketch from Robin2. This results in a lot of garbage as described before.

I am using:

  • nRF24L01 with pcb antenna. I am periodicially using an esp32 to test that the nRF24L01 is still functioning okay
  • a heltec AB01. The nRF24L01 is connected to the spi interface and CE -> GPIO3 and CSN -> GPIO2
  • To program I'm using platformio. But in desperation I am also able to use the Arduino IDE (exactly the same behaviour)

RX code: /** * See documentation at https://nRF24.github.io/RF24 * See License information at root directory of this library * Author: Brendan Doherty (2bndy5) */

    /**
     * A simple example of sending data from 1 nRF24L01 transceiver to another.
     *
     * This example was written to be used on 2 devices acting as "nodes".
     * Use the Serial Monitor to change each node's behavior.
     */
    #include <SPI.h>
    #include "printf.h"
    #include "RF24.h"

    // instantiate an object for the nRF24L01 transceiver
    RF24 radio(GPIO3, GPIO2); // 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"};
    // It is very helpful to think of an address as a path instead of as
    // an identifying device destination

    // to use different addresses on a pair of radios, we need a variable to
    // uniquely identify which address this radio will use to transmit
    bool radioNumber = 1; // 0 uses address[0] to transmit, 1 uses address[1] to                                 transmit

    // Used to control whether this node is sending or receiving
    bool role = false;  // true = TX role, false = RX role

    // For this example, we'll be using a payload containing
    // a single float number that will be incremented
    // on every successful transmission
    float payload = 0;

    void setup() {

      Serial.begin(115200);
      while (!Serial) {
        // some boards need to wait to ensure access to serial over USB
      }
      pinMode(Vext, OUTPUT);
      digitalWrite(Vext, LOW);
      delay(10);
      // initialize the transceiver on the SPI bus
      if (!radio.begin()) {
        Serial.println(F("radio hardware is not responding!!"));
        while (1) {} // hold in infinite loop
      }

      // print example's introductory prompt
      Serial.println(F("RF24/examples/GettingStarted"));
      
      radioNumber = 1;
      Serial.print(F("radioNumber = "));
      Serial.println((int)radioNumber);
    
      // Set the PA Level low to try preventing power supply related problems
      // because these examples are likely run with nodes in close proximity to
      // each other.
      radio.setPALevel(RF24_PA_LOW);  // RF24_PA_MAX is default.
    
      // save on transmission time by setting the radio to only transmit the
      // number of bytes we need to transmit a float
      radio.setPayloadSize(sizeof(float)); // float datatype occupies 4 bytes

      // set the TX address of the RX node into the TX pipe
      radio.openWritingPipe(address[radioNumber]);     // always uses pipe 0
    
      // set the RX address of the TX node into a RX pipe
      radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1

      // additional setup specific to the node's role
      if (role) {
        radio.stopListening();  // put radio in TX mode
      } else {
        radio.startListening(); // put radio in RX mode
      }

      // For debugging info
      // printf_begin();             // needed only once for printing details
      // radio.printDetails();       // (smaller) function that prints raw register values
       radio.printPrettyDetails(); // (larger) function that prints human readable data

    } // setup

    void loop() {

        // This device is a RX node

        uint8_t pipe;
        if (radio.available(&pipe)) {             // is there a payload? get the pipe         number that recieved it
          uint8_t bytes = radio.getPayloadSize(); // get the size of the payload
          radio.read(&payload, bytes);            // fetch payload from FIFO
          Serial.print(F("Received "));
          Serial.print(bytes);                    // print the size of the payload
          Serial.print(F(" bytes on pipe "));
          Serial.print(pipe);                     // print the pipe number
          Serial.print(F(": "));
          Serial.println(payload);                // print the payload's value
        }

    } // loop

I have tried anything I could think of, without success. Any help would be appreciated!

1 Answer 1

0

Turned out to be a corrupt library and an SPI speed mismatch

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.