I have Arduino Leonardo and Micro. I can't manage them to communicate via nRF24L01. I made a receiver and sender sketch to test it and can't see any respond. I tested the same code on two arduino nano and they work fine.
I connected the pins correctly using the ICSP pins in Leonardo and corresponding pins (not ICSP) dedicated for SPI in Micro.
Please could someone tell me what am I missing in porting sketch from nano-nano to leonardo-micro?
Here are the sketches:
PS some additional channels are left to see what I expected from working sketch.
Receiver module:
//NRF24
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
RF24 radio(9, 10);
byte addresses[][6] = {"1Node", "2Node", "3Node", "4Node"};
int channel = 1;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
radio.begin();
radio.setAutoAck(1);
radio.setRetries(15, 15);
radio.openReadingPipe(1, addresses[0]);
radio.openReadingPipe(2, addresses[1]);
radio.openReadingPipe(3, addresses[2]);
radio.openReadingPipe(4, addresses[3]);
radio.startListening();
}
void loop() {
// put your main code here, to run repeatedly:
while (radio.available()) {
char theMessage[13];
radio.read(&theMessage, 13);
Serial.println(theMessage);
if(theMessage == "testingsend"){
//this is removed in nano
digitalWrite(13,HIGH);
delay(50);
digitalWrite(13,LOW);
}
}
}
And the sender:
//NRF24
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
RF24 radio(9, 10);
byte addresses[][6] = {"1Node", "2Node", "3Node", "4Node"};
int channel = 1;
void setup() {
// put your setup code here, to run once:
radio.begin();
radio.setAutoAck(1);
radio.setRetries(15, 15);
radio.openWritingPipe(addresses[channel]);
}
void loop() {
// put your main code here, to run repeatedly:
char theMessage[13] = "testingsend";
radio.write(theMessage, sizeof(theMessage));
memset(theMessage,0,sizeof(theMessage));
delay(300);
}