nRF between UNO and MEGA2560

Hi all
I need some help with this kind of communication between the above arduinos. The nRF are connected on a 5v convert board and are powered by separately. During my trials they are in a distance of a meter between them. Both have a 10uF cap on their board power in points.
The problem is that the receiver seems not receiving. I think is better to include the results than tried to explain. An image is always better than words i think.
I followed Robin2 instructions with simple TX-RX codes. Also i tried the TEST code from his #31 for both of the nRFs. I include the results from the tests and the results from the serial monitors.
I read a lot of threads about issues with this communication and tried a few things like different cap capacitors, different devices, some delays but no success untill now. If someone comes up with an idea will be great. Thanks.

CODE FOR NANO

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

CODE FOR MEGA

// 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();
    delay(200);
    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;
    }
}

The following is the code of ROBIN2 to check if there is connection between nRF module and the Arduino.

// 18 Mar 2018 - simple program to verify connection between Arduino
//      and nRF24L01+
//  This program does NOT attempt any communication with another nRF24

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

#include <printf.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);
    printf_begin();

    Serial.println("CheckConnection Starting");
    Serial.println();
    Serial.println("FIRST WITH THE DEFAULT ADDRESSES after power on");
    Serial.println("  Note that RF24 does NOT reset when Arduino resets - only when power is removed");
    Serial.println("  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not");
    Serial.println("     communicating with the nRF24");
    Serial.println();
    radio.begin();
    radio.printDetails();
    Serial.println();
    Serial.println();
    Serial.println("AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1");
    Serial.println(" and 250KBPS data rate");
    Serial.println();
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.setDataRate( RF24_250KBPS );
    radio.printDetails();
    Serial.println();
    Serial.println();
}


void loop() {

}

Upload a photo of my setup:


I don't have the capability at the moment to upload a schematic so i will describe the connections which are simple ones.
For Arduino MEGA 2560:
GND -----> GND
CE ------> PIN 7
CSN ------> PIN 8
MISO ----> PIN 50
MOSI ----> PIN 51
SCK ------> PIN 52
Power supply for the nRF module is separate from the arduino. The GND is connected from nRF module to the arduino.

For NANO;
GND -----> GND
CE -----> PIN 7
CSN -----> PIN 8
MISO ----> PIN D12
MOSI ----> PIN D11
SCK ------> PIN D13

THE RESULTS FROM THE COMMUNICATION BETWEEN THE 2 ARDUINO'S ARE WORD DOCUMENTS(COPIED FROM TERATERM) IN THE FOLLOWING LINK:arduino nRF - Google Drive
IS TOO MUCH TO LOAD HERE.

THANK YOU.

Post the code and an annotated schematic of each. Show all connections, power, ground, power sources etc.

Hi
I upload what you ve been asking. Thanks.

I do not see the link.

I update the original post sorry

What is the name of the link, all I see are .txt files.

Hi
Sorry i was at work the link is:
https://drive.google.com/drive/folders/1hBSJ78-EyhG4qXTcSCZUorbmbUOUHHzK?usp=sharing

The CheckConnection output you posted indicates that you have a wiring problem on both the Mega and the Nano.

Essentially, the Microcontrollers are not successfully 'talking' to the radios.

Check you wiring and connections by scrolling down here: https://nrf24.github.io/RF24/

Then see the following doc: https://nrf24.github.io/RF24/md_COMMON__ISSUES.html for an example of what your CheckConnection output should look like.

I would also suggest using shorter connecting wires for the radios.

Your problem is not unexpected, and your wiring may be the root cause. Since hardware is involved, it’s crucial to provide an accurate, annotated schematic of your circuit as it is currently wired. Please note that Fritzing diagrams are not considered proper schematics; they are wiring diagrams and are often not helpful for troubleshooting.

What to Include:

  1. Annotated Schematic: Show all connections, including power, ground, and power sources. This helps us understand how your circuit is set up and identify any potential issues.
  2. Technical Information Links: Provide links to technical documentation for each hardware device used in your setup. Avoid links to sales sites like Amazon, as they usually lack the necessary technical details. We need complete specifications to help you effectively.
  3. Additional Information Needed: If the above details are incorrect, more information is required. Tell us what hardware and software you are using, the format of any data (like map data), and how your system determines its position. For example, if your project involves a robot, describe how it navigates and what computers are involved.

Why This Matters:

We have no way of knowing the specifics of your setup unless you provide that information. Clear and detailed descriptions enable us to offer the most accurate help possible. Without these details, it’s difficult to diagnose and solve the issues you're experiencing.

-->

How to Get the Right Help Faster:

You can spend weeks spinning your wheels, or you might get lucky and solve your problem quickly. To avoid unnecessary delays, it’s crucial to provide an annotated schematic of your circuit as you have it wired, showing all connections, including power, ground, and supplies.

Why Detailed Information Matters:

  • Annotated Schematics: These are essential because they show exactly how your circuit is set up. Without them, it's difficult for anyone to understand what you’ve done, which makes troubleshooting nearly impossible. Fritzing diagrams or unclear pictures are not enough.
  • Technical Information: Many modules look similar and may even have the same name, but they can function differently. This is why we always ask for links to detailed technical information—not just sales pages like those on Amazon, which often lack the specifics we need.
  • Show All Connections: It’s important to include every connection, especially power and ground, in your schematic. Missing these details makes it hard to determine if a setup issue might be causing your problem.

My Process:

When I see a question, I spend a moment assessing it. If it’s missing critical information, I might ask for it. However, if it's repeatedly lacking important details, I may assume the questioner is not serious and move on to another query.

What You Need to Consider:

We don’t know your skill level or what resources you have available. If you’re missing key technical details or seem unprepared, it may indicate that you need to spend more time learning the basics before starting your project.

Providing the right information upfront will help you get the best possible assistance and avoid the frustration of running into dead ends. Let us help you by sharing what you have clearly and completely!

Hello
Sorry for late answer. I enclose a link with the test results of 5 different nRF's. I found i think the issue but i don't have the experience to difeine i am right. If you can take a look please and let me know. The link is: Arduino NANO - Google Drive

Regards

Put your results here, not on some way off site others have to go searching for.

I found i think the issue but i don't have the experience to difine if i am right. I have paste 4 test results from 4 different modules. If someone can take a look please and let me know if these responses looking ok.

1.THE FIRST

CheckConnection Starting
FIRST WITH THE DEFAULT ADDRESSES after power on
Note that RF24 does NOT reset when Arduino resets - only when power is removed
If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
communicating with the nRF24

SPI Speedz      = 10 Mhz
STATUS          = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1    = 0x00001c0010 0x0000000000
RX_ADDR_P2-5    = 0x70 0x70 0x00 0xc4
TX_ADDR         = 0x0000000000
RX_PW_P0-6      = 0xc0 0x00 0x00 0x00 0x00 0x00
EN_AA           = 0x3f
EN_RXADDR       = 0x38
RF_CH           = 0x00
RF_SETUP        = 0x22
CONFIG          = 0x00
DYNPD/FEATURE   = 0x44 0x70
Data Rate       = 1 MBPS
Model           = nRF24L01
CRC Length      = Disabled
PA Power        = PA_HIGH
ARC             = 0

AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1
and 250KBPS data rate

SPI Speedz      = 10 Mhz
STATUS          = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1    = 0x0000000000 0x00000000e0
RX_ADDR_P2-5    = 0x44 0x00 0x38 0x00
TX_ADDR         = 0x0000000080
RX_PW_P0-6      = 0x11 0x1c 0x8c 0x00 0x44 0x1c
EN_AA           = 0x80
EN_RXADDR       = 0x22
RF_CH           = 0x00
RF_SETUP        = 0x00
CONFIG          = 0x23
DYNPD/FEATURE   = 0x00 0x00
Data Rate       = 1 MBPS
Model           = nRF24L01
CRC Length      = 8 bits
PA Power        = PA_MIN
ARC             = 0

2.SECOND TRIAL

CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
Note that RF24 does NOT reset when Arduino resets - only when power is removed
If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
communicating with the nRF24

SPI Speedz      = 10 Mhz
STATUS          = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1    = 0x00000000e0 0x00000000e0
RX_ADDR_P2-5    = 0x38 0x38 0x0c 0xff
TX_ADDR         = 0xffffffffef
RX_PW_P0-6      = 0xc7 0x1c 0x40 0x70 0x38 0x10
EN_AA           = 0x3f
EN_RXADDR       = 0x7e
RF_CH           = 0x38
RF_SETUP        = 0x38
CONFIG          = 0x0c
DYNPD/FEATURE   = 0x70 0x38
Data Rate       = 1 MBPS
Model           = nRF24L01
CRC Length      = 16 bits
PA Power        = PA_HIGH
ARC             = 15

AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1
and 250KBPS data rate

SPI Speedz      = 10 Mhz
STATUS          = 0x06 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=3 TX_FULL=0
RX_ADDR_P0-1    = 0x00000000e0 0xc2c2c2c2c2
RX_ADDR_P2-5    = 0x70 0x38 0x1c 0xff
TX_ADDR         = 0x3f3f3f3f3f
RX_PW_P0-6      = 0xe0 0x40 0x20 0x18 0x70 0x0c
EN_AA           = 0x1c
EN_RXADDR       = 0x38
RF_CH           = 0x18
RF_SETUP        = 0x1c
CONFIG          = 0x01
DYNPD/FEATURE   = 0x70 0x70
Data Rate       = 2 MBPS
Model           = nRF24L01
CRC Length      = 16 bits
PA Power        = PA_HIGH
ARC             = 0

3.THIRD TRIAL
CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
Note that RF24 does NOT reset when Arduino resets - only when power is removed
If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
communicating with the nRF24

SPI Speedz      = 10 Mhz
STATUS          = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1    = 0x0000000000 0x0000000000
RX_ADDR_P2-5    = 0x00 0x46 0x07 0x8e
TX_ADDR         = 0x00c011000e
RX_PW_P0-6      = 0x00 0x00 0xe0 0x00 0x00 0x00
EN_AA           = 0x00
EN_RXADDR       = 0x00
RF_CH           = 0x00
RF_SETUP        = 0x22
CONFIG          = 0x08
DYNPD/FEATURE   = 0x60 0x00
Data Rate       = 1 MBPS
Model           = nRF24L01
CRC Length      = 8 bits
PA Power        = PA_MIN
ARC             = 0

AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1
and 250KBPS data rate

SPI Speedz      = 10 Mhz
STATUS          = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1    = 0x0000000000 0x000000009c
RX_ADDR_P2-5    = 0x0e 0x60 0x00 0x22
TX_ADDR         = 0x0080030007
RX_PW_P0-6      = 0xd8 0x00 0x00 0x00 0x38 0x00
EN_AA           = 0x3e
EN_RXADDR       = 0x38
RF_CH           = 0x00
RF_SETUP        = 0x47
CONFIG          = 0x08
DYNPD/FEATURE   = 0x46 0x70
Data Rate       = 1 MBPS
Model           = nRF24L01
CRC Length      = 8 bits
PA Power        = PA_MIN
ARC             = 0

4.FOURTH TRIAL
CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
Note that RF24 does NOT reset when Arduino resets - only when power is removed
If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
communicating with the nRF24

SPI Speedz      = 10 Mhz
STATUS          = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1    = 0x00000c0000 0x0000000070
RX_ADDR_P2-5    = 0x00 0x30 0xc5 0x00
TX_ADDR         = 0x00000000c0
RX_PW_P0-6      = 0x00 0x0c 0x40 0x00 0x20 0x18
EN_AA           = 0x02
EN_RXADDR       = 0x00
RF_CH           = 0x00
RF_SETUP        = 0x00
CONFIG          = 0x01
DYNPD/FEATURE   = 0x00 0x01
Data Rate       = 2 MBPS
Model           = nRF24L01+
CRC Length      = 8 bits
PA Power        = PA_MAX
ARC             = 0

AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1
and 250KBPS data rate

SPI Speedz      = 10 Mhz
STATUS          = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1    = 0x00000000e0 0x0000000000
RX_ADDR_P2-5    = 0x38 0x00 0x00 0xc2
TX_ADDR         = 0xc7c7c7c7c7
RX_PW_P0-6      = 0x00 0x00 0xc0 0x00 0xc0 0xc0
EN_AA           = 0x00
EN_RXADDR       = 0x38
RF_CH           = 0x02
RF_SETUP        = 0x18
CONFIG          = 0x04
DYNPD/FEATURE   = 0x30 0xe0
Data Rate       = 1 MBPS
Model           = nRF24L01+
CRC Length      = Disabled
PA Power        = PA_MIN
ARC             = 0

Go back and read #2 and #9 and follow request there.
How did you arrive at your "results".
Any code or error messages should be provided within code "tags" here, again not on some obscure site people have to search for.

Hi
My dear friend. I update the first post with whatever is possible from my side. Some documents that i think someone will need to check unfortunately can't upload that's why i post a link something which a lot of you doing. If you want to help please read it carefully and i think is providing everything you need for shaping an opinion if you ofcourse familiar with the specific communication.
On POST #12 I made some changes on arduino NANO. After using the code for communication test between nRF and arduino i tested for 4 different nRF modules and posted the results copied from TERATERM asking if someone can tell me if arduino nano can see these 4 modules.
I hope is clear enough for you.
My sincere regards

Your results still indicate the radios are not 'talking' to the microcontroller correctly. Again you need to verify your connections and wiring is correct.

Hi
This is excactly the diagram i use from the beginning. Probably i have connection issue on the breadboard. I will solder everything and order few more nRF's maybe also destroyed them with all these experiments and i will update here. Thank you for your efforts to help.
Regards

Problems can stem from trying to use Arduino boards as power supplies which they were never designed for.

Hello 1967nikos

I have been following the topic of using this type of wireless module and the associated software functions for some time now.

For wireless projects, I recommend using the HC12 module.

What are the advantages:

  1. no external functions from a library are needed.
  2. the development of a communication protocol is in your hands
  3. the necessary development steps can be programmed and tested without using the wireless module
  4. the radio module can be easily configured for the project requirements
  5. both transmitter and receiver are contained in one radio module.

hth

Have a nice day and enjoy coding in C++.

Hi
Thanks for the answer no i am using the pc to power on the arduino boards and each of the nRF module has his own power supply of 10A.

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