Another NRF24L01 problem. Transmitter doesn't update

Hi, I'm a mechanical engineer who is noob in electronics.
I decided to improve my electronic knowledge and started with arduino, leds, lcds, potentiometers so on. My next challenge is building an RC device, so I bought some NRF24L01 modules.

I have been trying loads of stuff last 3 weeks without any success. First I tried with antenna, after hundred of trials I decided my arduino is broken bought new one still no success changed stuff again no success and so on....

I am trying desperately with robin2's tutorials since it is known working..

I bought NRF modules without external antenna, tried again. Still no success....
And today I cut my jumper wires to make wires shorter as adviced in many topics. Tadaa, I am able to create communication between tx and rx. The real reason I keep being unsuccessful looks like the noise on the cables. Finally it works. BUT... The rx sometimes updates message number and sometimes doesn't.

I am using uno as rx and pro mini as tx, both clones.
I use NRF24L01 modules with adapters.
I tried MISO and MOSI twisted and not twisted as adviced on some video on youtube. Nothing changes..

tx: arduino pro mini, powered with 2 18650 batteries. when I measure voltage it is 8V. Arduino powered via raw pin, nrf24l01 is connected to 8V, when I measure voltage on nrf24l01 it is exactly 3.3V.
added pin 10 as output as adviced in various places.

my setup;

tx code:

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


#define CE_PIN   8
#define CSN_PIN 9

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);
    pinMode(10, OUTPUT);
}

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

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: arduino uno connected to computer via usb. nrf powered via arduino 5V pin, also tried to power via batteries, it got even worse, I don't know why because I use adapter it shouldn't change I guess.

rx code:

// SimpleRx - the slave or the receiver

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

#define CE_PIN   8
#define CSN_PIN 9

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();
    pinMode(10, OUTPUT);
}

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

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

I am only able to get output from rx serial monitor, because when I connect tx to usb I can't power rx. (told you I am noob)

Serial monitor output;
13:02:25.664 -> Data received Message 0
13:02:26.662 -> Data received Message 0
13:02:27.690 -> Data received Message 1
13:02:28.689 -> Data received Message 1
13:02:30.734 -> Data received Message 1
13:02:31.744 -> Data received Message 1
13:02:32.747 -> Data received Message 1
13:02:33.760 -> Data received Message 2
13:02:34.757 -> Data received Message 3
13:02:35.791 -> Data received Message 3
...
...
...

Your advices are most appreciated. Please forgive me if I posted anything wrong against the rules, I tried to be open and according to the rules.

The answers of the rx side get lost quite often,
so you could raise the number of retries.

The timeout set in the same statement is quite tight also,
maybe raising that a little could help also (when using 250KB).
I don't remember the exact limitations from the datasheet.
But that should disable all Acks, so it is probably ok (without any Ack-Payload).

:heart: Mech Engineers :heart:

Now, this EE is going to agree with you regarding electromagnetic noise: it is everywhere.

When prototyping RF stuff, even the Arduino board creates nasty RF hash ... put an old 6-transistor radio tuned to the AM band near a running microcontroller!

Another baddie: flourcesent lighting
Another: neighbor with arc-welding equipment

My suggestion is to shield your project in an aluminum project box taking care to observe good RF practices. Here is a good starting point:
ARRL best practices shielding microcontrollers at DuckDuckGo

A wonderful source for code, tips, and brain exercise:
LowPowerLab | Low Power IoT Systems

I came to home, wanted to try you guys advices, ran the programme without doing anything, wow! it works as expected!
So yes, I think thats because electromagnetic noise is less during night!

Thanks for suggestion, now it works but will do your advice not to have issue next time.

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