Hello guys i'm working on an application where i need to save 2 float numbers in flash memory (i need them when the msp lose power) ,i have the hardware part done but i can't figure out the coding i'm very new to programing.
I need to do something like this.
I need to save "energie1" to flash and whe my msp lose power the value stays on and then when i power it back my "energie1" value goes something like this energie1=(media_puteri1*timp/3600)+flash_value;
PS: i read the ENERGIA flash write/read exemple but i don't understand how to save float values;
I need to do something like this.
Code:
int sensorPin = 23;
int sensorValue = 0;
float volt;
// loop part
sensorValue = analogRead(sensorPin);
unsigned long currentMillis = millis();
timp=currentMillis/1000;
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
volt=sensorValue;
volt=(volt*3.3)/4096;
volt=volt*8.51;
putere1=volt*amp1;
total_putere1=putere1+total_putere1;
}
media_puteri1=total_putere1/timp;
energie1=media_puteri1*timp/3600;
PS: i read the ENERGIA flash write/read exemple but i don't understand how to save float values;