Howdy folk, I've been working on setting up an arduino to manage the temp in my fridge and I thought I would chronicle my adventure. What I have is rough but I think it will work. My setup is as follows:
1 x Arduino clone(freeduino, works the same)
1 x LM35 temp sensor
1 x P2N2222A transistor
1 x 1N4004 diode
1 x 1K resistor
1 x PB134005 relay
I'll post the schematic if someone needs it.
The LM35 output goes to analog 0
The relay for the fridge is on pin 13
Here is my arduino code.
float tempC;
float tempF;
int tempPin = 0;
int ledPin = 13;
void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
}
void loop()
{
tempC = analogRead(tempPin); //read the value from the sensor
tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature
tempF = (tempC * 9)/ 5 + 32; // converts to fahrenheit
Serial.print ((int) tempC ); //send the data to the computer
Serial.print(" Celsius, ");
Serial.print ((int) tempF ); //send the data to the computer
Serial.print(" Fahrenheit, -> ");
delay(1000); //wait one second before sending new data
digitalWrite(ledPin, HIGH); // sets the LED on
if (tempF < 71) digitalWrite(ledPin, HIGH);
if (tempF < 71) Serial.println ("fridge on");
if (tempF > 69) digitalWrite(ledPin, LOW);
if (tempF > 69) Serial.println ("fridge off");
This code was stolen from a number of arduino forums, mixed and matched, and then further mangled by me. I am not a programmer. Eventually I would like to have a computer log temprature, compresser state, and be able to adjust the min and max temp, and make all of this via a web page. For now I just need it to hold my fridge at 70F.
Next will be building temp probes like in Yuri's howto then wiring the relay into my fridge.
Simpleton
1 x Arduino clone(freeduino, works the same)
1 x LM35 temp sensor
1 x P2N2222A transistor
1 x 1N4004 diode
1 x 1K resistor
1 x PB134005 relay
I'll post the schematic if someone needs it.
The LM35 output goes to analog 0
The relay for the fridge is on pin 13
Here is my arduino code.
float tempC;
float tempF;
int tempPin = 0;
int ledPin = 13;
void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
}
void loop()
{
tempC = analogRead(tempPin); //read the value from the sensor
tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature
tempF = (tempC * 9)/ 5 + 32; // converts to fahrenheit
Serial.print ((int) tempC ); //send the data to the computer
Serial.print(" Celsius, ");
Serial.print ((int) tempF ); //send the data to the computer
Serial.print(" Fahrenheit, -> ");
delay(1000); //wait one second before sending new data
digitalWrite(ledPin, HIGH); // sets the LED on
if (tempF < 71) digitalWrite(ledPin, HIGH);
if (tempF < 71) Serial.println ("fridge on");
if (tempF > 69) digitalWrite(ledPin, LOW);
if (tempF > 69) Serial.println ("fridge off");
This code was stolen from a number of arduino forums, mixed and matched, and then further mangled by me. I am not a programmer. Eventually I would like to have a computer log temprature, compresser state, and be able to adjust the min and max temp, and make all of this via a web page. For now I just need it to hold my fridge at 70F.
Next will be building temp probes like in Yuri's howto then wiring the relay into my fridge.
Simpleton