EDIT: solution on post #30 and following
Hi !
I'm looking for some help here regarding a wered issue I'm facing with RF modules and Mirf lib.
I'm trying to light ON and OFF some LED modules, but depending the code I use the message is sometimes not received (or sent I don't know).
I use:
Arduino Pro Micro ATMega 32U4 5V 16Mhz
NRF24L01+ 2.4GHz RF Wireless Transceiver + Socket Adapter plate Board
Mirf nRF24L01 library for RF interface
Arduino IDE 1.8.8
The following code is working, the LED modules are receiving well the 1000 requests (tried several times) :
void test() {
for (int i = 0; i < 1000; i++) {
sendToBtn(1, "cmd22");
delay(300);
sendToBtn(2, "cmd22");
delay(300);
sendToBtn(3, "cmd22");
delay(300);
sendToBtn(4, "cmd22");
delay(300);
sendToBtn(5, "cmd22");
delay(300);
sendToBtn(6, "cmd22");
delay(300);
sendToBtn(7, "cmd22");
delay(300);
}
}
These codes aren't working, some requests aren't received by LED modules ( ~20% are lost):
void test2() {
int num = 0;
byte buto[] = { 7,5,1,6,7,1,5,7,1,7,5,6,5,7,1,6,1,5,1,5,7,6,7,1,5,6,7,6,5,1,6,7,5,7,6,5 };
for (int i = 0; i < sizeof(buto); i++) {
sendToBtn(buto[i], "cmd22");
delay(300);
}
}
void randomBlinkBtn() {
int turns = btnCount * 10;
int rnd = 0;
int last = 0;
for (int i = 1; i<turns; i++) {
rnd = getRandomButton(last);
last = rnd;
sendToBtn(rnd,"cmd22");
delay(300);
}
sendToBtn(getRandomButton(last), "cmd11");
}
My sent code :
void sendToBtn(int butID, char* data) {
Mirf.setTADDR(btnNames[butID]);
delay(50);
Mirf.send((uint8_t*) data);
unsigned long time = millis();
while (Mirf.isSending()) ;
}
}
I don't think it's a hardware issues as some code is working well.
I've placed 30uF cap on RF modules but that doesn't help.
Mirf config:
Mirf.cePin = A1;
Mirf.csnPin = A0;
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *) "btn00"); // Configure transmitting address.
Mirf.payload = 7;
Mirf.channel = 90;
Mirf.configRegister(RF_SETUP, 0x0E); //2Mbps
Mirf.configRegister(SETUP_RETR, 0x0F); //Up to 15 retries
Mirf.configRegister(EN_RXADDR, 0x3F); //Activate all channels
Mirf.configRegister(EN_AA, 0x3F);
Mirf.config();
Control module :
LED Module :
Does anyone already face the same issue ?
Thanks in advance for any advice regarding this strange issue I'm unable to fix.
Regards