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 ![]()
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;