Hi everyone....I watched youtube video The nRF24L01 - Wireless Joystick for Arduino Robot Car with nRF24L01+...so I went on amazon and ordered some nrf24L01 modules as well as the breakout boards so I could power with 5vdc and a couple of unos. I followed the sketches and hooked up the wiring as Bill described. Turned on serial monitor with the server sketch and got "init failed". not understanding why my setup is not working. I've swapped the sketches but no change, I swapped the nrf24L01 module/adapter/uno on each computer...no change...any ideas why this is not working? Looking forward to some troubleshooting advice...thanks Geoff
Regards,
Geoff
I've done that exercise on a couple of occasions and can't remember if I had any particular error that I had to contend with, but your error was a little vague to me. At what point did you get the "init failed" message.
Was it after you had finished uploading the server sketch, then opened the serial monitor? Was it immediately after an upload sequence? Where was the message displayed? On the serial monitor or in the Arduino IDE? Also if there are differences in the versions of libraries that Bill was using when he made the video and the versions used when you tried to replicate the work, that can also produce compile errors but I'm not sure if that could cause the "init failed" message.
I guess we need more information.
SteveG
Hi Steve
Thanks for your reply. Let me hook everything back up (hopefully by this weekend) and take some screen shots. I am using a windows laptop and another older 32 bit laptop which I installed Linux mint. I wanted to see serial monitors on both the server and client do their thing. Now that I am on this forum, I will post pictures and the two sketches. Appreciate your response. Look for a post in a day or so.
Regards,
Geoff
Understand, as I would have to set mine back up as well to try to mimic what you are experiencing.
In trying to understand what you are experiencing, are you saying that the compile of both the client and the server ran with no errors? As well as the upload to both, and then the error popped up when you tried to open the serial monitor on the server, but not on the client?
SteveG
@codecage Hi
Attached to this reply showing snips of server and client serial monitors. Just for fun, I also swapped sketches to each uno/breakout board/nRF24L01 and same issues. The code I am using for each uno is from the youtube video. Can post that as well if needed. Cant understand why this is not working.
Hoping everybody can see the snips. Thanks for looking at this and helping me troubleshoot this issue.
Geoff
Regards,
Geoff
Appears the issue is on the server side as client serial monitor shows action...but not totally sure...it may show messages even if server is not hooked up....Any ideas out there where I am going sideways with this?
Thanks
Geoff
Regards,
Geoff
Also sketch compiles ok and uploads with no errors on each uno
Regards,
Geoff
Hello All...here is server code
// nrf24_server.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing server
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_client
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini ( http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module
#include <SPI.h>
#include <RH_NRF24.h>
// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini
void setup()
{
Serial.begin(9600);
while (!Serial)
; // wait for serial port to connect. Needed for Leonardo only
if (!nrf24.init())
Serial.println("init failed");
// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!nrf24.setChannel(1))
Serial.println("setChannel failed");
if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
Serial.println("setRF failed");
}
void loop()
{
if (nrf24.available())
{
// Should be a message for us now
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (nrf24.recv(buf, &len))
{
// NRF24::printBuffer("request: ", buf, len);
Serial.print("got request: ");
Serial.println((char*)buf);
// Send a reply
uint8_t data[] = "And hello back to you";
nrf24.send(data, sizeof(data));
nrf24.waitPacketSent();
Serial.println("Sent a reply");
}
else
{
Serial.println("recv failed");
}
}
}
Regards,
Geoff
Here is Client code
// nrf24_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_server.
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini ( http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module
#include <SPI.h>
#include <RH_NRF24.h>
// Singleton instance of the radio driver
RH_NRF24 nrf24;
// RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf
// RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin
// RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini
void setup()
{
Serial.begin(9600);
while (!Serial)
; // wait for serial port to connect. Needed for Leonardo only
if (!nrf24.init())
Serial.println("init failed");
// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!nrf24.setChannel(1))
Serial.println("setChannel failed");
if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
Serial.println("setRF failed");
}
void loop()
{
Serial.println("Sending to nrf24_server");
// Send a message to nrf24_server
uint8_t data[] = "Hello World!";
nrf24.send(data, sizeof(data));
nrf24.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (nrf24.waitAvailableTimeout(500))
{
// Should be a reply message for us now
if (nrf24.recv(buf, &len))
{
Serial.print("got reply: ");
Serial.println((char*)buf);
}
else
{
Serial.println("recv failed");
}
}
else
{
Serial.println("No reply, is nrf24_server running?");
}
delay(400);
}
Regards,
Geoff
Will try to get this setup on my bench later today or tomorrow and see what results i get. I know I had it working previously, so just need to look at it again.
SteveG
I got at just one UNO and nRF24L01 module set up on my bench. Since only one was setup, had to run the client and server code separately so my client messages were just like yours as there was no server to catch and acknowledge client messages. But my server gave no indication on the serial monitor that anything was happening. So I added the following to the end of the setup() code to let me know that we had completed the setup() with no errors:
Serial.println("Init Worked, setChannel Worked, setRF Parameters worked...");
Obviously this would also print to the serial monitor if there were errors in any of the 'if' statements, but I had no errors so all I saw was the message that all had worked.
I'll try to get a second UNO and nRF24L01 set up to give a complete test. Stay tuned.
A last thought but not sure it has anything to do with differences in results. I downloaded the nRF24 libraries a good while ago so have no idea if current downloads might give different results. I do have the Linux workstation I built from Bill's video that does not have these nRF24 libraries, so I will download the latest from Radiohead and see if there might be a difference.
SteveG
@geoff666 Geoff, I am using the nRF24L01+ on an Elegoo Smart Car 3.0 with separate power for the car and nRF24L01. After powering everything up I still have to hit the reset on the Arduino Uno to get the transmitter and receiver to work. (using a nano on transmitter).
Arlo
I just duplicated your error with the server code!
But I made it happen without the nRF24L01 connected to my UNO at all. I'll now connect the nRF24L01 and try again. Then I'll report back.
SteveG
All hooked up and things seem to be working. I seem to get slight pauses from time to time in the TX and RX of responses (I turned on Show timestamp in the serial monitor), but other than that did not get you error message or any of the other error messages in the start() code.
I think you said you tried reversing the server and the client setups and the issue followed to whichever was the server. Is that correct? Without changing any wiring?
My two UNOs and nRF24L01s are in separate rooms, but with a common wall between them, so that might explain the periodic missed messages.
Afraid I haven't been of a great help, but it does confirm, to me at least, that the version of RadioHead libraries don't seem to be the issue here. On my server I'm using v1.116 of the RadioHead libraries, just downloaded this morning. I'm not sure at the moment what version of the library is on the other machine, a WIN10 machine, but the libraries were installed some time ago. Maybe even a year or two ago.
SteveG