nRF24L01 transmitter problem

Hey guys,

I have 2 arduino - mega 2560 and uno - and tried to communicate wireless between them with nRF24L01 bluetooth module.

Reciving is going good ( rx led blinking and something show up at serial monitor ) but tx led not blinking.

Transmitter code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
}

Reciver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

SCK,MISO,MOSI is at good pin i’m sure about this.

On reciver serial monitor i got something unexpected characters.

thanks a lot!

The SPI pins on a Mega are in a completely different location than on an Uno. RTFM

…R
Simple nRF24L01+ Tutorial

Thanks Robin, nice tutorial.

I have tried to solve by your tutorial, tx led started to blinking but radio.available() was return false. At the reciver i got something unknown characters. Also tried to put 100uF between VCC and GND but nothing. Any experience?

tmsbrndz:
I have tried to solve by your tutorial, tx led started to blinking but radio.available() was return false. At the reciver i got something unknown characters. Also tried to put 100uF between VCC and GND but nothing. Any experience?

You need to post the programs that YOU uploaded to YOUR Arduinos. Be sure to make it clear which program is on the Mega.

...R

So here i come…

Tried with MEGA 2560 with following code ( built by ur tutorial )

#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); 

char data[15] = "TestMessage";

void setup() {
    Serial.begin(9600);
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); 
    radio.openWritingPipe(slaveAddress);
}

void loop() {
  bool sent = radio.write( &data, sizeof(data) );

  if(radio.available()){
    Serial.println("Connection is available!");
    Serial.print("Package sent : ");
    Serial.println(data);
    }
  else {
    Serial.println("Radio is not available :(");
    }
}

Got back “Radio is not available” message and sent return 0. With MEGA 2560 RX led blinking but with UNO TX led blinking.

With your code also failing…

thanks

tmsbrndz:
So here i come..

Tried with MEGA 2560 with following code ( built by ur tutorial )

I forgot to ask you to say what pins on the Mega you have connected the nRF24 to?

Also post the program that YOU have uploaded to your UNO - and say what I/O pins are used on it

Without being able to see both programs it is like trying to diagnose problems with one-handed clapping.

...R

I removed MEGA now.

Built with 2 UNO.

Code is 100% same with your tutorial’s code.

TX

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



// SimpleTx - the master or the transmitter



#define CE_PIN   9
#define CSN_PIN 10

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.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;
}

RX

// SimpleRx - the slave or the receiver

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

#define CE_PIN   9
#define CSN_PIN 10

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.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();
}

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

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

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

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

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

TX led lighting continuously, RX led nothing just blink once at start, also swapped the modules to another but still nothing. CNS and CE at good pin,100%

Im really disappointed about this module.

tmsbrndz:
TX led lighting continuously, RX led nothing just blink once at start,

Never mind the blinking lights. What appears on the Serial Monitors for the two programs?

Your code is NOT identical to my code. Fix that first.

Are you certain you have the correct RF24 library - the same as I use?

Have you tried disconnecting the power from the Uno after uploading the program to make sure that the nRF24 resets. The normal Arduino reset does not reset the nRF24.

Have you 10µF capacitors across Vcc and GND for the nRF24s?

Have you a spare nRF24 that you can use just in case one of the first pair is faulty?

Wireless problems can be very frustrating.

...R

Changed code to original. STILL fail.

On TX UNO RX led blinking, on RX UNO nothing. I use good library im sure. Tried to unplug the usb after upload.

On serial monitor :

RX

Data Sent Message 0 Tx failed

TX

SimpleRx Starting

Thats all. I dont have 10uF capacitor just 100uF, im gonna give up this module and looking for another wireless communication.

I can't think of anything else to suggest. 100µF should be fine. Maybe you have a faulty nRF24.

I have had one faulty device among about 20 altogether. Apart from that I have found them very easy to work with.

How are you connecting the nRF24 to the Arduino. In another recent Thread someone said he had trouble with poor connections on dupont connectors - but I have not had that problem with my dupont connectors.

I know my code works because other Forum members have used it.

...R

I need to solder capacitors on modules or i can do this with breadbord?

Mine radio is not alive, i think its failing at start not at reciving or transmitting data...

tmsbrndz:
I need to solder capacitors on modules or i can do this with breadbord?

They don't need to be soldered but there must be a reliable electrical connection and they should be as close as possible to the nRF24 pins. I presume you know that electrolytic capacitors need to be connected the right way round.

Buy another pair of nRF24s for testing. They are not very expensive.

...R

Hi Robin!

So i think here we have 100% issue with wires, i moved them little while arduino running and TX/RX led not just lighting they started to blink and got this output. (RX is not blinking just light)

TX works fine?!

TX

RX

I think for my best i need to solder normal wires on module to work with them.

thanks

up!

tmsbrndz:
up!

Why are you bumping this Thread? I have not noticed any outstanding question.

...R