Hello
Sorry for the basic question but I was unable to figure it out myself.
I am trying to figure out how to use EEPROM in case of power outage.
I manged to successfully use EEPROM.get and EEPROM.put (using docs
int temp;
int s1max1;
int s1min1;
void setup() {
Particle.function("s1",s1 );
Particle.variable("s1max1",s1max1);
Particle.variable("s1min1",s1min1);
pinMode(D0, OUTPUT);
pinMode(D0, OUTPUT);
EEPROM.get(0, s1max1);
EEPROM.get(5, s1min1);
Serial.begin(9600);
}
void loop() {
//temp=airSensor.getTemperature();
size_t length = EEPROM.length();
Serial.print("The size of byte is "); Serial.print((length));
Serial.println(".");
delay(2000);
if(temp <= s1max1){
digitalWrite(D0, HIGH);
}
if(temp <= s1min1){
digitalWrite(D0, LOW);
delay(2000);
}
}
int s1 (String value) {
s1min1 = value.substring(0,2).toFloat();
s1max1= value.substring(2,4).toFloat();
EEPROM.put(0, s1max1);
EEPROM.put(5, s1min1);
return 0;
}
Although it works OK I did not understand how addresses work and how much storage each variable takes.
In this code attached I used address 0 for the first variable and address 5 for the second and printing the size of the eeprom to see if it changes.
My question is : How much of storage each INT with 1 digit (for example 6), with 2 digit (for example 26)/ 3 digit etc…
I tried reading this but I did not understand it.