Notifications
Clear all

init failed RC n24 project


talamasca
(@talamasca)
Active Member
Joined: 2 years ago
Posts: 9
Topic starter  

Hi, i followed one of Bill's projects, well a lot actually, anyways. in this one, the one with the RC car using the radiohead library.

i'm using an arduino nano for the controller and an arduino mega for the car. i've just wired the n24s, they are both the ones with the antenna and im using the adapters that bill uses on the video. when i upload the sketch client to any of the 2 arduinos it initializes without a problem but for the server sketch on any of both boards the serial monitor throws me an init failed message. as i'm using the adaptors, both n24s are connected to the arduino 5v pin. any ideas or suggestions?

thank you very much in advance


Quote
Topic Tags
Pugwash
(@pugwash)
Noble Member
Joined: 2 years ago
Posts: 1011
 

@talamasca

both n24s are connected to the arduino 5v pin. 

You have probably fried the n24l01s, they are only 3.3V tolerant.


ReplyQuote
talamasca
(@talamasca)
Active Member
Joined: 2 years ago
Posts: 9
Topic starter  

@pugwash hi, thanks for the reply. the adaptor that i used has a 3.3v regulator in it. i re-checked the voltage before just in case and it feeds 3.3v.

 


ReplyQuote
Pugwash
(@pugwash)
Noble Member
Joined: 2 years ago
Posts: 1011
 

@talamasca

This clearly demonstrates the need to provide an accurate and exhaustive description of your problem.

You also need to provide the code, and where the problem occurs!

init failed message

My guess is that the code compiled correctly and this message was returned by the Arduino sketch during the setup() function.

A link to the website/youTube page would be helpful, most of us are willing to help but also have our own projects that we are working on and definitely not prepared to start searching the web ourselves to find the reference youTube video!


ReplyQuote
talamasca
(@talamasca)
Active Member
Joined: 2 years ago
Posts: 9
Topic starter  

@pugwash

again sir, thank you for your reply and your time.

so here is the link to the video

u r right, the error comes from the setup() part of the sketch.
here is the code which is just the example from the radiohead library. the sketch is called nrf24_server

#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 ", 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");
}
}
}

uploading this sketch to the arduino nano or to the arduino mega will result in the "init failed" message in the serial monitor. on the other hand if i upload the following sketch to any of the 2 arduinos the error won't happen. (the following sketch is called nrf24_client).

 

#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);
}

again thank you for your time. and please let me know if there is some more information that i can provide.

 

 

 

This post was modified 2 years ago 3 times by talamasca

ReplyQuote
Pugwash
(@pugwash)
Noble Member
Joined: 2 years ago
Posts: 1011
 

@talamasca

Try this on the Nano:

// Singleton instance of the radio driver
RH_NRF24 nrf24(10,9);

I will have to look at the Mega pins before I can give you the right pin setup for the Mega!


ReplyQuote
Pugwash
(@pugwash)
Noble Member
Joined: 2 years ago
Posts: 1011
 

I think this would work on the Mega:

// Singleton instance of the radio driver
RH_NRF24 nrf24(53,52);

Just make sure the wiring is correct! CE to 53 and CSN to 52.

Good luck!


ReplyQuote
talamasca
(@talamasca)
Active Member
Joined: 2 years ago
Posts: 9
Topic starter  

@pugwash

i tried this both with your advice and i got the same results.

i'll just leave here the code that i tried.


#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
//RH_NRF24 nrf24(53,52); // for Mega (CE,CSN)
RH_NRF24 nrf24(10,9); // for nano
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 ", 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");
}
}
}



so i would just uncomment the line depending which board i'm uploading it to
This post was modified 2 years ago by talamasca

ReplyQuote
Pugwash
(@pugwash)
Noble Member
Joined: 2 years ago
Posts: 1011
 

@talamasca

Sorry, I gave you some wrong information. This is the actual pin connections for Uno/Nano and Mega.

SPI

So the declarations should be:

// Singleton instance of the radio driver for the Nano
RH_NRF24 nrf24(8,10); // nrf24(CE ,CSN )
// Singleton instance of the radio driver for the Mega
RH_NRF24 nrf24(8,53); // nrf24(CE ,CSN )

ReplyQuote
talamasca
(@talamasca)
Active Member
Joined: 2 years ago
Posts: 9
Topic starter  

@pugwash

hi sir. So i did this very carefully and i get the same outcome as before. although i noticed something. when i touch with my hand the MOSI cable it starts working, let my hand go and it stops. i'm sure this is a hint of what is happening but i have no ide what could it be.


ReplyQuote
talamasca
(@talamasca)
Active Member
Joined: 2 years ago
Posts: 9
Topic starter  

gotta say too, that is not a faulty connection, this doesn't happen if i wiggle the cable it only happens if i touch the plastic colored part of the cable.


ReplyQuote
mykeruiz
(@mykeruiz)
New Member
Joined: 3 weeks ago
Posts: 4
 

I also encounter this problem. the client and server return the init failed message. i am using arduino uno r3 (original) on the transmitter. and another arduino uno r3 (clone) on the receiver. I followed the instructions of Bill on his video. When I test the program it returned "init failed" on server side and "init failed, Sending to nrf24_server. No reply, is nrf24_server running?" on the client side. Any help is much appreciated. Thank you!


ReplyQuote