I am trying to get a Nano and an Uno to communicate via NRf24's but I can't seem to get it to work.
I have been looking for answers for this for the last two days but i cant find anything so now im asking here.
I have tried four different Tutorials trying to get my Nano to wirelessly send a hello world to my Uno but it has never worked.
I have 3 NRF24Lo1+ modules and I've tried this with all of them in every possible combination.
I have added some Serial-println lines as so i can watch the serial monitor and see if the programm is running correctly and as far as I can tell nothing is wrong there. (I would try some of my other Nano's but my soldering Iron broke and i cant seem to get the cables to connect reliably by just putting them in the holes)
Another Uno is in the mail and should arrive tomorrow so I can test it with that then but I really dont think either of the arduinos is damaged as they have no problems with any other sketches I upload to them.
My Arduinos and my NRf24's are from AZ-Delivery and I have properly installed the needed USB-drivers.
This is the first Tutorial I followed:
HowToMechatronicsTutorial
I am aware that the SPI pins of the Mega and the Uno are different I have connected mine correctly.
This tutorial also gives the wrong SPI-pins for the Nano, which i have also connected correctly
The code from this Tutorial is the one I modified with the Serial.println()
My Transmitter Code (running on the Nano):
/*
* Arduino Wireless Communication Tutorial
* Example 1 - Transmitter Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
Serial.println ("Setup Done");
}
void loop() {
const char text[] = "Hello World";
Serial.println("text set");
radio.write(&text, sizeof(text));
Serial.println("Message sent");
delay(1000);
}
This is what appears in the Serial Monitor:
13:13:59.285 -> Setup Done
13:13:59.285 -> text set
13:13:59.331 -> Message sent
13:14:00.300 -> text set
13:14:00.347 -> Message sent
13:14:01.318 -> text set
13:14:01.364 -> Message sent
13:14:02.379 -> text set
13:14:02.379 -> Message sent
13:14:03.392 -> text set
13:14:03.439 -> Message sent
13:14:04.406 -> text set
13:14:04.452 -> Message sent
As you can see this is looking excatly as it is supposed to do
This is my Receiver Code (running on the Uno):
/*
* Arduino Wireless Communication Tutorial
* Example 1 - Receiver Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8 ); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
Serial.println("Setup Done");
}
void loop() {
if (radio.available()) {
Serial.println("Data received");
char text[32] = "";
radio.read(&text, sizeof(text));
Serial.println(text);
Serial.println("cycle complete");
}
Serial.println("loop running");
}
This appears in the Serial Monitor:
13:17:17.529 -> Setup Done
13:17:17.529 -> loop running
13:17:17.529 -> loop running
13:17:17.529 -> loop running
13:17:17.529 -> loop running
13:17:17.576 -> loop running
13:17:17.576 -> loop running
13:17:17.622 -> loop running
Here we can see that the loop is running but it doesn't detect anything over wireless so it doesn't write "Data received" or "cycle complete"
This is the second Tutorial:
InstructablesCurcuitsTutorial
The Code they have listed for the receiver needed a few more brackets before it was able to be compiled but then it uploaded without a Problem but it still didn't work
The third Tutorial:
I cant find it anymore but I do remember that the Code wouldn't compile and I couldn't fix it.
The fourth Tutorial:
I used the Code from a post in this Forum which supposedly works: ForumPost
The Server Code results in this in the Serial Monitor:
13:30:12.790 -> init failed
13:30:12.883 -> Sent data
13:30:15.003 -> Sent data
13:30:17.075 -> Sent data
13:30:19.197 -> Sent data
13:30:21.271 -> Sent data
13:30:23.393 -> Sent data
13:30:25.466 -> Sent data
13:30:27.585 -> Sent data
The Client Code results in this in the Serial Monitor:
13:33:31.459 -> init failed
13:33:36.487 -> No message, is nrf24_server running?
13:33:41.509 -> No message, is nrf24_server running?
13:33:46.490 -> No message, is nrf24_server running?
13:33:51.509 -> No message, is nrf24_server running?
I have installed all the libraries required by the sketches.
I am relatively new to arduino so please assume that I made every possible stupid mistake.
Thanks in advance
I'll put all the things I already checked for because of suggestions from here in this List (as long as I can edit my post of course):
/