So I'm trying to do a simple transmission between two nrf24l01 modules that will send and receive messages.
I've checked the hardware and it's solid (Did the continuity tests for each pin)
I'm thinking I have a programming problem but I'm not sure because I've followed various resources exactly and there is still no transmission.
I've left this running for hours and I still have no successful transmission (I did this by having a LED light up if it runs successfully at least once).
Receiver Code
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
void setup()
{
//NRF set up
Serial.begin(9600);
radio.begin();
//radio.setChannel(115);
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_250KBPS);
radio.startListening();
Serial.println("Initialize Listening");
//LED set up
pinMode(4, OUTPUT);
}
void loop()
{
//Keep on pinging or test transmitter for alternative options
if (radio.available())
{
//May need to turn off later
Serial.println("Received signal");
char text[32] = {0};
radio.read(&text, sizeof(text));
//String receivedData = String(text);
Serial.println(text);
//Flash LED for successful transmission
digitalWrite(4, HIGH);
}
else
{
Serial.println("Searching for Signal");
delay(1000);
digitalWrite(4, LOW);
}
}
If you read and, closely, follow Robin2's simple rf24 tutorial you should be able to get them working. That tutorial sure helped me. The code in the examples has been proven to work many many times. If it does not work for you, there is likely a hardware problem.
Run the CheckConnection.ino (look in reply #30 in the tutorial) to verify the physical wiring between the radio module and its processor (Arduino).
It is very important that you get the 3.3V supply to the radio modules to supply enough current. This is especially true for the high power (external antenna) modules. Some have success with a 10uF to 100uF cap across the rf24 module power pins. I use homemade adapters like these. They are powered by 5V and have a 3.3V regulator on the board. Robin2 also has suggested trying with a 2 AA cell battery pack.
I have a pair of Unos with RF25 modules that I use for testing. I uploaded your code and the code works fine.
Here is a sample of the output from the receiver:
Initialize Listening
Searching for Signal
Received signal
test
Searching for Signal
Received signal
test
Searching for Signal
Received signal
test
Searching for Signal
Received signal
test
This leads me to believe that you have a wiring or power problem. Like I said in the prior post, run the CheckConnection program to verify the connection between each radio module and its processor.
How are the rf24 modules powered? Are they the ones with the external antenna?
Please post wiring diagrams and, as requested by @kolaha, photos of the wiring.
I would not have the else part in the receive code for those radios. It does no good and the delay does not belong in that code.
The above link are the images. The color of the wires is not great (Gotta do with limited resources here), but the colors are listed below:
Transmitter (Black Arduino Uno R3) Wire Colors
Yellow - GND
Black - VCC, 3.3 V (I know, it's very cursed but I'm too lazy to change it)
Red - MISO, 12
Orange - MOSI, 11
Green - SCK, 13
Purple - CSN, 10
CE - Blue, 9
I also put a 100 µF capacitor between the VCC and GND pins (Not shown)
Receiver (Green Arduino Uno R3) Wire Colors
Black - GND
Red - VCC, 3.3 V
Black - MISO, 12
Brown - MOSI, 11
Blue - SCK, 13
White - CSN, 10
Purple - CE, 9
Thank you, happy to know it's not a coding problem. Hardware problem is more difficult, but I'm trying various techniques. Also, these are external antenna modules, I did unplug those and received some success, but the data the receiver is receiving appears to be corrupted and not clean. In addition, I think it is inaccurate because it only works when I press the receiver wires. Output is the following:
Received signal
}}__⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
Received signal
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
For the extra power, I plan on testing that tomorrow but I think that should be the most likely solution to the problem.
The above link are the images. The color of the wires is not great (Gotta do with limited resources here), but the colors are listed below:
Transmitter (Black Arduino Uno R3) Wire Colors
Yellow - GND
Black - VCC, 3.3 V (I know, it's very cursed but I'm too lazy to change it)
Red - MISO, 12
Orange - MOSI, 11
Green - SCK, 13
Purple - CSN, 10
CE - Blue, 9
I also put a 100 µF capacitor between the VCC and GND pins (Not shown)
Receiver (Green Arduino Uno R3) Wire Colors
Black - GND
Red - VCC, 3.3 V
Black - MISO, 12
Brown - MOSI, 11
Blue - SCK, 13
White - CSN, 10
Purple - CE, 9
Do not remove the antenna from the modules. I have read that it can harm the radios.
If using the high powered radios make sure to separate them by a few meters. They may not work too close together. Try the lower power settings for testing.
radio.setPALevel(RF24_PA_MIN);
The 10uF cap should be placed as close to the radio module as possible. I solder them right to the power header on the module.