problem in transfering data from arduino mini pro to arduino uno using NRF24L01

Hello

I am trying to transfer data from one device to another. so i am trying simple program.

Transmitter side

connections

USB TTL ARDUINO MINI PRO NRF24L01

3.3V ---- VCC ----- V+

GND ---- GND ----- GND

TX ---- RX

RX ---- TX

PIN 7 ----- CE

PIN 8 ----- CSN

PIN 11 ----- MOSI

PIN 12 ----- MISO

PIN 13 ----- SCK

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

Receiver part

connection

ARDUINO uno NRF24L01
3.3v ----- V+
GND ----- GND
PIN 7 ----- CE
PIN 8 ----- CSN
PIN 11 ----- MOSI
PIN 12 ----- MISO
PIN 13 ----- SCK

receiver code

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

I am not getting anything on serial monitor, can some one please tell me what is the mistake and help me to solve the issue.

Thanks in advance

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

…R

Robin2: 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

...R

Hello Robin

I tried your simple one way transmission code.

In serial monitor i am getting some strange messages

serial monitor message. 0⸮{؟⸮⸮O⸮0⸮{؟⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮⸮⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮⸮0⸮{؟⸮⸮O⸮⸮⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮⸮0⸮{⸮⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮⸮⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮⸮000⸮00⸮0⸮0⸮0⸮{؟⸮⸮O⸮0⸮0⸮0⸮0⸮0⸮0⸮0⸮0⸮0⸮{⸮0⸮{⸮0⸮{؟⸮⸮O⸮⸮⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮⸮0⸮0⸮0⸮{؟⸮⸮O⸮0⸮{؟⸮⸮O⸮⸮⸮⸮k⸮⸮⸮C⸮⸮⸮⸮⸮0⸮{؟⸮⸮⸮0⸮{؟⸮⸮O⸮⸮⸮⸮k⸮⸮⸮C⸮⸮⸮⸮̝⸮⸮k⸮⸮⸮C⸮⸮⸮⸮

on receiver side i am setting as SimpleRx Starting on serial monitor.

I think there is problem with the transmitter side. can you please tell me what will be the issue.

Have you correctly set the baud rate in the Serial Monitor?

When either program starts it should print a message that has nothing at all to do with the wireless. If that initial message does not appear then there is a completely different problem.

Have you tried the connection test program that is in my Tutorial?

It will also help if you post the pair of programs that YOU have uploaded to your two Arduinos

...R

Robin2: Have you correctly set the baud rate in the Serial Monitor?

When either program starts it should print a message that has nothing at all to do with the wireless. If that initial message does not appear then there is a completely different problem.

Have you tried the connection test program that is in my Tutorial?

It will also help if you post the pair of programs that YOU have uploaded to your two Arduinos

...R

Yes I tried. there was problem with board now i replaced it is working fine.

can you please send me any example code to send sensor data.

i want to send sensor data from transmitter to receiver.

bmg1234: can you please send me any example code to send sensor data.

NO.

I am willing to help you with your code. It should not be too difficult to modify one of my examples to send sensor data.

Have you got a short program that reads the sensor and displays the data on the Serial Monitor?

...R

yes i have code but it is not working

transmitter code

// 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 address[5] = {'R','x','A','A','A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
void setup() {
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
Serial.begin(9600);
pinMode(4,INPUT);
}
void loop() {
int x =digitalRead(4);
radio.write(&x, sizeof(x));
delay(100); }

receiver code

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

#define CE_PIN   9
#define CSN_PIN 10

const byte address[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);
void setup() {
Serial.begin(38400);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
pinMode(4,OUTPUT);
}
void loop() {
if (radio.available()) {
int x;
radio.read(&x, sizeof(x));
if(x){
digitalWrite(4,HIGH);
Serial.println(x);
}
else{
digitalWrite(4,LOW);
}
}
}

The transmitter does not use the standard SS pin, but does not set it to OUTPUT.

Note about Slave Select (SS) pin on AVR based boards

All AVR based boards have an SS pin that is useful when they act as a slave controlled by an external master. Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative.

It is, however, possible to use any pin as the Slave Select (SS) for the devices. For example, the Arduino Ethernet shield uses pin 4 to control the SPI connection to the on-board SD card, and pin 10 to control the connection to the Ethernet controller.

from A Brief Introduction to the Serial Peripheral Interface (SPI).

Hello

I tried to modify the transmitter code. i am getting output but there is some disturbance. if switch is not pressed at transmitter some times still i get output on receiver. why is this so?

can you please help me to solve mistake in the code

transmitter code

// SimpleTx - the master or the transmitter

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

#define CE_PIN   7
#define CSN_PIN 8
int S = 2; 
int SW = 4; 
const byte address[6] = "00001";


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
void setup() {
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
Serial.begin(38400);
pinMode(S,INPUT);
pinMode(SW,INPUT);
}

void loop(){
  int msg =digitalRead(2);
{ if (digitalRead(S) == HIGH); 
      
    radio.write(&msg,S);}
    int ms =digitalRead(4);
{ if (digitalRead(SW) == HIGH);
    
 radio.write(&ms, SW);}}

Receiver code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN   9
#define CSN_PIN 10


#define S 2       
#define SW 4   

const byte address[6] = "00001";

RF24 radio(CE_PIN, CSN_PIN);
void setup() {
Serial.begin(38400);
radio.begin();
radio.openReadingPipe(1, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();

 pinMode(S, OUTPUT);
 pinMode(SW, OUTPUT);}

void loop(){
 if (radio.available()){
  int msg;
   radio.read(&msg,S);    
     
     if (msg){digitalWrite(S, HIGH);}
else {digitalWrite(S, LOW);}}
{ int ms;
     radio.read(&ms, SW); 
        if (ms){digitalWrite(SW, HIGH);}
     else {digitalWrite(SW, LOW);}
     delay(10);}}

With that very crappy formatting you don't see your errors, use Ctrl-T in the IDE to clean that crap up.

if (digitalRead(S) == HIGH);
if (digitalRead(SW) == HIGH);

Do normal working if statements look like this?

Did you connect an external pullup to the switch?

    radio.write(&msg,S);}

So the size of the message depends on the pin used as a button? Strange...

Why do people so often try to run before they can even walk?