Help with NRF24L01+ Transmitting and Recieving

Hello all,

I am currently working on a project where I need to wirelessly transmit data from one Arduino to another. Currently, I am working with placeholder data; however, it is not working. I have 0 clue as to what my problem is, as I followed Robin2's tutorial and still have problems, while also being extremely new to wireless transmission.

Here are some specs:

Transmitter:

  1. Arduino Uno (powered by computer)
  2. NRF24L01+ with adapter (powered by 9V battery)

Receiver:

  1. Arduino Uno (powered by computer)
  2. NRF24L01+ with adapter (powered by 9V battery)

Here are my pinouts:

Transmitter:

CE = 7
CSN = 8
SCK = 13
MOSI = 11
MISO = 12
VCC = Breadboard positive
GND = Breadboard negative
9V power supply = Breadboard

Receiver:

CE = 7
CSN = 8
SCK = 13
MOSI = 11
MISO = 12
VCC = Breadboard positive
GND = Breadboard negative
9V power supply = Breadboard

Here is my code (copied from Robin2):

Transmitter:

// SimpleTx - the master or the transmitter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


#define CE_PIN  7
#define CSN_PIN 8

const byte slaveAddress[5] = {'R','x','A','A','A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

char dataToSend[10] = "Message 0";
char txNum = '0';


unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second


void setup() {

  Serial.begin(9600);

  Serial.println("SimpleTx Starting");

  radio.begin();
  radio.setDataRate( RF24_250KBPS );
  radio.setPALevel(RF24_PA_MIN);
  radio.setRetries(3,5); // delay, count
  radio.openWritingPipe(slaveAddress);
}

//====================

void loop() {
  currentMillis = millis();
  if (currentMillis - prevMillis >= txIntervalMillis) {
    send();
    prevMillis = millis();
  }
}

//====================

void send() {

  bool rslt;
  rslt = radio.write(&dataToSend, sizeof(dataToSend));
      // Always use sizeof() as it gives the size as the number of bytes.
      // For example if dataToSend was an int sizeof() would correctly return 2

  Serial.print("Data Sent ");
  Serial.print(dataToSend);
  if (rslt) {
    Serial.println("  Acknowledge received");
    updateMessage();
  }
  else {
    Serial.println("  Tx failed");
  }
}

//================

void updateMessage() {
  // so you can see that new data is being sent
  txNum += 1;
  if (txNum > '9') {
    txNum = '0';
  }
  dataToSend[8] = txNum;
}

Receiver:

// SimpleRx - the slave or the receiver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN  7
#define CSN_PIN 8

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;

//===========

void setup() {

  Serial.begin(9600);

  Serial.println("SimpleRx Starting");
  radio.begin();
  radio.setDataRate( RF24_250KBPS );
  radio.setPALevel(RF24_PA_MIN);
  radio.openReadingPipe(0, thisSlaveAddress);
  radio.startListening();
}

//=============

void loop() {
  getData();
  showData();
}

//==============

void getData() {
  if ( radio.available() ) {
    radio.read( &dataReceived, sizeof(dataReceived) );
    newData = true;
    Serial.println("WORKING");
  }
}

void showData() {
  if (newData == true) {
    Serial.print("Data received ");
    Serial.println(dataReceived);
    newData = false;
  }
}

My transmitter is printing "Data sent Message 0 Tx failed". If any more information is needed, just ask, and I will provide it. Thanks!

ADurian

Please make a proper schematics. "Pinouts" is not much good.

Sounds very strange, likely bad. 2 times...

Here's a link telling what forum expects from You: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Neither sketch checks the result of radio.begin();. So it's entirely possible that the nRF24L01 on one or both aren't even being detected or set up properly.

Are you following the simple rf24 tutorial written by Robin2? I followed it closely and got my radios talking well.

Have you ran the sketch in reply #30 to test the wiring connection between the rf24 module and its connected processor?

How are the rf24 modules powered? The most often encountered problem is lack of power. I use homemade versions of these adapters to drop 5V to 3.3V with great success.

Thanks for you reply! I can not find a proper software allowing me to create a schematic. Would a simple photo be fine?

I am currently in school, so I can likely double-check this after my class. I followed Robin2's tutorial exactly; however, I will run the sketch in reply #30 in a couple of hours and send the results here. My modules, with the adapter, are being powered by a separate 9V battery, so I do not believe it is a power issue, as it should have enough current.

If the 9V batteries are of the smoke alarm variety, you have a probem with power. Those batteries cannot supply sufficient current for the radios. A 2 or 3 AA cell pack is a much better supply.

Oh yes, they are of that kind. I will ask my teacher to purchase on of those cell packs and get back to you when I test them. Thank you so much for your help!

Just try pen and paper, then taking a foto and post it. Remember to add pin logic designations, power sup data.....

Would you say that the 5V pin on Arduino can provide enough current for the modules?

That depends upon the source of the 5V. 5V from USB likely would supply enough current. You must reguate that 5V to the 3.3V that the module needs.

If the 5V is sourced externally (batteries through Vin or the power plug) and the 5V comes from the on board regulator, it depends on what else is powered by the regulator. Any power draw over 1 Watt from the on board regulator can overload the regulator and cause shutdown.

I do not believe that power is my issue, as I have recently tried using the 5V pin on the Arduino to power the module, and it is still not working. I have this 5V pin powered by a USB as well, and the 5V is being regulated to 3.3V by the adapters I am using.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.