Need help with Error Message

Hi all.

I have built a sweep servo unit using two Arduino UNO’s and two NRF24L01 2.4 ghz transceivers, and a small 5 vdc servo, i have used the example on the Arduino Hub.

I can upload the Transmitter sketch ok, but when i try to upload the Receiver sketch i get this error “void value not ignored as it ought to be”

Here is the error message, highlights the following line in Void Loop "done = radio.read(msg 1,);

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>      // include the Servo library 
Servo myServo;   

int msg[1];
RF24 radio(9,10);//check your pin number on RF24 github check you have the right
//pin number for the arduino you're using. this pin is diffrent for diffrent arduino models.

const uint64_t pipe = 0xF0F0F0F0D2L;


void setup(void)
{
 myServo.attach(3);
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(1, pipe);
  radio.startListening();
  myServo.write(0);      // initial position of servo at angle 0
 
}

void loop(void)
{
  if(radio.available()){
    bool done = false;
    while (!done) {
      done = radio.read(msg, 1);
      Serial.println(msg[0]);
      if (msg[0] == 212) {
       myServo.write(180); 
      }
      else {   
            myServo.write(0); 
      }
    }
  }
}
 void read( void* buf, uint8_t len );

From RF24.h

The read() function does not return a value (ie it is declared void) but you try to assign its return value to the done variable.

      done = radio.read(msg, 1);

This may be due to the difference between code that was written for the ManiacBug version of the RF24 library and the newer and better TMRh20 version.

Have a look at this Simple nRF24L01+ Tutorial.

...R

Hi all.

I have read the NRF24l01 tutorial, i understand most of it, but i do not get any clues as to why i have this error message.

I have removed all RF libraries from my Arduino folder, and i have uploaded what i believe to be the TMRh20 library, i have run the sketch again, problem still exists.

UKHELIBob you have written a line of code in your initial reply, do i have to do something with it, i am confused about it.

Regards

Ray

gresleyman:
i have uploaded what i believe to be the TMRh20 library, i have run the sketch again, problem still exists.

As I said earlier I suspect your program was written with the earlier version of the library. Have you looked at the TMRh20 documentation for the radio.read()? Did you study the code in my tutorial to see how it differs from yours?

Did you change the line of code that @UKHeliBob pointed out - by dropping the done =

C'mon now. You need to do some of the work :slight_smile:

...R

Hi Robin2

"I need to do some work" are you having a laugh ? what do you think i have been doing with my time?

i have read the tutorial and i have already admitted i do not understand some of it. On this Forum i have to repeatedly remind people, that people like me (70 years old ex mechanical engineer) find it harder to understand some things, it takes time for the penny to drop as they say. It's certainly not for the want of trying. I need help not criticism.

Thanks for your help so far, when you say have i dropped the "done =" what do you mean by this ?

  1. write it out of the sketch.
  2. Replace it with what ?

Ray

gresleyman:
i have already admitted i do not understand some of it.

That's fair enough but if you don't tell us the specific parts that you don't understand it is rather difficult to help.

Thanks for your help so far, when you say have i dropped the "done =" what do you mean by this ?

  1. write it out of the sketch.
  2. Replace it with what ?

Remove it completely so your code looks like the equivalent line in one of my tutorial examples.

...R

PS... You are only 4 years older than me and I don't have a professional engineering qualification.

OK, how long have you been doing this ?

UKHELIBob you have written a line of code in your initial reply, do i have to do something with it,

The line of code was taken from the RF24.h file that declares the functions available in the library.

The function definition that I posted shows that the read() function is declared void, ie that it does not return a value. That may not be he case with other libraries where the function may return a value and would, therefore, not be declared void.

Either use a different library that does return a value or change your code so that it does not expect a return value, ie remove the done = and don't use the value that would have been returned if the function were not void.

Hi all.

Thank you all so far. Just to add to the subject, i read an article that the NRF24L01' work better with their own power supply, i therefore purchased two i2c shields for them

[

I have searched the internet for a library for these shields and i cannot find one ? or am i looking in the wrong places, or maybe they do not need one?

Can anyone advise on this issue please.

Regards

Ray](https://eu.banggood.com/Wholesale-Warehouse-Socket-Adapter-Module-Board-For-8-Pin-NRF24L01-Wireless-Transceiver-wp-Eu-935508.html)

No extra library needed. Just use the standard one

gresleyman:
Thank you all so far. Just to add to the subject, i read an article that the NRF24L01' work better with their own power supply, i therefore purchased two i2c shields for them

As the nRF24 uses SPI I'm not at all clear why you got I2C shields?

Have you tried the examples in my Tutorial? They have worked for other Forum users. I suggest you get the first example working properly before you try anything else.

...R

Hi.

I agree Robin2.

I have tried everything that so far has been suggested, now i am losing the will to live, there seems so much contradiction has to what and won't work, i have tried different libraries, i have tried to re write the sketch, i have now been on this problem around 15 hours in total, i think i am losing my mind, can you help me write the sketch,? remember i am a newbie.

My aim for this exercise is to create a simple, servo driven panning CCTV camera, panning in two directions, east to west and visa versa.The sketches i have cut and paste are off the instructables site.

Regards

Ray

As the nRF24 uses SPI I'm not at all clear why you got I2C shields?

Luckily what he bought, or at least the adaptor that he linked to, uses SPI

https://eu.banggood.com/Wholesale-Warehouse-Socket-Adapter-Module-Board-For-8-Pin-NRF24L01-Wireless-Transceiver-wp-Eu-935508.html

gresleyman:
i have now been on this problem around 15 hours in total, i think i am losing my mind, can you help me write the sketch,? remember i am a newbie.

There are working programs in my Tutorial. Start there. When you have my first example working properly we can consider moving forward.

If you have tried the first example and it did not work for you then please post the programs that YOU uploaded to your two Arduinos and also post a sample of the output from both of them

...R

PS ... even for the more experienced me, 15 hours is not long.

Hi Robin2

I have uploaded your Simple TX & RX sketches, when i run the sketch, the data is mega fast on the serial screen, following the advice, i have uploaded #29 's test sketch, to both TX & RX Arduino's and my Arduino's are not talking to their respective NRF24L01's according to the serial data.

Help.

Regards

Ray

Please make a simple diagram (pencil and paper is best) showing how you have everything connected for one of the Arduinos and post a photo of the diagram. (I am assuming the same problem is likely to apply to both).

...R

Hi Robin2

Yes, the problem applies to both Arduino’s.

I have uploaded a previously made Powerpoint Drawing, so much neater than my hand done drawings.

Regards

Ray

Image from Reply #NN so we don't have to download it. See this Simple Image Guide

...R

Your wiring seems to be wrong. SCK is 13, MISO is 12 and MOSI is 11

There are diagrams in my tutorial.

...R