nRF24L01 communication

Hi, I am trying to communicate between two nRF24L01 modules. One is connected to mega 2560 and second to UNO. The problem is, that I get " No radio found " ==> no answer. My code and circuit:

//RECEIVER - ARDUINO UNO

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

float temperature[2];
RF24 radio(CE_PIN, CSN_PIN);
const byte thisSlaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};

void setup(void)
{
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate( RF24_250KBPS );
  radio.openReadingPipe(1, thisSlaveAddress);
  radio.startListening();
  Serial.println("Humidity & temp");
  delay(2000);
  Serial.println("Starting.....");
  delay(2000);
}

void loop(void)
{
  if ( radio.available() ) {
        radio.read( &temperature, sizeof(temperature) );
    Serial.println("Temp");
    Serial.println("Humidity");
    Serial.println(temperature[0]);
    Serial.println(" C");
    Serial.println(temperature[1]);
    Serial.println(" %");
    delay(1000);
  }
  else {
    Serial.println("No radio Found");
  }
}
//TRANSMITTER - ARDUINO MEGA 2560

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

int pin = A0;
DHT11 dht11(pin);
float temperature[2];
RF24 radio(CE_PIN, CSN_PIN);
const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};

void setup(void) {
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate( RF24_250KBPS );
  radio.setRetries(3, 5); // delay, count
  radio.openWritingPipe(slaveAddress);
}

void loop(void)
{
  float temp, humi;
  //dht11.read(humi, temp);
  temp = 20;
  humi = 42;
  Serial.println(humi);
  Serial.println(temp);
  temperature[0] = temp;
  temperature[1] = humi;
  radio.write( &temperature, sizeof(temperature) );
  delay(1000);
}



UNO

Do you have capacitors on the radio supplies?

Make sure the rf24 power supply can provide enough current. This is especially true for the high power (external antenna) modules. I use homemade adapters like these. They are powered by 5V and have a 3.3V regulator on the board. Robin2 also has suggested trying with a 2 AA cell battery pack.

No, but I've tried it with them before, and it was the same. I used 10-50 µF (I can't remember now).

You can't do this in your receiver code loop(). You'll get 1000s of lines to the serial console during slight pauses in transmission.

Why do you only want 5 retries?

There is a radio.stopListening(); missing in the transmitter setup.

The 3.3V from Arduinos is rarely strong enough to make the NRFs work,
a capacitor can help, a solid 3.3V supply works best.

I dislike these fake processing messages very much.
Do you like to waste other people's time?

I tried it with external power supply, but it also didn't communicate.

What exactly is the "external" power supply and how did you have it connected?

Here:

I was also thinking about wifi, cannot be this the problem?

Can somebody help me?

Please post your latest code and show what messages appear from it on the serial console.

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