EcoRenovator  

Go Back   EcoRenovator > Improvements > Appliances & Gadgets
Advanced Search
 


Blog 60+ Home Energy Saving Tips Recent Posts


 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 10-10-10, 02:00 PM   #1
skyl4rk
Helper EcoRenovator
 
Join Date: Sep 2010
Posts: 66
Thanks: 3
Thanked 6 Times in 4 Posts
Default Arduino controlled "chest freezer" refrigerator

Below is arduino code that uses a thermistor voltage reading to turn a chest freezer on and off to maintain a certain temperature.

The thermistor measured about 500 ohms at 20C. 5V was applied to the thermistor and a 1000 ohm resistor in series, and the resulting voltage was measured at the junction between the two, as if you were using a voltage divider. On an analog input pin, the arduino displays a number between 0, which represents 0V, and 1000 which represents about 5V.

The voltage level at specific temperatures is determined by putting the thermistor in an ice bath (0 Celsius) and reading the result, then heating the water a bit to 10 Celsius and reading the result, and extrapolating the other degree levels.

Most of the following code is used to display the temperature by blinking an LED or sending a tone in morse code.

Void(loop) repeats every 1000 milliseconds, in other words, it checks the temperature every second.

The very bottom of the code, after void(loop), is where the arduino senses the current voltage level, and if it is outside of parameters, it turns on the voltage at pin 5. Pin 5 delivers 5V to a relay which is used to turn on the chest freezer. Vdyn is the dynamic voltage, in other words the voltage returned every 1000 milliseconds. Vmax is the parameter for the maximum desired voltage (which represents the maximum temperature before the compressor should turn on).

Because the chest freezer motor is an inductive load, a high amp relay is needed. I used a dual 10 amp relay, which is not the same as a 20 amp relay but almost as good.

Code:
// Kegerator Controller
// Kegerator control to digital pin 5
// Thermistor to analog pin 2
// this example is with a 500 Ohm thermistor at 20C and a 1k Ohm resistor to ground
// 5VDC to thermistor to resistor to ground, pin 2 to thermistor/resistor junction
// Vmax is 4C, Vmin is 2C on my thermistor circuit.
// Vdyn is the current voltage read from the thermistor
// Pin 13 flashes morse value for Vdyn on LED, pin 9 sounds a morse tone on speaker for Vdyn
// 434-> 0C, 447-> 1C, 459-> 2C, 472-> 3C, 484-> 4C, 497-> 5C, 509-> 6C, 522-> 7C, 534-> 8C, 545-> 9C, 559-> 10C

int Vmax = 484;  
int Vmin = 459;
int ThermistorPin = 2;
int ditlength = 25;
int hundreds = 0;
int tens = 0;
int ones = 0;
int Vdyn = 0;
int status = 0;
int x = 0;
int c = 0;

typedef void (*FunctionPointer) ();
FunctionPointer numeral[10] = {zero,one,two,three,four,five,six,seven,eight,nine};

int conversion[9] = {434,447,459,472,484,497,509,522,534};

void zero(void) {dash(); dash(); dash(); dash(); dash(); pause();};
void one(void) { dit(); dash(); dash(); dash(); dash(); pause();};
void two(void) {dit(); dit(); dash(); dash(); dash(); pause();};
void three(void) {dit(); dit(); dit(); dash(); dash(); pause();};
void four(void) {dit(); dit(); dit(); dit(); dash(); pause();};
void five(void) {dit(); dit(); dit(); dit(); dit(); pause();};
void six(void) {dash(); dit();dit();dit();dit(); pause();};
void seven(void) {dash(); dash(); dit(); dit(); dit(); pause();};
void eight(void) {dash(); dash(); dash(); dit(); dit(); pause();};
void nine(void) {dash(); dash(); dash(); dash(); dit(); pause();}; 

void dit() {
for (x=0; x<ditlength; x++){
  digitalWrite(9, HIGH);
  digitalWrite(13, HIGH);
  delayMicroseconds(2800);
  digitalWrite(9, LOW);
  digitalWrite(13, LOW);
  delayMicroseconds(100);
  }
  digitalWrite(9,LOW);
  digitalWrite(13,LOW);
  delay(100);
}

void dash() {
for (x=0; x<ditlength*3; x++){
  digitalWrite(9, HIGH);
  digitalWrite(13, HIGH);
  delayMicroseconds(2800);
  digitalWrite(9, LOW);
  digitalWrite(13, LOW);
  delayMicroseconds(100);
  }
  digitalWrite(9,LOW);
  digitalWrite(13,LOW);
  delay(100);
}

void pause(){
  digitalWrite(9,LOW);
  digitalWrite(13,LOW);
  delay(300);
}
    
void setup() {
  pinMode(9, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  
Vdyn = analogRead(ThermistorPin);
Serial.println(Vdyn);

if(Vdyn > Vmax){
  status = 1;
  }
 
if (Vdyn < Vmin){
  status = 0;
  } 

if(status == 1){
  digitalWrite(5, HIGH);
  Serial.println("Compressor On");
  } 

if(status == 0){  
  digitalWrite(5, LOW);
  Serial.println("Compressor Off");
  }

hundreds = int(Vdyn/100);
tens = int((Vdyn - (hundreds*100))/10);
ones = int(((Vdyn - (hundreds*100)) - (tens*10)));

numeral[hundreds]();
numeral[tens]();
numeral[ones]();

delay(1000);

for (c=0; c<9; c++){   //if in range 0 to 8, sound and flash morse degrees Celsius 
  int  d = c + 1;
  if (Vdyn > conversion[c] && Vdyn < conversion[d]){
    numeral[c]();
    Serial.println(c);
    }
  }
delay(1000);
}

skyl4rk is offline   Reply With Quote
The Following User Says Thank You to skyl4rk For This Useful Post:
Piwoslaw (10-12-10)
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:19 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Ad Management by RedTyger
Inactive Reminders By Icora Web Design