Config Stored to EEPROM Not Surviving Power Cycle
Posted: Tue Aug 11, 2015 6:16 pm
Board: Adafruit HUZZAH ESP8266
Arduino IDE: 1.6.5
Board Manager URL: http://arduino.esp8266.com/stable/packa ... index.json
(all downloaded within last couple days)
Issue: I can write to EEPROM and read back successfully, until a power cycle, then EEPROM is lost.
What am I doing wrong?
Arduino IDE: 1.6.5
Board Manager URL: http://arduino.esp8266.com/stable/packa ... index.json
(all downloaded within last couple days)
Issue: I can write to EEPROM and read back successfully, until a power cycle, then EEPROM is lost.
What am I doing wrong?
Code: Select all
#include <EEPROM.h>
void setup()
{
Serial.begin(115200);
int eeAddress = 0;
struct wifiConfig
{
char* ssid;
char* wifiKey;
char* host;
};
wifiConfig configuration_;
EEPROM.begin(512);
delay(100);
EEPROM.get(eeAddress, configuration_);
yield();
EEPROM.end();
delay(3000);
Serial.print("Read: ");
Serial.println(configuration_.ssid);
Serial.println(configuration_.wifiKey);
Serial.println(configuration_.host);
// Nothing Ever Output
delay(3000);
char ssid[] = "BLAH";
char wifiKey[] = "yada";
char host[] = "dontek.net";
wifiConfig configuration = { ssid, wifiKey, host };
EEPROM.begin(512);
delay(100);
EEPROM.put(eeAddress, configuration);
yield();
EEPROM.commit(); // Tried, since .end() was not work, this doesn't help.
EEPROM.end();
delay(3000);
wifiConfig configuration__;
EEPROM.begin(512);
delay(100);
EEPROM.get(eeAddress, configuration__);
yield();
EEPROM.end();
delay(3000);
Serial.print("Read: ");
Serial.println(configuration__.ssid);
Serial.println(configuration__.wifiKey);
Serial.println(configuration__.host);
Serial.println("");
// Values Output as Expected
Serial.println("Rebooting in 5 seconds...");
Serial.println("");
Serial.println("");
delay(5000);
ESP.deepSleep(5000000, WAKE_RF_DEFAULT);
}
void loop() {}