Go Down

Topic: Saving String Variable In EEPROM Of NODEMCU (Read 890 times) previous topic - next topic

Parth_Kharia

one general question, does EEPROM storage value have to do something with this? like you have define EEPROM.begin(512), whereas i have define EEPROM.begin(1) in my code since beginning, this value was working just fine for reading and writing 4 values that i was using for my last relay states, so i never changed it, does it have something to do with all this?? do i need to change to a higher value?? 

cattledog

Quote
i have define EEPROM.begin(1) in my code since beginning, this value was working just fine for reading and writing 4 values that i was using for my last relay states, so i never changed it, does it have something to do with all this?? do i need to change to a higher value??
Absolutely. There is a default minimum of 4, which is why your EEPROM.begin(1) worked for your 4 values.

You have been wasting your and my time by not paying attention to fundamentals. This is why we ask to see running code which demonstrates the issue, and not snippets of code.

Parth_Kharia

#17
Oct 24, 2020, 06:28 pm Last Edit: Oct 24, 2020, 07:04 pm by Parth_Kharia
Sorry cattledog, for wasting your precious time, but i didn't knew it coz i am a newbie in arduino coding and some shitty youtube tutorial taught me that 1 stands for 1 MB of EEPROM storage which would be enough for storing upto 1024 values. I am extremely sorry for this, and thanks for your help mate, you helped me alot. I'll update the final outcome soon. Also can you just give me a last help, i want to use an if else condition that checks that any ssid is stored in EEPROM or not.

Cheers,
Parth Kharia

cattledog

Quote
Also can you just give me a last help, i want to use an if else condition that checks that any ssid is stored in EEPROM or not.
A simple method is use a separate eeprom address to store a value (0 or 1 is easy enough) which tells you if the ssid has been stored or not.

if(EEPROM.read(addr) == 1)
{
 //ssid has been stored
 //do what needs to be done if ssid is stored
 //perhaps set a flag to do something later in the program
}
else
{
 //ssid has not been stored
 // do what needs to be done if ssid not stored
 //perhaps set a flag to do something later in the program
}

Go Up