Hey guys, I have a small problem that I don't understand.
I have a arduino nano with nothing but the NRF24L01 modul connected as a sender, it uses the following code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
int msg[1];
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void){
Serial.begin(9600);
printf_begin();
radio.begin();
// radio.setDataRate(RF24_250KBPS);
// radio.setPALevel(RF24_PA_MAX);
// radio.setChannel(70);
// radio.setRetries(15,15);
// radio.setCRCLength(RF24_CRC_16);
radio.openWritingPipe(pipe);
radio.printDetails();
Serial.println();
Serial.println("Ready.");
delay(50);
}
void loop(void){
for (int x=0;x<255;x++){
msg[0] = x;
Serial.println(msg[0]);
radio.write(msg, 1);
delay(1500);
}
}
(I tried it with and without commenting these five currently commented lines)
And also an arduino uno with the same module and an RFID-Card reader on SPI.
The arduino uno currently has the following code loaded:
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
#include "printf.h"
int msg[1];
RF24 radio(7,4);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void){
Serial.begin(9600);
printf_begin();
radio.begin();
// radio.setDataRate(RF24_250KBPS);
// radio.setPALevel(RF24_PA_MAX);
// radio.setChannel(70);
// radio.setRetries(15,15);
// radio.setCRCLength(RF24_CRC_16);
radio.openReadingPipe(1,pipe);
radio.startListening();
radio.printDetails();
Serial.println();
Serial.println("Ready.");
}
void loop(void){
if (radio.available()){
bool done = false;
while (!done){
done = radio.read(msg, 2);
Serial.println(msg[0]);
}
}
}
Got the code from here, just modified it a bit.
The Nano is definitely sending, I've used a CC308+ to test it.
The wiring is definitely okay too, when I try a complete serial chat using the exact same hardware setup, it works. The RFID-Card reader is working too, so I'm sure I didn't mess up the SPI wiring.
Some very very very rare times the uno received the "0" the nano sends at first, but that happens only once a day in lots of tries. No changes in the hardware or wires at all.
The chat works all the times. I also tried the RF24 send/receive example: Sometimes it works, most times that one doesn't work too.
I have no clue what to check and what I could look for. Thanks in advance for any help!