NRF24L01 not sending sensor data?

I’m using a NRF24L01 to transmit sensor data from one Arduino Nano to another. The sensor the transmitting nano is connected to is an ADXL377 G force sensor. The transmitting nano looks at A0 (G force in the X direction) and should send the data to the receiving nano, where the value is then printed.

I can read the ADXL377 data from the transmitting nano fine. I can send an integer from one nano to the other fine. When I need to combine the two I get no results. As soon as I ask the nano to read the A0 pin and transmit this value I run into problems and get no output from the receiver. Any ideas why that is? Thanks!

Transmitting Nano Code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8 );
const byte address[6] = “00001”;
int x;
void setup() {
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setDataRate(RF24_2MBPS);
radio.setChannel(125);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
x = analogRead(A0);
Serial.println(x);
radio.write(&x, sizeof(x));
delay(5);
}

Reciving Nano code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8 );
const byte address[6] = “00001”;
int x;
void setup() {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_2MBPS);
radio.setChannel(125);
radio.startListening();
}
void loop() {
if (radio.available()) {
radio.read(&x, sizeof(x));
Serial.println(x);
}
}

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

Also, it is not a good idea to use single character variable names (other than in FOR loops) as it makes it almost impossible for a text editor to highlight all the occurrences of a variable.

...R

mophead182:
I’m using a NRF24L01 to transmit sensor data from one Arduino Nano to another. The sensor the transmitting nano is connected to is an ADXL377 G force sensor. The transmitting nano looks at A0 (G force in the X direction) and should send the data to the receiving nano, where the value is then printed.

I can read the ADXL377 data from the transmitting nano fine. I can send an integer from one nano to the other fine. When I need to combine the two I get no results. As soon as I ask the nano to read the A0 pin and transmit this value I run into problems and get no output from the receiver. Any ideas why that is? Thanks!

Transmitting Nano Code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8 );
const byte address[6] = “00001”;
int x;
void setup() {
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setDataRate(RF24_2MBPS);
radio.setChannel(125);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
x = analogRead(A0);
Serial.println(x);
radio.write(&x, sizeof(x));
delay(5);
}

Reciving Nano code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8 );
const byte address[6] = “00001”;
int x;
void setup() {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_2MBPS);
radio.setChannel(125);
radio.startListening();
}
void loop() {
if (radio.available()) {
radio.read(&x, sizeof(x));
Serial.println(x);
}
}

I wrote a detailed blog post about all the reasons nRF24 modules don’t work: nRF24 blog post

bitbank: I wrote a detailed blog post about all the reasons nRF24 modules don't work: nRF24 blog post

You forgot about one of the main problems, bad (insufficient) power supply.

You can hardly power the normal units from the mini's 3.3V, a capacitor of 2-10 microfarad helps, for the PA LNA modules you need a separate 3.3V supply to run them reliably.