NRF24L01 receiver problems

Hi there… lately i’ve a projects on water level detector by using arduino and nrf24l01…

i’ve been working on this code and i have a problem on the receiver part which is got error void value not ignored as it ought to be. i been through other topics but i still can’t figure it out. please someone help me.

this is my code.

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
/* establish RF communication [13] */
float signal[4];
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;

/* declare variables */
int greenLED = 2;
int yellowLED = 3;
int amberLED = 4;
int redLED = 5;
int whiteLED = 6;

/* initial system setup */
void setup(){
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
pinMode(greenLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(amberLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(whiteLED, OUTPUT);
}

void loop(){
if (radio.available()){
digitalWrite(greenLED, HIGH);
Serial.println(“Transmitter is active”);
bool done = false;
while (!done){
done = radio.read(signal, sizeof(signal)); ← this is where the error
for(int i=0; i<=3; i++){
Serial.println(signal*);*
}
/* yellow alert */
if (signal[1] > 4.9) {
analogWrite(A1,255);
analogWrite(A2,0);
analogWrite(A3,0);
analogWrite(A4,0);
noTone(A5);
Serial.println(“Yellow Alert!!”);
/* amber alert */
if ((signal[1] > 4.9)&&(signal[2] > 4.9)) {
analogWrite(A1,0);
analogWrite(A2,255);
analogWrite(A3,0);
analogWrite(A4,0);
noTone(A5);
Serial.println(“Amber Alert!!”);
/* red alert */
if ((signal[1] > 4.9)&&(signal[2] > 4.9)&&(signal[3] > 4.9)) {

  • analogWrite(A1,0);*
    analogWrite(A2,0);
    analogWrite(A3,255);
    analogWrite(A4,0);
    noTone(A5);
    Serial.println(“Red Alert!!”);
    delay(30000); // delay 30 seconds
    delay(1000); // delay 1 second
    done = radio.read(signal, sizeof(signal)); ← this is where the error
    for(int i=0; i<=3; i++){
    Serial.println(signal*);*
    }
    /* flood warning */
    while((signal[1] > 4.9)&&(signal[2] > 4.9)&&(signal[3] > 4.9)){
    analogWrite(A1,0);
    analogWrite(A2,0);
    analogWrite(A3,255);
    analogWrite(A4,255);
    tone(A5,500);
    Serial.println(“Flood warning!!”);
    delay(5000); // delay 5 seconds
    done = radio.read(signal, sizeof(signal)); ← this is where the error
    for(int i=0; i<=3; i++){
    Serial.println(signal*);*
    }
    }
    }
    }
    }
    /* system reset */
    else if ((signal[1] < 4.9)&&(signal[2] < 4.9)&&(signal[3] < 4.9)) {
    analogWrite(A1,0);
    analogWrite(A2,0);
    analogWrite(A3,0);
    analogWrite(A4,0);
    noTone(A5);
    }
    delay(5000); // delay 5 seconds
    }
    }
    else{
    Serial.println(“Signal is not available”);
    digitalWrite(greenLED, LOW);
    }
    }
    Please help me… thank you in advance
done = radio.read(signal, sizeof(signal)); <-- this is where the error

And does radio.read return a value?

Help others to help you - use code tags when posting code.

what did you mean by radio.read return a value? i really don’t know because i’m new to this. sorry.

You are probably using a different library (RF24) than the snippet that you copied did use.
The original ManiacBug library and its successors have slight differences in the interface.

But finding the right library, or changing the code to use the current will not really help you.

Your code shows clearly that you don't have an idea of what you are doing.

This sequence is not useful to controll leds on pins 2 to 6.

analogWrite(A1,255);
analogWrite(A2,0);
analogWrite(A3,0);
analogWrite(A4,0);
noTone(A5);

i get the RF24 library from here : http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo.

is there any problem for this library or im the one who is problem? :cry: :cry:

did any other RF24 library that can use for my projects?

sorry for the sequence to control leds, Whandall. I will check on it later. Thanks for your guide.

You should use the library you are using, it is the best official library I know.

Your code should be rewritten, not only changed to compile.

Do not use delay().
Do not block on Serial.

Your signals/values could/should be evaluated on the sending side and transferred as bytes (or even bits), not as floats.

Anyway, your current ‘program’ compiles when changed like that

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
/* establish RF communication [13] */
float signal[4];
RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;

/* declare variables */
int greenLED = 2;
int yellowLED = 3;
int amberLED = 4;
int redLED = 5;
int whiteLED = 6;

/* initial system setup */
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(1, pipe);
  radio.startListening();
  pinMode(greenLED, OUTPUT);
  pinMode(yellowLED, OUTPUT);
  pinMode(amberLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(whiteLED, OUTPUT);
}

void loop() {
  if (radio.available()) {
    digitalWrite(greenLED, HIGH);
    Serial.println("Transmitter is active");
    bool done = false;
    radio.read(signal, sizeof(signal));
    for (int i = 0; i <= 3; i++) {
      Serial.println(signal[i]);
    }

    /* yellow alert */
    if (signal[1] > 4.9) {
      analogWrite(A1, 255);
      analogWrite(A2, 0);
      analogWrite(A3, 0);
      analogWrite(A4, 0);
      noTone(A5);
      Serial.println("Yellow Alert!!");

      /* amber alert */
      if ((signal[1] > 4.9) && (signal[2] > 4.9)) {
        analogWrite(A1, 0);
        analogWrite(A2, 255);
        analogWrite(A3, 0);
        analogWrite(A4, 0);
        noTone(A5);
        Serial.println("Amber Alert!!");

        /* red alert */
        if ((signal[1] > 4.9) && (signal[2] > 4.9) && (signal[3] > 4.9)) {
          analogWrite(A1, 0);
          analogWrite(A2, 0);
          analogWrite(A3, 255);
          analogWrite(A4, 0);
          noTone(A5);
          Serial.println("Red Alert!!");
          delay(30000); // delay 30 seconds
          delay(1000); // delay 1 second
          radio.read(signal, sizeof(signal));
          for (int i = 0; i <= 3; i++) {
            Serial.println(signal[i]);
          }

          /* flood warning */
          while ((signal[1] > 4.9) && (signal[2] > 4.9) && (signal[3] > 4.9)) {
            analogWrite(A1, 0);
            analogWrite(A2, 0);
            analogWrite(A3, 255);
            analogWrite(A4, 255);
            tone(A5, 500);
            Serial.println("Flood warning!!");
            delay(5000); // delay 5 seconds
            radio.read(signal, sizeof(signal));
            for (int i = 0; i <= 3; i++) {
              Serial.println(signal[i]);
            }
          }
        }
      }
      /* system reset */
      else if ((signal[1] < 4.9) && (signal[2] < 4.9) && (signal[3] < 4.9)) {
        analogWrite(A1, 0);
        analogWrite(A2, 0);
        analogWrite(A3, 0);
        analogWrite(A4, 0);
        noTone(A5);
      }
      delay(5000); // delay 5 seconds
    }
  }
  else {
    Serial.println("Signal is not available");
    digitalWrite(greenLED, LOW);
  }
}