EcoRenovator  

Go Back   EcoRenovator > Improvements > Appliances & Gadgets
Advanced Search
 


Blog 60+ Home Energy Saving Tips Recent Posts Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Display Modes
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)
Old 10-10-10, 02:23 PM   #2
skyl4rk
Helper EcoRenovator
 
Join Date: Sep 2010
Posts: 66
Thanks: 3
Thanked 6 Times in 4 Posts
Default

The relay used was this one:

relays, solenoids, buzzers, timers, sockets & accessories



It is double pole double throw so there are actually two 10 amp relay actuators. Depending on the size of your chest freezer motor, you may want to move up to the 20 amp relay.

A base for this relay is also needed. Make sure that the relay is rated at 6VDC (more or less) so that it kicks in when the arduino turns on the 5V to the trigger circuit. I think my relay was rated at 12VDC, but it still worked. The relay rated at 12V might have used more current than desirable at 5V.

The thermistors were part of a grab bag of thermistors from American Science and Surplus. They do not have them anymore, as far as I can tell. Any thermistor rated at 500 ohm to 1000 ohm should work fine. Just match it with a similar sized resistor. When you calibrate the thermistor you make up for any differences in ohmage.

AS&S did have this: American Science & Surplus : Solenoids and Relays

There was hysterisis built into this code, the code turned the compressor on at Vmax (484 or 4C), and did not turn it off until Vmin (459 or 2C).

I did this project quite a few years ago and had several arduino scripts on an old archive hard drive. I can't tell you for sure if this was the working script, but it should be fairly easy to troubleshoot if it is not the right one, it is a very simple script.

Last edited by skyl4rk; 10-10-10 at 02:34 PM..
skyl4rk is offline   Reply With Quote
Old 10-10-10, 03:50 PM   #3
knowbodies
Home Improvement Goon
 
Join Date: Oct 2008
Location: Moose Jaw, SK, CA
Posts: 96
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I'm a geek and all, and I love hacking stuff but wouldn't a line voltage thermostat for a walk-in cooler have been a lot simpler?
knowbodies is offline   Reply With Quote
Old 10-10-10, 07:09 PM   #4
skyl4rk
Helper EcoRenovator
 
Join Date: Sep 2010
Posts: 66
Thanks: 3
Thanked 6 Times in 4 Posts
Default

Yes, that would be much easier. But that gets you no mad scientist points.
skyl4rk is offline   Reply With Quote
Old 10-11-10, 12:44 AM   #5
Clev
Wannabe greenie
 
Join Date: Sep 2008
Location: Crestline, CA
Posts: 74
Thanks: 1
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by knowbodies View Post
I'm a geek and all, and I love hacking stuff but wouldn't a line voltage thermostat for a walk-in cooler have been a lot simpler?
A walk-in cooler thermostat can't tweet its status.

Tweet Library for Arduino
Clev is offline   Reply With Quote
Old 10-14-10, 08:58 PM   #6
skyl4rk
Helper EcoRenovator
 
Join Date: Sep 2010
Posts: 66
Thanks: 3
Thanked 6 Times in 4 Posts
Default

Here is a kit for a thermostat. It is not cheap but the schematic is available on this page:

:: Mikey Sklar :: Holy Scrap ::

skyl4rk is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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 04:22 AM.


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