Hi.
My project require communication between two arduino unos, so i'm using the nRF24L01 transreciever with the base module NRF24LD1 and the TMRh20 library (v3.0) available through library manager in Arduinos IDE . I've tried a lot of different approaches but i simply cannot get anything to work.
Physical setup:
Using the standard pins:
7 - CE
8 - CSN
13 - SCK
11 - MO
12 - MI
the reciever code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
void setup()
{
while (!Serial);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, rxAddr);
radio.startListening();
}
void loop()
{
if (radio.available())
{
char text[32] = {0};
radio.read(&text, sizeof(text));
Serial.println("text: ");
Serial.print(text);
}
}
The transmitter code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
void setup()
{
Serial.begin(9600);
radio.begin();
radio.setRetries(15, 15);
radio.openWritingPipe(rxAddr);
radio.stopListening();
}
void loop()
{
const char text[] = "Hello World";
Serial.println("pre");
radio.write(&text, sizeof(text));
Serial.println("post");
delay(1000);
}
For the reciever I have this problem:
No matter what i do, the radio.available() returns true, even though there are no transmitter sending data. I can remove all wires completely so the arduino is blank, but still the radio.available() returns true. (the serial monitor shows infinite of "text: ")
For the transmitter I have this problem:
The program stops at the radio.write(), (the serial monitor only show "pre"). If I pull out the nRF24L01 module from the base socket, the program goes past the .write() function, but then it obviously dosn't send any data, (the serial monitor shows "pre, post" in one second interval).
I know the hardware is working, I got a fellow student to upload his code, used for controlling a drone, to my arduino, and it worked fine. Unfortunately he is not using the TMRh20 library, but some other library made specially for the drone, using other pins etc.
So far i have:
- Tried three different arduinos, all behave the same.
- powered up the circuit by an external powersupply 5 V.
- Installed previous version of TMRh20 library (v2.0).
- Looked over (100 times) that pins are correctly wired.
- tried most of the example codes from different places, none of them made any differance
- tried th use the ICSP pins instead of 11,12,13 pin
- measured the resistance of the wires
If someone can point out a obvious mistake I've made, I couldn't be more happy. I simply do not know any more things to check for. For me it sounds like a hardware connection error, but if it is, I can't find it.