Hey there!
So I wired up my nRF24L01s just as shown in Bill's video, triple-checked them, and even removed the breadboard or any additional connectors to make sure I had as good a connection as possible.
The sketches run, and after leaving it for an hour and counting the successful communications, it came out to about 1.6 successful communications per minute... not exactly what I was hoping for!
I tried switching from the example channel 1 to channels 0 and 2, and I didn't notice a significant improvement. I even tried turning off my WiFi to see if there was any interference there.
There's nothing between the receivers (in fact I wondered if they could be too close, but that would seem odd).
My end goal is to transmit a live feed from the Arducam I have now (or the MU Vision Sensor I have arriving soon) to another Arduino as a proof of concept for the small robot I'm working on.
So what are my best troubleshooting options? I bet I could keep trying different channels, but I'm not sure how many there are. Has anyone else gotten it to technically "work" but at an unbelievably slow rate?
Thanks for any and all help!
Fortune Favors the Bold
I am not familiar with your modules or 'Radio head', but am familiar with RF.
Changing channels will do nothing unless you are receiving interference from another transmitter close by. (and may be another product on the band causing the interference, as hobby low power bands are not a priority to the FCC here in the states, or to other regulating agencies in other countries.) As you have already changed channels, I doubt that is your problem area.
Are you using antennas that couple to the board, or on board circuit trace antennas? Sometimes vendors will ship antennas that are not tuned for the frequency they are supposed to be handling. A properly tuned antenna is definitely better than circuit trace antenna. Emphasis on properly tuned.
If none of this is making sense, look up Andreas Spiess on you tube. In several videos he discusses antennas, VSWR, and VNA. All which may be useful.
Have you downloaded the datasheet for the nRF24L01? There are 4 different bit settings to control power output with a difference of 0 to -18dBm.
As you are getting several transmissions completed, I imagine your code is correct.
Hopefully some others will have some more hands on advise as well.
Good luck.
@centari I am using on-board ciruit trace antennas, I hope to upgrade to the version of the nRF24L01 that has an antenna, but having watched Bill's video on the standard version, I believe I am supposed to be getting results that match his unless I have bad transceivers or adapters.
Because I like ordering multiples of things, I've got an extra set of transceivers and adapters, and I haven't tried every configuration thereof, but it doesn't seem like any of the chips are necessarily faulty.
The Client seems to be working better than the Server, since as dictated by the client code it consistently and correctly hits the server and asks for a reply, only rarely does it actually get one. So I think my problem has something to do with the server components since, as you said, my code is likely not at fault, especially since it's the same default example Bill got working.
At the moment I can't find my fourth transceiver, but I did just exchange the server one and its adapter with the spares I could find, and there's been no discernable improvement.
Edit: in fact, after swapping out some of the parts, I don't seem to be getting any responses at all, leading me to believe I may have a faulty part. It's very difficult to troubleshoot since I can't be sure if one is working at any given time, or rather I don't know how to test that.
Fortune Favors the Bold
If you're using the Arduino IDE, my next step would be to add Serial.print() statements at key point to check program flow. Print out variables that mean something so you can check against what should be there.
It's a time consuming and annoying way to troubleshoot, but without a debugger, the only option I know of.
Hopefully, someone will chime in with better, or more targeted advise.
@centari Thanks! I just did that, and I'll show the example code so it can be seen where I added the Serial statements:
#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);
Serial.println("Checking for message");
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");
}
} else {
Serial.println("nRF24 not available");
}
}
So right now all I'm getting is "nRF24 not available" while not getting any of the errors around the initialization and other setups. I'm not familiar enough with RF to understand what exactly is failing there. I also swapped the transceiver out a couple times (found the fouth one) with no change.
Fortune Favors the Bold
I have had good luck with the tmrh20 RF24 library found here. I think it is
newer than the radio head library.
@noweare Thanks! I'll check that out in the morning! It's been a long day and I'm already winding down haha... and by wanding down I mean watching DroneBot Workshop in bed.
Fortune Favors the Bold
@leonardo1123 The "GettingStarted.ino" is the most basic. In the code find the lines below. Just have one board set for radioNumber =0 and the other uses radioNumber=1
Then load that sketchs onto your two arduino. After it works you can play around with the code. Just save the sketch under a different name or it will over write the example sketch.
/****************** User Config ***************************/
/*** Set this radio as radio number 0 or 1 ***/
bool radioNumber = 0;
@leonardo1123, Didn't mean to leave you hanging, been under the weather. Clearly @noweare knows a lot more about the subject than I do. Thanks for stepping in.
@centari No worries, I hope you feel better!
I always hate when switching libraries works, because I can't help but feel I could have made the last one work. I've got a 5-day weekend trip I'm taking with my mom, and I'll be doing a lot of nRF coding, mainly trying to take a picture on one Arduino and display it on the other. I'll take my first crack at it, but it will almost assuredly become a forum post, haha.
Fortune Favors the Bold
@noweare I'm officially controlling my car with my joystick remotely! Do you have any advice on how to send data back to the joystick Arduino? The Getting Started example kinda showed how to switch roles, but not dynamically, nor while performing other tasks.
Any tips would be much appreicated!
Fortune Favors the Bold
Check out the other examples. Any two way communication example would work.