Friday, February 12, 2010

First Arduino Project!

I bought an Arduino a while back and haven't really done anything with it until today...

From Arduino Mug Heater Temp Gauge


Frustrated with working on my thesis I decided to implement and idea I had about an arduino project. I have a mug-heater that sits on my desk to keep my coffee warm when I forget about (nothing is worse than grabbing for a shot of coffee and coming back with an icy-cold bleh).

Well, actually, I one of those candle-warmer things that you use to make candles smell nice without burning them that I use as a coffee-warmer because Bed-Bath and Beyond did not have any mug-warmers when I went looking for one and the clerk said that he thought a candle-warmer would be fine. Generally it is, except that it takes a long time to heat up and it gets a little too hot for my liking...

So I decided that I would use a 10k thermistor, a tri-color LED and my Arduino to make a gauge that would tell me how hot the warmer plate is. Naturally I could have just left the arduino plugged in with the serial monitor up and paid attention to it to find out the temps from the thermistor - but if I can't remember that I have coffee, what do you think the chances are that I will remember to check an extra window?

Since the Arduino is open source and the Arduino community consists of generally awesome people who know MUCH more about all of this than I do I was able to find a great function that converts the resistance values from the thermistor into Fahrenheit temperatures. (Really, it's amazing, no look-up table, very lightweight and effective.) I then run the temp value through an 'if' statement and determine which of the three leads on the LED to light up. Blue is for temperatures below 90; green is for temperatures between 90 and 110; and red is for temps above 110.

Here are some photos:

Arduino Mug Heater Temp Gauge

Here is the code for the whole project:
The 'Thermistor' function was taken from: http://www.arduino.cc/playground/ComponentLib/Thermistor2
The rest I wrote myself - my apologies for the lack of comments.
#include

int RED = 2;
int GREEN = 3;
int BLUE = 4;

int THERM = 1;

double Thermistor(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15; // Convert Kelvin to Celcius
Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}

void setup() {
Serial.begin(300);
pinMode(RED,OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
}

void loop() {
Serial.println(Thermistor(analogRead(THERM))); // display Fahrenheit
delay(1000);
if (Thermistor(analogRead(THERM)) <>
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
digitalWrite(BLUE, HIGH);
}
else if (Thermistor(analogRead(THERM)) > 90 && Thermistor(analogRead(THERM)) <>
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
digitalWrite(GREEN, HIGH);
}
else {
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
digitalWrite(RED, HIGH);
}
}


No comments:

Post a Comment