Radio.send NRF24L01

I followed this tutorial 1 week ago and got the code to work without any problems.

When i try to run the code now it says “radio unavailable” in the serial monitor.
I tried re pinning everything and going over the turotial again without success.
A friend of mine says that there could be a problem with the library because his code worked 1 week ago but when he tried running his code today he got radio unavailable as well.

I would appreciate it if someone gave an answer.

The code for the Receiver:

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int msg[1];
RF24 radio(8, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int LED1 = 3;

void setup(void) {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(1, pipe);
  radio.startListening();
  pinMode(LED1, OUTPUT);
}
void loop(void) {
  if (radio.available()) {
    bool done = false;
    while (!done) {
      done = radio.read(msg, 1);
      Serial.println(msg[0]);
      if (msg[0] == 111) {
        delay(10);
        digitalWrite(LED1, HIGH);
      }
      else {
        digitalWrite(LED1, LOW);
      }
      delay(10);
    }
  }
  else {
    Serial.println("No radio available");
  }
}

Code for transmitter

#include  <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int msg[1];
RF24 radio(8, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int SW1 = 7;
void setup(void) {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(pipe);
} void loop(void) {
  if (digitalRead(SW1) == HIGH) {
    msg[0] = 111;
    radio.write(msg, 1);
  }
}

A friend of mine says that there could be a problem with the library because his code worked 1 week ago but when he tried running his code today he got radio unavailable as well.

Your friend is an idiot. Code does not rot. If the code worked last week, the code will work this week.

The same can not be said for the hardware.

When i try to run the code now it says "radio unavailable" in the serial monitor.

Serial.println("No radio available");

You have very serious problems.

If the code worked and does not now then it can be a couple of things:

  • Tx not working.
  • Rx not working.

If TX not working (which you don't know as you have no debug messages):

  • Check power supply - should not have 5v direct to NRF24L01.
  • Check earth connections.
  • Check other connections.

If RX not working:

  • Check power supply - should not have 5v direct to NRF24L01.
  • Check earth connections.
  • Check other connections.

G

put a Serial.print debugging statement in this section of code:

  if (digitalRead(SW1) == HIGH) {
    msg[0] = 111;
    radio.write(msg, 1);
  }

To verify that the transmitter is attempting to send something, in your case, half an integer.

6v6gt:
put a Serial.print debugging statement in this section of code:

  if (digitalRead(SW1) == HIGH) {

msg[0] = 111;
    radio.write(msg, 1);
  }



To verify that the transmitter is attempting to send something, in your case, half an integer.

111 is, in my book, an integer.

111 is, in my book, an integer.

But the code is only writing one byte (the high order one) of the int, so it IS only writing half an int. Not the half that contains the bits that are set, mind you.

I've found those radios to be very position sensitive, both distance and antenna orientation, try aiming the antenna in a different direction and moving away from metal obstructions / reflectors.

outsider:
I've found those radios to be very position sensitive, both distance and antenna orientation, try aiming the antenna in a different direction and moving away from metal obstructions / reflectors.

Finally! This worked for me thanks!

Finally! This worked for me thanks!

So, the code hadn’t rotted at all.

The receivers can be easily overloaded when two units are adjacent and running at max power.

This Simple nRF24L01+ Tutorial may be of interest.

I Have no problem with the nRF24L01+ modules with PCB antennas communicating when both are on the same table. I think the default is full power and I have never changed it.

If you are having problems try putting a 10µF capacitor across the Vcc and GND pins of the nRF24 module.

...R