[solved]'void value not ignored as it ought to be'

So I have had some success replicating Nick Gammon's great work with solar powered arduino here:

Two days ago I compiled and uploaded the receiving sketch to my Arduino Nano, and all is working fine. It is still loaded and I can successfully monitor the voltage of the ATmega328P that is transmitting it's internal voltage.

Roll the clock forward to today and I try to compile the same receiving sketch and I keep getting the error:
"void value not ignored as it ought to be".

The only change since my successful compile was that I noticed that I had a number of libraries that needed updating. I updated those (one of which included the RF24 library). In my haste I didn't notice what the other libraries were that I updated.

I tried to roll back to the previous version of the RF24 library, but still the error persists.

The code is shown below:

// Program to receive a reading from a NRF24L01
// Author: Nick Gammon
// Date: 15th March 2015

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
//#include <bitBangedSPI.h>
//#include <MAX7219.h>

//
// Hardware configuration
//

/*

NRF24L01     Uno
----------   ----------------

  VCC         --> 3.3V pin
  Gnd         Gnd
  CSN         D10 (SS) 
  CE          D9
  MOSI        D11 (MOSI) 
  SCK         D13 (SCK)
  IRQ         N/C
  MISO        D12 (MISO)

MAX7219        Uno
----------     ----------------

 VCC            +5V
 Gnd            Gnd
 MAX7219 LOAD   D6  (/CS) line (active low)
 MAX7219 DIN    D7  (data in)
 MAX7219 CLK    D8  (clock)
 
*/

// Set up nRF24L01 radio on SPI bus plus pins 9 & 10

RF24 radio (9, 10);

// 1 chip, bit banged SPI on pins 6, 7, 8
//MAX7219 display (1, 6, 7, 8);  // Chips / LOAD / DIN / CLK

//
// Topology
//

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };


void setup(void)
  {

  //
  // Print preamble
  //

  Serial.begin(115200);
  Serial.println ("RF24 receiver - now with voltages!.");

  //
  // Setup and configure rf radio
  //

  radio.begin();

  // optionally, increase the delay between retries & # of retries
  radio.setRetries(15,15);

  // optionally, reduce the payload size.  seems to
  // improve reliability
  radio.setPayloadSize(8);

  radio.openWritingPipe(pipes[1]);
  radio.openReadingPipe(1,pipes[0]);
  
  //
  // Start listening
  //

  radio.startListening();

  //
  // Dump the configuration of the rf unit for debugging
  //

  radio.printDetails();
  
  //display.begin ();
  //display.sendString ("StArt");

  }  // end of setup

const float InternalReferenceVoltage = 1.086; // as measured
unsigned long lastReading;
unsigned int counter;

void loop(void)
  {
    // if there is data ready
  if ( radio.available() )
    {
      // Dump the payloads until we've gotten everything
      unsigned int voltage;
      bool done = false;
      while (!done)
      {
        // Fetch the payload, and see if this was the last one.
        done = radio.read( &voltage, sizeof voltage );
        counter++;
        if (counter > 9999)
          counter = 0;
        
        float results = InternalReferenceVoltage / float (voltage + 0.5) * 1024.0; 
        int elapsedTime = (millis () - lastReading) / 1000;
        Serial.print (counter);
        Serial.print (". ");
        Serial.print ("Reading = ");
        Serial.print (voltage);
        Serial.print (", Voltage = ");
        Serial.print (results);  
        Serial.print (" - elapsed time: ");
        Serial.println (elapsedTime);
        lastReading = millis ();

        char voltageBuf [8];
        dtostrf (results, 4, 2, voltageBuf);  // number, width, decimal places, buffer 
        char buf [9];
        sprintf (buf, "%3s %4i", voltageBuf, counter);
         
        //display.sendString (buf);

      }  // end reading the payload
    }  // end of data available
  }  // end of loop

This has really got me stumped so any help would be greatly appreciated :slight_smile:

EDIT - forgot to highlight the line of code that the error points to:

while (!done)
      {
        // Fetch the payload, and see if this was the last one.
        done = radio.read( &voltage, sizeof voltage );  // <<< ERROR LINE
        counter++;
        if (counter > 9999)
          counter = 0;

        done = radio.read( &voltage, sizeof voltage );Does the read method return a value ?
Even if it does you do not use it anywhere.

UKHeliBob:
done = radio.read( &voltage, sizeof voltage );Does the read method return a value ?
Even if it does you do not use it anywhere.

Sorry, this is not my code. The radio.read() method is part of the RF24 library and although I have looked at the library files I struggle to understand them fully. The method within the RF24.cpp file is as follows:

void RF24::read( void* buf, uint8_t len ){

  // Fetch the payload
  read_payload( buf, len );

  //Clear the two possible interrupt flags with one command
  write_register(NRF_STATUS,_BV(RX_DR) | _BV(MAX_RT) | _BV(TX_DS) );

}

I copied and pasted the receiving sketch directly from Nick Gammon's forum page and the only changes I made were to comment out anything pertaining to the LED Matrix Display.

void RF24::read( void* buf, uint8_t len ){The method does not return a value

I know that I said you did not use the value of done but that is not actually the case as there is a while loop depending on its value. My apologies.

UKHeliBob:
void RF24::read( void* buf, uint8_t len ){The method does not return a value

Is this the reason it is not compiling? And what could I have done (inadvertently) last time to allow it to compile?

Could any of the other library updates I did change something in the IDE that handles rules to this kind of method ? Or is this a generic coding rule that has existed since day one?

UKHeliBob:
I know that I said you did not use the value of done but that is not actually the case as there is a while loop depending on its value. My apologies.

No need to apologize, I'm grateful for your help :slight_smile:

Is this the reason it is not compiling?

Yes.

And what could I have done (inadvertently) last time to allow it to compile?

You used a different version of the library, where read() DID return a value.

PaulS:
Yes.
You used a different version of the library, where read() DID return a value.

Thank you,

I found a backup of my library folder and managed to reinstate the original library (it no longer exists at the link from Nick's forum post) and everything compiles as before.

I now need to understand the changes that the new library implements, why did the author change that method and how can I use the new method to achieve the same results?

These questions send me mad and give me purpose all at the same time lol :slight_smile:

I'm afraid that is an occupational hazard of using libraries from lots of sources. Plus, the underlying compiler, when upgraded, suddenly rejects code it used to accept. And now you have the fact that links die. It's all rather fragile, unfortunately.

The ideal thing is if libraries are on GitHub, where (so far) they don't die. Plus you can look back and see what changes were made.

why did the author change that method and how can I use the new method to achieve the same results?

He probably decided that the return code did nothing useful.

Thank you Nick and I'm really enjoying your Solar Powered Arduino tutorial btw :slight_smile:

I'm using it to build an alarm for my shed which is quite small and I don't really want to install mains electricity in it. I have replicated your hardware and modified the software to suit my needs, I'm just lacking a few more components until it's complete. Then comes the next challenge >> finding a new project :slight_smile:

Every hiccup I encounter helps me learn so much more. For instance, I have yet to understand exactly how Github works, but I know I will eventually.

Each time I find a problem that seems insurmountable, I find a solution ...or at least a way around it :wink:

Each time I find a problem that seems insurmountable, I find a solution ...or at least a way around it

Great. Can you help me with writing a program to import a Step 238 file into CATIA?

LOL!!

Well, it would probably take me longer to find the solution than it would you, but I think I would crack it in the end :stuck_out_tongue: