Error: void value not ignored as it ought to be done = radio.read(&Irms, sizeof(float));

Good morning everyone, I had this sketch that worked now when loading the program gives me an error:

#include <Wire.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
float Irms ;
RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;

void setup(void) {

radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
Serial.println("setup() - Inizializzazione completata");
delay(300);
}
void loop(void){
if ( radio.available() )
{
bool done = false;
while (!done)
delay (1000);
{
delay(1000);
done = radio.read(&Irms, sizeof(float));

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

Please post your complete sketch as then end of it is missing

done = radio.read(&Irms, sizeof(float));

The read() function does not return a value but your code assumes that it does

Here is the declaration of the read() function in the library

    void read(void* buf, uint8_t len);

Note that the function is declared void, ie that it does not return a value

help How can I change my code?

Start by posting all of it and add the code tags

You also posted this in the Italian section

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum. It will help you get the best out of the forum in the future.

Thank you.

He didn't stop there. He also went on to Stack Exchange. arduino uno - Error: void value not ignored as it ought to be done = radio.read(&Irms, sizeof(float)); - Arduino Stack Exchange

And also got quite a good answer (even though I say it myself :slight_smile: )

Solved Thanks

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