NRF24L01 No conncection

Hi,
today I am using two modules NRF24L01. I connected them to Arduino Uno and Arduino Nano. Both has Atmega 328P. I made a program based on https://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo

And it looks like that:

TRANSMIT

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

#define CE_PIN 9
#define CSN_PIN 10

#define greenled 2

const uint64_t pipe = 0xE8E8F0F0E1LL;

RF24 radio(CE_PIN, CSN_PIN);
int led[1];

void setup()
{
pinMode(greenled, OUTPUT);
Serial.begin(9600);
delay(1000);
Serial.println("Nrf24L01 Receiver Starting");
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
}

void loop()
{
if ( radio.available() )
{
bool done = false;
while (!done)
{
done = radio.read( led, sizeof(led) );
if(led[0] == 1)
{
digitalWrite(greenled, HIGH);
}
if(led[0] == 0)
{
digitalWrite(greenled, LOW);
}
}
}
else
{
delay(500);
Serial.println("No radio available");
}

}

RECEIVE

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

#define CE_PIN 9
#define CSN_PIN 10

#define greenled 2

const uint64_t pipe = 0xE8E8F0F0E1LL;

RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

int led[1];

void setup()
{
pinMode(greenled, OUTPUT);
Serial.begin(9600);
delay(1000);
Serial.println("Nrf24L01 Receiver Starting");
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
}

void loop()
{
if ( radio.available() )
{
bool done = false;
while (!done)
{
// Fetch the data payload
done = radio.read( led, sizeof(led) );
if(led[0] == 1)
{
digitalWrite(greenled, HIGH);
}
if(led[0] == 0)
{
digitalWrite(greenled, LOW);
}
}
}
else
{
delay(500);
Serial.println("No radio available");
}

}

When I turn both arduino on, "Receive Arduino" returns "No radio available" to Serial Monitor.

I don't know how to repair that.
Any ideas?

Thanks for answers!

Maybe have Transmit radio transmit something?
Both your codes are for reading, neither transmitting.
Where is a radio.write()?

Oh I see now.

So I wrote new code.

It's the same code as on the code I based on.

But i changed only loop() on Transmit to this:

void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
joystick[0] = 87921;
joystick[1] = 3267182;

radio.write( joystick, sizeof(joystick) );

}

Receiver write to Serial Monitor mostly "No radio available" or "X = -1 Y = -1"

What is the problem with that program?

You need to change more than what you did.
You also need to post code inside the proper code tags for the forum.
Read the sticked thread at the top of the forum please.

Ok, got it :slight_smile: