temperature control

hi all I have small question, how can I get arduino to save my last temp setting if, ex power shut down then restart. I have this setup. When I start up the set point is 25 C but I would like to have it to remember the last setting I had set it. Is it possible in coding not using battery back up.

const int Led_Green = 10;          // Red LED (270E-GND) - pin 10
const int Led_Red   = 11;          // Green LED (270E- GND) - pin11
const int Relay     = 12;          // BC 548_ C-(yellow led via 270E-GND),B-1K-pin12,
const int Temp_Sensor = A0;        // Lm 35DT Temperature sensor        cont// E-GND.
const int Up_Key    = 2;           // adjust up key
const int Down_Key  = 3;           // adjust down key

int Vin = A0;                      // Variable to read the value from Pin A0
float Temperature;                 // variable that receives the converted voltage
int SetPoint = 25;

thanks john

You can use the internal EPROM, if your board has one, or an external chip like the 24LC256.

You would store the value at power down and read it at power up. Initially, it would be zero but that can be tested in code.

Hi Thanks A/E I'm using arduino uno r3 and 328P-PU, never used the eeprom before any help in getting started please. john

There are examples in the IDE. You can also use a library named something like EpromAnything?. You put all your data in a single structure then write it to some starting address, usually 0. Keep in mind that the internal EPROM has a limited number of read/write cycles so use it sparingly. Once at powerup and powerdown should not be a problem.

I also like to save a checksum byte to eeprom of the structure after changing anything in it. That allows the software to determine if the values it is getting from the eeprom are correct. If you are using something where you set the temperature point periodically, then that is where I would save the new set point to the eeprom. I have a controller for a hummingbird feeder I use (actually with a PIC processor) and I store the set point for the temperature, hysterisis and ambient air temp trigger points in a small structure. When it initially powers up, the structure is not initialized, so the software sets the default values in the structure and the checksum. If I change the settings, the new settings are then set, but since the array was setup at first time power up, it is now valid so the current settings are taken from the structure instead of the defaults. (saves having to program the structure in the eeprom the first time - let the software configure the default settings).

A "gotcha" you've probably thought of, but hasn't really been explored here yet...

You asked...

how can I get arduino to save my last temp setting if, ex power shut down then restart.

... You can't really get it to save the setting as it "dies" during a power failure. In simple terms, you save it whenever it changes. In the real world you may want to refine that, e.g. save it if it has changed since the last time it was saved AND hasn't been changed again for say 10 seconds. (This would be "necessary" if your setting routine was like many simple devices... you press an "up" (or down) button multiple times to get to where you want the setting to be. No need to save at each "step" on the journey!