nRF24 Problem !!!!

hello

I 've been trying to make 2 nRF24's to communicate and I found simple RX/TX code

// SimpleTx - the master or the transmitter

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


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

and

// 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(115200);

    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);
        delay(300);
        newData = false;
    }
}

and look what I've got on the serial monitor

Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮
Data received ⸮⸮a⸮⸮⸮⸮⸮
Data received ⸮a⸮.⸮⸮a⸮⸮
Data received
Data received x⸮⸮⸮⸮@⸮
Data received ⸮⸮⸮⸮⸮⸮⸮⸮
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮
Data received a⸮⸮⸮⸮⸮⸮
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮

Why is there a delay() in this - there is none in my Tutorial, and for a very good reason.

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

...R

Well I am still receiving the same stuff but in the much much faster way

ata received
Data received
Data received
Data received }⸮⸮⸮⸮⸮⸮⸮⸮
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
Data received
Data received
Data received
Data received
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮
Data received
⸮⸮⸮⸮⸮⸮⸮⸮⸮
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮
Data received ⸮⸮⸮?⸮⸮⸮⸮⸮⸮
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮

The communication between the NRF24L01 and the Arduino is failing (in the receiving node).
(bad wiring, bad wires, bad module, ...)

There is a connection test program in @Robin2's sketches.

xlameee:
Well I am still receiving the same stuff but in the much much faster way

That is the important diagnostic information that your delay() had disguised. This incorrect behaviour is mentioned at the bottom of the first Post in my Simple nRF24L01+ Tutorial

The most likely problem is as suggested by @Whandall in Reply #3.

...R

Hello

Thank you I understand now

the problem is from the wiring I cannot fix it, but I created a shield for mega so I can have a solid connection with nrf24 module and sent it for a production

I couldn't find any other way to fix the problem >:( :confused:

seems this module needs solid connection to Arduino in order to work properly and I don't want to solder it directly to arduino

even with this I shown you on the attached image I still have to hold the cables going into arduino and move them around in order to send anything and I am currently programming 4 nodes

you get the picture what I have to do to get one packet goes trough an other node in order to reach it's final destination :slight_smile:

photo_2020-01-22_03-23-43.jpg

seems this module needs solid connection to Arduino in order to work properly

That is surely a requirement for anything connected to the Arduino. How could it be otherwise ?

photo_2020-01-22_03-23-43.jpg

For this kind of high power NRF you need a solid separate 3.3V supply.

These also don't work very well on short distances.

Have a look at this Ultimate nRF24L01 range comparison.

photo_2020-01-22_03-23-43.jpg

I have few of those

https://www.amazon.co.uk/Breadboard-Supply-Module-Arduino-Solderless/dp/B06XQ1DSCP/ref=sr_1_3?keywords=breadboard+power+supply&qid=1579831789&sr=8-3

1 side I am powering up the arduino with 5v and on the other side I power NRF with 3.3v and 10uf capacitor between VCC and GND

As you can see the power is not the issue here the connection is the problem I thing.
I am testing them with an examples from the library RF24 , RF24Network and they work but I have to hold the connection wires and moving them around. I've created a shield and I am hoping to solve that problem

Thank you

xlameee:
As you can see the power is not the issue here the connection is the problem I thing.

If you cannot send and receive messages it is difficult to rule anything out.

The simplest way to ensure you have sufficient nRF24 power (at least for testing) is to use a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND. And power the Arduino separately.

If you suspect wrong or loose connections between your Arduino and the nRF24 then the connection-test program in my nRF24 tutorial should confirm the situation. It would be pointless to expect anything to work if the connection-test program does not work. Note that the connection-test DOES NOT check the wireless.

It would also be a good idea to start testing with a pair of the low-power nRF24s (with the PCB antenna) - they will work fine even when both of them are on the same workbench. And the software interface is identical with the high-power versions.

...R

Robin2:
If you cannot send and receive messages it is difficult to rule anything out.

The simplest way to ensure you have sufficient nRF24 power (at least for testing) is to use a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND. And power the Arduino separately.

If you suspect wrong or loose connections between your Arduino and the nRF24 then the connection-test program in my nRF24 tutorial should confirm the situation. It would be pointless to expect anything to work if the connection-test program does not work. Note that the connection-test DOES NOT check the wireless.

It would also be a good idea to start testing with a pair of the low-power nRF24s (with the PCB antenna) - they will work fine even when both of them are on the same workbench. And the software interface is identical with the high-power versions.

...R

Hello

It's the MISO wire When I get my finger close to that wire the rf24 starts transmitting

Data Sent Message 9 ent Message 9 Tx failed
SimpleTx Starting
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Acknowledge received
Data Sent Message 1 Tx failed
Data Sent Message 1 Acknowledge received
Data Sent Message 2 Tx failed
Data Sent Message 2 Acknowledge received
Data Sent Message 3 Tx failed
Data Sent Message 3 Acknowledge received
Data Sent Message 4 Tx failed

When I grab it with both fingers I've got this

SimpleTx Starting
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed
Data Sent Message 0 Acknowledge received
Data Sent Message 1 Acknowledge received
Data Sent Message 2 Acknowledge received
Data Sent Message 3 Acknowledge received
Data Sent Message 4 Acknowledge received
Data Sent Message 5 Acknowledge received
Data Sent Message 6 Acknowledge received
Data Sent Message 7 Acknowledge received
Data Sent Message 8 Acknowledge received
Data Sent Message 9 Acknowledge received
Data Sent Message 0 Acknowledge received
Data Sent Message 1 Acknowledge received

Any Idea why???

Thank you

xlameee:
Any Idea why???

Maybe a loose connection somewhere.

Have you a good GND connection?

...R