I'm using this library for my DS3231 which have a Atmel 24C32 on it. i have a float value which increases by 0.5, like:
27.50
28
28.50 ...
the code is like this:
float lowTemp= 10.5
float highTemp= 10.5
void setup(){
lowTemp = i2c_eeprom.read(100);
highTemp = i2c_eeprom.read(101);
}
void loop(){
if ((menuswtichStatus == HIGH) && (lcdWelcome == HIGH)) {
previousMillis = millis();
lcd.clear();
menuScroll++;
lcdClear = 1;
lcdClear2 = 1;
}
if (menuScroll == 1) {
lcd.setCursor(0, 0);
lcd.print("Temperature set:");
lcd.setCursor(0, 1);
lcd.print("Minimum ");
lcd.print(lowTemp);
lcd.print((char)223);
lcd.print("C ");
if (plusSwitchstatus == HIGH) {
lowTemp += 0.5;
}
if (minusSwitchstatus == HIGH) {
lowTemp -= 0.5;
}
}
if (menuScroll == 2) {
lcd.setCursor(0, 0);
lcd.print("Temperature set:");
lcd.setCursor(0, 1);
lcd.print("Maximum ");
lcd.print(highTemp);
lcd.print((char)223);
lcd.print("C ");
if (plusSwitchstatus == HIGH) {
highTemp += 0.5;
}
if (minusSwitchstatus == HIGH) {
highTemp -= 0.5;
}
}
if (menuScroll == 3) {
lcd.setCursor(0, 0);
lcd.print(" Saving the");
lcd.setCursor(0, 1);
lcd.print(" Settings...");
delay(1000);
i2c_eeprom.write(100, lowTemp);
i2c_eeprom.write(101, highTemp);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" SETTINGS");
lcd.setCursor(0, 1);
lcd.print(" SAVED!");
delay(2000);
menuScroll = 0;
lcdClear = 0;
lcdClear2 = 0;
}
}
i have the library and stuff up there, it's just an example of my code...
The float value is not saving(written), what's the solution?