Having issues with my NRF24L01 modules

Hello,

Problem: I'm having issues with my NRF24 modules for a while now, the wiring and all seems OK but for some reason I can't get them to work. From the 1000 messages I send probably, like only 8 got received, this gives me the idea that the wiring is OK but that the problem is somewhere else.
Library using: Library

I used the default (in my Arduino library thingy) library first called RF24, but then I saw Robin and a few others on multiple threads that I should use this one, sadly it didn't help.

Module using (NRF24): Click here

I'm using a real Arduino Uno (running on windows PC) and a clone Arduino Mega (running on my Macbook)

The pinout is as 'default':
VCC -> 3.3V
GND -> GND
MOSI -> 11
MISO -> 12
SCK -> 13
CSN -> 8
CE -> 7

The Transmitter test code:

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

#define radio_SS_pin  8
#define radio_CE_pin  7
RF24 radio(radio_CE_pin, radio_SS_pin);
const char SendHint3[] = "SendText";

const byte adres[][6] = {"10101","01010"};

void setup() {
  Serial.begin(115200);
  radio.begin();
  radio.setChannel(116);
  radio.setPALevel(RF24_PA_MIN);
  radio.openWritingPipe(adres[1]);
  radio.openReadingPipe(1,adres[0]);
  delay(1000);
  radio.stopListening();

}

void loop() {
  radio.write(&SendHint3, sizeof(SendHint3));
  Serial.println("Send");
  delay(100);

}

Receiver code:

#include <SPI.h>  
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>

RF24 myRadio (7, 8); 
char ReceiveHint3[] = " ";

byte adres[][6] = {"10101","01010"}; 

void setup() 
{
  Serial.begin(115200);

  myRadio.begin(); 
  myRadio.setChannel(116);
  myRadio.setPALevel(RF24_PA_MIN); 
  myRadio.openWritingPipe(adres[0]);
  myRadio.openReadingPipe(1,adres[1]);
  myRadio.startListening();
}


void loop()  
{

  if ( myRadio.available()) 
  {
    while (myRadio.available())
    {
      myRadio.read(&ReceiveHint3, sizeof(ReceiveHint3) );
    }
    Serial.println("RECEIVED!" );
    Serial.println(ReceiveHint3);
  }

}

So yet again: I'm receiving something, but only like 10x times each 1000 messages!

Thanks for any help, I hope that I've provided enough information!

Edit: I know about these power problems, but that shouldn't be the main issue to get it not receiving, I've seen enough video's who didn't do it, I did order NRF24 sockets to get it working hopefully more properly.

I know about these power problems, but that shouldn't be the main issue to get it not receiving, I've seen enough video's who didn't do it, I did order NRF24 sockets to get it working hopefully more properly.

This Simple nRF24L01+ Tutorial may help.

...R

Robin2:
This Simple nRF24L01+ Tutorial may help.

...R

Yes I have already, but sadly it's still not working and I have no clue why.

By the way you said:
"If you are using pins other than 10 and 9 for CSN and CE you must still set pin 10 for OUTPUT to ensure that the Uno acts as the SPI master."
I'm using pin 7 and 8, and a RFID reader is using pin 10, do I have to put 7 or 8 as an OUTPUT, or pin 10, or nothing because the MFRC library will do that for me?

Does my tutorial work for you if you use it completely unchanged? (and with nothing else connected to your Arduino).

Does the RFID reader use SPI?
If not, what does it use pin 10 for?

...R

Robin2:
Does my tutorial work for you if you use it completely unchanged? (and with nothing else connected to your Arduino).

Does the RFID reader use SPI?
If not, what does it use pin 10 for?

...R

Yes the RFID reader uses SPI, but without the RFID reader and just a blank Arduino it does the exact same thing, it only receives like 1/10...

  if ( myRadio.available())
  {
    while (myRadio.available())
    {
      myRadio.read(&ReceiveHint3, sizeof(ReceiveHint3) );
    }
    Serial.println("RECEIVED!" );
    Serial.println(ReceiveHint3);
  }

What is the while for?

The way it is now, it silently eats packets (while there are some to eat).

Just drop the while loop.

Yes the RFID reader uses SPI, but without the RFID reader and just a blank Arduino it does the exact same thing, it only receives like 1/10...

Without the RFID reader running it should not work at all (unless you make pin 10 an output).

Whandall:
Without the RFID reader running it should not work at all (unless you make pin 10 an output).

For some reason it does work tho.. I think the library might do that automatically or something?

I'll remove the while loop!

    // Initialize pins
    if (ce_pin != csn_pin) pinMode(ce_pin,OUTPUT);  
  
    #if ! defined(LITTLEWIRE)
      if (ce_pin != csn_pin)
    #endif
        pinMode(csn_pin,OUTPUT);
    
    _SPI.begin();
    ce(LOW);
  	csn(HIGH);

so it is probably 'or something' the library does not touch pin 10.

Oh.. but for some reason it does work though without defining pin 10 as an OUTPUT... is it really needed?

Note about Slave Select (SS) pin on AVR based boards

All AVR based boards have an SS pin that is useful when they act as a slave controlled by an external master.
Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface
could be put automatically into slave mode by hardware, rendering the library inoperative.

Whandall:
SPI - Arduino Reference

Thanks man! But do I have to do it because it's just connected to pin 10, or should I do it to pin 4 or something as well when that's a SS pin?

The AVRs have hardware SS pins, different from type to type.
That pin should be set to output, regardless of the SS-pin that is really used by the library.

Whandall:
The AVRs have hardware SS pins, different from type to type.
That pin should be set to output, regardless of the SS-pin that is really used by the library.

Alright so I have to set all the SS pins to output?

No, on an Uno/Nano/.. only pin 10, on Mega pin 53, on Leonardo/Micro i don't know, ...

akatchi:
Yes the RFID reader uses SPI, but without the RFID reader and just a blank Arduino it does the exact same thing, it only receives like 1/10...

This refers to my Tutorial.

I can't figure from the rest of this Thread whether you now have reliable wireless communication working without the RFID reader connected.

If not get the communication working properly first. My tutorial codes do work. If they don't work for you then post the programs that YOU uploaded to your Arduinos and I will try to help.

...R

Robin2:
I can't figure from the rest of this Thread whether you now have reliable wireless communication working without the RFID reader connected.

With and without the RFID reader connected it won't work.

Robin2:
If not get the communication working properly first. My tutorial codes do work. If they don't work for you then post the programs that YOU uploaded to your Arduinos and I will try to help.

I have used your tutorial codes before and these didn't work either, but I'll try them again, let's see!
(Btw I've posted in this thread the TX and RX code that I was using).

Test codes from you still not working Robin :(. Output monitors:

TX:

SimpleTx Starting
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed

And so on...

RX:

SimpleRx Starting

Nothing happens..

After like 1000 messages sent I received only 1 message in the receiver!
TX:

Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Acknowledge received
Data Sent Message 1  Tx failed
Data Sent Message 1  Tx failed

RX:

Data received Message 0

But yet only 1 message from all the other 1000... :frowning:

akatchi:
But yet only 1 message from all the other 1000... :frowning:

You have posted the output from your programs. But I want you to post the program code that YOU have uploaded to your Arduinos and which produces those messages.

Also, it can sometimes help to disconnect the Arduino from the USB cable and re-connect it to ensure that the nRF24 resets.

...R