Go Down

Topic: nrf24l01 not working (Read 68 times) previous topic - next topic

Rutger13

Feb 23, 2021, 05:41 pm Last Edit: Feb 23, 2021, 05:42 pm by Rutger13
Hi,
I can't get my nrf24l01 to work. I am aware that many other people have the same problem and many solutions have been found. I think I have tried all of them:
-          I have banned long jumper wires and soldered the circuit on perfboard (checked for continuity).
-          I have added a 100uf capacitor between 3.3v and ground.
-          I have used a different power source than the Arduino 3.3v pin.
-          I have tried different nrf24l01 module combinations.
-          I have tried different codes that seem to work with other people.

I don't know what to try next. One of the codes I tried is this one:


Code: [Select]
//transmitter

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

// Instantiate RF24 class with CE and CSN values
RF24 radio(7, 8);
// Address to devices comunicate each other (same in both)
const uint64_t pipe = 0xE8E8F0F0E1LL;
// A variable to hold some info
boolean info = false;

void setup() {
  // Setup serial output
  Serial.begin(9600);
  // Start RF
  radio.begin();
  // Setup the channel to work within, number 100
  radio.setChannel(100);
  // Open wite pipe
  radio.openWritingPipe(pipe);
}

void loop() {
  // it changes every interval
  info = !info;

  if (info) {
    Serial.print("Sending positive... ");
  } else {
    Serial.print("Sending negative... ");
  }

  // Send info over RF
  bool success = radio.write(&info, sizeof(boolean));

  if (success) {
    Serial.println("sent!");
  } else {
    Serial.println("fail!");
  }

  // Wait 2 seconds and repeat
  delay(2000);
}


Code: [Select]
//receiver

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

// Instantiate RF24 class with CE and CSN values
RF24 radio(8, 7);
// Address to devices comunicate each other (same in both)
const uint64_t pipe = 0xE8E8F0F0E1LL;
// A variable to hold some info
boolean info = false;

void setup() {
  // Setup serial output
  Serial.begin(9600);
  // Start RF
  radio.begin();
  // Setup the channel to work within, number 100
  radio.setChannel(100);
  // Open recept pipe
  radio.openReadingPipe(1, pipe);
  // Start to listen
  radio.startListening();
}

void loop() {
  // Wait until some data
  if (radio.available()) {
    // Read payload, and check if it finished
    radio.read(&info, sizeof(info));
    // Manage info
    if (info) {
      Serial.println("We received positive!");
    } else {
      Serial.println("We received negative!");
    }
  }
  // Wait a bit
  delay(50);
}


The transmitter keeps posting sent. The receiver keeps posting received positive. Same thing when I don't connect a module at all. When I connect a different module to the receiver side, it posts nothing.
What should I try next?

Kind regards





Robin2

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to. If the first example does not work be sure to try the connection test for both of your Arduinos. Nothing will work if the connection test fails.

A common problem with nRF24 modules is insufficient 3.3v current from the Arduino 3.3v pin. This seems to be a particular problem with the nano. The high-power nRF24s (with the external antenna) will definitely need an external power supply. At least for testing try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.

If you are using the high-power nRF24s (with the external antenna) it may help to have a distance of about 3 metres between the two nRF24s so that the signal does not overwhelm the receiver. However someone on the Forum has had them working without that separation - I don't have any personal experience with them. If you are new to nRF24s it may be better to start with a pair of low power modules with the pcb antenna.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Whandall

You should also make sure to use a working library.
The code you posted comes from an outdated library (maniacbug).

I would suggest using https://github.com/nRF24/RF24.
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)

Rutger13

#3
Feb 24, 2021, 03:07 pm Last Edit: Feb 24, 2021, 03:09 pm by Rutger13
Hi,
I have used the test code to check the connection between the nrf24l01 and the Arduino. One of my modules is broken. With the other two I got these results.





I used the test code you provided. I changed the CE an CSN to pin 7 and 8. I added the line: pinMode(10, OUTPUT);. (Does this mean I can't use pin 10 in later projects?). This is the output I got.





It looks like there is at least some connection between the two. Is this because there is something wrong with the feedback?



Robin2

#4
Feb 24, 2021, 04:01 pm Last Edit: Feb 24, 2021, 04:02 pm by Robin2
I used the test code you provided. I changed the CE an CSN to pin 7 and 8. I added the line: pinMode(10, OUTPUT);. (Does this mean I can't use pin 10 in later projects?).
Until you get things working don't change anything.


Pin 10 must be set as OUTPUT but it does not have to be used for SS (CSN).

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up