I am trying to send data from one arduino uno to another using the NRFL01+PA+LNA chip. I basically copy and pasted the code from this guide. I am using this RF24 library.
I made some modifications to the code from the guide (mostly adding things that allowed me to trouble shoot)
Transmitter code
#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001"; // the address the the module
const int buttonPin = 3; //Button stuff
int buttonState = 0;
void setup() {
radio.begin(); // Radio stuff
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MAX);
radio.stopListening();
Serial.begin(9600);
pinMode (buttonPin, INPUT); // button setup
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) { //try to send if the button is pressed
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
Serial.println ("done"); // testing in case of button problems
}
}
Receiver code
#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001"; // the address the the module
void setup() {
Serial.begin(9600);
radio.begin(); //Radio setup
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MAX);
radio.startListening();
}
void loop() {
if (radio.available()) { // if nrf has any incoming data
Serial.println ("available"); // a test to see if the radio is available
char text[32] = "";
radio.read(&text, sizeof(text));
Serial.println(text);
delay(5);
}
}
So far I have not been able to get the radio to be available.
Is there a code thing that is not allowing the radios to connect? Could it be my environment (ex too much wifi signals)? Could it be like how I have the antennas orientated? Is there another thing that I am not thinking of?
it is a good idea after radio.begin() to check if it is connected, e.g.
radio.begin();
if (radio.isChipConnected())
Serial.println("Receiver NF24 connected to SPI");
else {
Serial.println("NF24 is NOT connected to SPI");
while (1)
;
}
I added that code to my code and got a power supply that was giving the chip .23 amps. When I tested it the code showed that the chip was not connected to the arduino.
Not joining the grounds of the Arduino and the NRF module creates a floating reference between the devices, leading to voltage mismatch.
Without a common ground, the logic signals may not be interpreted correctly, causing communication failure.
This can also result in voltage spikes or current flowing through unintended paths, risking damage to sensitive components.
➜ To fix this, connect the ground of the Arduino to the ground of the NRF module to ensure both devices share a common reference, preventing signal issues and potential damage.