Nano and Nrf24L01 problem

Hello,
I have a problem with nano + nrf24L01 and a second set of the same.

One is the sender and the other receiver.
Code transmitter:

    /*
    * Arduino Wireless Communication Tutorial
    *     Example 1 - Transmitter Code
    *                
    * by Dejan Nedelkovski, www.HowToMechatronics.com
    * 
    * Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
    */
    #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.openWritingPipe(address);
      radio.setPALevel(RF24_PA_MIN);
      radio.stopListening();
    }
    void loop() {
      const char text[] = "Hello World";
      radio.write(&text, sizeof(text));
      delay(1000);
    }

Receiver:

    /*
    * Arduino Wireless Communication Tutorial
    *       Example 1 - Receiver Code
    *                
    * by Dejan Nedelkovski, www.HowToMechatronics.com
    * 
    * Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
    */
    #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);
      }
    }

In the serial monitor of the receiver I should get: Hello World
This is not happening.

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

I don't have a nano myself but from reading other Threads I suspect they can't provide enough 3.3v current to power an nRF24. if you think that is the problem you can easily test by powering the nRF24 from a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.

...R

Thank you. I will try this.

I have taken the power from an battery, 3V.
I have tested the first example: Simple one way transmission.

My result:

Transmitter:

SimpleTx Starting
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed

Receiver:

Data received
Data received
Data received

Please post a circuit diagram of both the Tx and Rx A hand photo of a hand drawing will be good enough

Photo 1

Photo 4

Please display your image(s) in your post so we can see it(them) without downloading it(them). See this Simple Image Guide

Also post the code that YOU uploaded to your two Arduinos.

Have you tried the connection test program in my Tutorial to make sure the Arduinos can talk to the nRF24 they are attached to?

...R

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

[u]Please draw a circuit diagram[/u], pictures show very little, or wires are obscuring others?

Do you have the gnd of the supply you are using for the NRFs connected to the gnd of the Nano?

Thanks.. Tom... :)

TX:

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

Schematic:

Hi,
Check your

#define CE_PIN   7
#define CSN_PIN 8

With your fritzy picture and the top view pinout of the NRF24L01;
NRFPinouts.jpg
This why we like circuit diagrams, not fritzy pictures, fritzy pics do not have pin labels on ALL components.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Reverse engineer your circuits when you DRAW your schematics.
Don’t just copy the fritzy, I believe you have CE and CSN transposed.

The fritzy shows pin 7 connected to the pin next to Vcc in the NRF, this pin is the CSN, yet the code shows it as CE.

Tom… :slight_smile:

@ TomGeorge,

You where right. I changed the CE and the CSN in the code and it works.

Thanks,

@Robin2:

I have tested Simple nRF24L01+ Tutorial. Everything works well(3 examples).

Thanks