Hi All
I'm having difficulty reading back the contents of an ESP8266 Feather Huzzah.
I'm trying to read consecutive address but I get the same data value at address 0 for all headings 'Boiler fire called at' to 'wdt'. addr++ doesn't move to next address.
Any suggestions would be welcomed
void eepromRead()
{
valueRead = EEPROM.read(address); //reads back all eeprom contents after each write
if (e > 0) //means gas boiler has fired
{
Serial.print("address = ");
Serial.print(address);
Serial.println("");
Serial.println("Reading back written eeprom contents\n");
}
else
{
Serial.println("no gas firings yet today\n");
}
address = 0;
for (f = 0; f <= e; f++) //reads back all eeprom writes
{
if (lastPilotCounter != 0) //prevents printing below if boiler hasn't fired yet
{
EEPROM.read(address); //reads back all eeprom contents after each write
Serial.print("Boiler fire called at ");
Serial.print(valueRead); //hour from DS3231 (int)
Serial.print(":");
address++; //advances value of address by 1
Serial.print(valueRead); //minute from DS3231 (int)
Serial.print(":");
address++; //advances value of address by 1
Serial.print(valueRead); //second from DS3231 (int)
Serial.print("\t");
Serial.print("lastPilotCount = ");
Serial.print(valueRead);
address++; //advances value of address by 1
Serial.print("\t");
Serial.print("e = "); //int number of Gas boiler firings today
Serial.print(valueRead);
address++; //advances value of address by 1
Serial.print("\t");
Serial.print("f = "); //int counter
Serial.print(valueRead);
address++; //moves to the next eeprom address
Serial.print("\t");
Serial.print("wdt = "); //int number of wdt resets
Serial.println(valueRead);
address++; //moves to the next eeprom address
}
if (f == e)
{
address = 0;
valueRead = 0;
}
}
if (address == addr - 1)
{
Serial.print("\nvalues read from all ");
Serial.print(arraySize);
Serial.println("EEPROM Addresses\n");
}
}//end of void eepromRead()
Sorry, I pasted the wrong void eeprom() function. I tried the one shown below with the same results
void eepromRead()
{
valueRead = EEPROM.read(address); //reads back all eeprom contents after each write
if (e > 0) //means boiler has fired
{
Serial.print("address = ");
Serial.print(address);
Serial.println("");
Serial.println("Reading back written eeprom contents\n");
}
else
{
Serial.println("no gas firings yet today\n");
}
address = 0;
for (f = 0; f <= e; f++) //reads back all eeprom writes
{
if (lastPilotCounter != 0) //prevents printing below if boiler hasn't fired yet
{
EEPROM.read(address); //reads back all eeprom contents after each write
Serial.print("Boiler fire called at ");
Serial.print(valueRead);
Serial.print(":");
address++; //advances value of address by 1
EEPROM.read(address); //reads back all eeprom contents after each write
Serial.print(valueRead);
Serial.print(":");
address++; //advances value of address by 1
EEPROM.read(address); //reads back all eeprom contents after each write
Serial.print(valueRead);
Serial.print("\t");
Serial.print("lastPilotCount = ");
Serial.print(valueRead);
address++; //advances value of address by 1
EEPROM.read(address); //reads back all eeprom contents after each write
Serial.print("\t");
Serial.print("e = ");
Serial.print(valueRead);
address++; //advances value of address by 1
EEPROM.read(address); //reads back all eeprom contents after each write
Serial.print("\t");
Serial.print("f = ");
Serial.print(valueRead);
address++; //moves to the next eeprom address
EEPROM.read(address); //reads back all eeprom contents after each write
Serial.print("\t");
Serial.print("wdt = ");
Serial.println(valueRead);
address++; //moves to the next eeprom address
}
if (f == e)
{
address = 0;
valueRead = 0;
}
}
if (address == addr - 1)
{
Serial.print("\nvalues read from all ");
Serial.print(arraySize);
Serial.println("EEPROM Addresses\n");
}
}//end of void eepromRead()
Produced this:
f = 12
e = 11
address = 0
Reading back written eeprom contents
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
Boiler fire called at 23:23:23 lastPilotCount = 23 e = 23 f = 23 wdt = 23
wdtCount = 0
r = 0
These are the values stored in the first 8 EEPROM address:
address = 0 value = 23
address = 1 value = 16
address = 2 value = 21
address = 3 value = 1
address = 4 value = 1
address = 5 value = 0
address = 6 value = 0
address = 7 value = 6
On ESP8266 EEPROM is emulated using Flash and a RAM buffer and using it requires a bit more code than on AVR.
Have you called EEPROM.begin(size) / EEPROM.commit() / EEPROM.end()?
Hi
Yes I've called EEPROM.begin & EEPROM.commit() the EEPROM is being written to, it's the reading I'm struggling with
Delta_G nailed your problem in reply #3
I've changed the code to this below but the problem remains! It looks like the 'address' isn't incrementing
void eepromRead()
{
valueRead = EEPROM.read(address); //reads back all eeprom contents after each write
if (e > 0) //means boiler has fired
{
Serial.print("address = ");
Serial.print(address);
Serial.println("");
Serial.println("Reading back written eeprom contents\n");
}
else
{
Serial.println("no gas firings yet today\n");
}
//address = 0;
for (f = 0; f <= e; f++) //reads back all eeprom writes
{
if (lastPilotCounter != 0) //prevents printing below if boiler hasn't fired yet
{
for (address = 0; address <= f*7;)
{
EEPROM.read(address); //reads back all eeprom contents after each write
int readHour = valueRead;
Serial.print("Boiler fire called at ");
Serial.print(readHour);
Serial.print(":");
address++; //advances value of address by 1
EEPROM.read(address); //reads back all eeprom contents after each write
int readMin = valueRead;
Serial.print(readMin);
Serial.print(":");
address++; //advances value of address by 1
EEPROM.read(address); //reads back all eeprom contents after each write
int readSec = valueRead;
Serial.print(readSec);
Serial.print("\t");
Serial.print("lastPilotCount = ");
Serial.print(valueRead);
address++; //advances value of address by 1
EEPROM.read(address); //reads back all eeprom contents after each write
int readE = valueRead;
Serial.print("\t");
Serial.print("e = ");
Serial.print(readE);
address++; //advances value of address by 1
EEPROM.read(address); //reads back all eeprom contents after each write
int readF = valueRead;
Serial.print("\t");
Serial.print("f = ");
Serial.print(readF);
address++; //advances value of address by 1
EEPROM.read(address); //reads back all eeprom contents after each write
int readWdt = valueRead;
Serial.print("\t");
Serial.print("wdt = ");
Serial.println(readWdt);
address++; //moves to the next eeprom address
}
}
if (f == e)
{
//address = 0;
//valueRead = 0;
}
}
if (address == addr - 1)
{
Serial.print("\nvalues read from all ");
Serial.print(arraySize);
Serial.println("EEPROM Addresses\n");
}
}//end of void eepromRead()
Every one of these:
EEPROM.read(address);
needs to be:
valueRead = EEPROM.read(address);
As Delta_G & wildbill suggested I changed every instance of EEPROM.read(address) to
valueRead = EEPROM.read(address) & it now reads the eeprom.
Thanks all for your input