Saving variable value in Flash Memory

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Carlini
Normal user
Posts: 16
Joined: 09 Apr 2017, 17:45
Location: Brazil

Saving variable value in Flash Memory

#1 Post by Carlini » 09 Apr 2017, 18:04

Hi guys

I am using the espeasy and I need to save the value of my variable Temperature in the flash memory of ESP 8266.

I cant lost the value of variable when the esp 8266 is restarted (power off -> power on)

Is it possible ? How can I do this ?

Thanks

krikk
Normal user
Posts: 118
Joined: 28 Feb 2017, 07:57
Location: Austria
Contact:

Re: Saving variable value in Flash Memory

#2 Post by krikk » 09 Apr 2017, 19:39

theoretically possible, but it would wear out the flash memory on the long run, so not a good idea...

Carlini
Normal user
Posts: 16
Joined: 09 Apr 2017, 17:45
Location: Brazil

Re: Saving variable value in Flash Memory

#3 Post by Carlini » 10 Apr 2017, 22:31

Do you know how ?

User avatar
lucaberta
Normal user
Posts: 59
Joined: 09 May 2016, 11:26
Location: Lausanne, Switzerland
Contact:

Re: Saving variable value in Flash Memory

#4 Post by lucaberta » 20 Apr 2017, 01:00

Technically speaking, you could use the SPIFFS file system to write each time you have a reading to a file, which effectively becomes the "last read value" from your temperature sensor.

The issue is that your ESP8266 flash will wear out very quickly, as it's not designed to be used that way. And once you wear it out, you will need to change the flash IC in your design, or the whole ESP8266 board in the worst case.

The better way to do this would be to store the last read value in a different database, typically the one where your ESP8266 board sends its data. Hopefully that database will always be available, and will also be able to tell what time it was when the last received temperature was effectively received.

Moreover, why would you care to keep the last temperature reading anyway if your sensor crashes or the battery dies? As soon as it starts up again you will get a new reading, and it does not matter what the old reading was about, really... it would be more interesting to know WHEN was the last reading taken, but that information again can only be taken from the database where you are sending the temperature data to.

Hope this helps.

Bye, Luca

mcteusz
New user
Posts: 7
Joined: 07 Mar 2017, 13:53

Re: Saving variable value in Flash Memory

#5 Post by mcteusz » 20 Apr 2017, 14:01

I think this is about something like here:
https://www.letscontrolit.com/forum/vie ... rol#p14559

And this is about Value Name 1: Temperature at Device4. Isn't it?
So first we set temperature in the variable but what to do when ESP restart?

jojocardee
New user
Posts: 5
Joined: 31 Mar 2017, 05:42

Re: Saving variable value in Flash Memory

#6 Post by jojocardee » 27 Apr 2017, 11:40

the database where you are sending the temperature data to
คาสิโนออนไลน์

foad62
New user
Posts: 6
Joined: 19 Apr 2017, 13:11

Re: Saving variable value in Flash Memory

#7 Post by foad62 » 17 Jul 2017, 13:19

Hi all,
I have a thermostat and I need to store the last preset value which is entered by the user permanently.
How can I do that?

cherowley
Normal user
Posts: 125
Joined: 14 Jan 2016, 09:39

Re: Saving variable value in Flash Memory

#8 Post by cherowley » 20 Jul 2017, 12:42

In my thermostat/timer plugin I write the set point & times to flash:

case PLUGIN_WEBFORM_SAVE:
{

//example to save the temp set point
tmpStr = WebServer.arg("plugin_121_SetTemp");
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0] = tmpStr.toFloat ();

SaveTaskSettings(event->TaskIndex);
success = true;
break;
}

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 41 guests