Hi
I'm trying to use EEPROM.get() to save floats to the onboard EEPROM, and am getting an odd error.
This is the code section where I'm defining the float variables, then trying to read them from the EEPROM during the initialisation of the code. The EEPROM addresses are declared at the beginning of the code.
float rainAnnual;
float rainMonthly;
float rainDaily;
float rainHourly;
EEPROM.get(rainAnnualEEPROM, rainAnnual);
EEPROM.get(rainMonthlyEEPROM, rainMonthly);
EEPROM.get(rainDailyEEPROM, rainDaily);
EEPROM.get(rainHourlyEEPROM, rainHourly);
The error message returned during compilation is:
exit status 1
'EEPROM' does not name a type
The code uses the same format as examples I've seen, so I'm not sure what it is looking for. Any assistance is appreciated.
Cheers,
Brian
I'd use "put"
I think you need to post your code.
(Sorry if that sounds obvious)
Hi
I have used .put later in the code when values have changed. At this point in the code, everything is initialising, so I want to retrieve the values that were previously saved so that the code can continue from where it left off without resetting all the long-term data
...that we still can't see.
Here is the initialisation code:
* 1 Mar 2023 Added Blynk
* 7 Mar 2023 Added RTC for daily resets
* 1 Apr 2023 Added EEPROM registers to save values for reload after restart
*************************************************************/
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#include <EEPROM.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <SPI.h>
#include <Ethernet.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
// Set up EEPROM Registers
#define tipCountEEPROM 0 // int
#define tipsPerHourEEPROM 5 // float
#define mmRainEEPROM 10 // float
#define rateEEPROM 15 // float
#define volumeTippedEEPROM 20 // float
#define rainHourlyEEPROM 25 // float
#define rainDailyEEPROM 30 // float
#define rainMonthlyEEPROM 35 // float
#define rainAnnualEEPROM 40 // float
#define irsPin 23 // bucket tip sensor pin
// Set up RTC
const char* ntpServer = "nz.pool.ntp.org";
const long gmtOffset_sec = 43200; //43200 for NZ STD time
const int daylightOffset_sec = 46800; //46800 for DST
// rainfall quantums
float rainAnnual;
float rainMonthly;
float rainDaily;
float rainHourly;
EEPROM.get(rainAnnualEEPROM, rainAnnual);
EEPROM.get(rainMonthlyEEPROM, rainMonthly);
EEPROM.get(rainDailyEEPROM, rainDaily);
EEPROM.get(rainHourlyEEPROM, rainHourly);
BrianHight:
EEPROM.get(rainAnnualEEPROM, rainAnnual);
EEPROM.get(rainMonthlyEEPROM, rainMonthly);
EEPROM.get(rainDailyEEPROM, rainDaily);
EEPROM.get(rainHourlyEEPROM
That code isn't in a function.
Try putting it in setup, or a function called by setup.
You have never seen example code written like that.
JCA34F:
You have to provide the EEPROM address where the variable is stored
That's done, but you have to do it in a function
1 Like
OH
I didn't realise that. Thanks.
system
Closed
September 28, 2023, 11:15pm
11
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.