So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By t_andersen
#60455 I have programmed a thermostat that can be set over the internet. After a power loss, I want the thermostat to return to the last setpoint that was entered, so I wish to store the setpoint in the EEPROM. I understand from the documentation that, in fact, there is no real EEPROM in the 8266 but that the data instead is stored in the flash memory next to the program itself behind the back of the programmer. For every compilation of the program after small modifications, the "EEPROM" data will therefore wind up in a new location (I think). The same program must therefore be used to read and store data in the EEPROM.

The problem I have is an initialization issue. In the beginning of the sketch, I read the stored setPoint from the "EEPROM" but the very first time, the contents may be garbage and give a "nan". How can I tell the program that it is a first-time run, so that it does not read the EEPROM the very first time it is executed?