Saturday, October 1, 2011

Arduino Based Computer Temp Sensing

The Problem

I bought a new graphics card for my computer recently, just to realize I didn’t have a power supply large enough to properly power the new card - causing it to overheat (temporarily, I opened the side of my computer and used a desk fan to cool it). After buying the correct power supply, I decided I needed some type of temperature indicator on my computer...Hello Arduino! (I actually used my Uno32 for this project, to view my review on it click HERE)

Now, this hack is very simple, versatile, and easy to implement. All you need is a general purpose temperature sensor, an RGB LED (or more if you want your computer to look really flashy), and some appropriate resistors so you don't blow up your LED. The Arduino fades an RGB LED from blue to red depending on the temp of your component. When it is over 50°C, the LED will be red. (50C is close to what most NVIDIA GFX cards can handle). I also have a processing sketch in progress to read the value of the temp sensor and store it into a .txt file, and a C++ program (in progress) to alert you when the .txt file says that your computer is too hot.


The Set-Up

Below is the schematic. I know that it isn’t standard, but it’s much easier to read for electronics beginners. I recommend giving yourself a pretty good length in wire so that you can attach the LED(s) wherever you need to. Also, HEAT SHRINK ANY VISIBLE METAL so that you don’t end up messing up your computer. Often, your computer will use the casing as a ground, so any visible wires would be really bad. 

Once you’re all soldered up and ready to go, you’ll want to attach the temp sensor wherever you think has a chance of overheating. To attach it I recommend using electrical tape, and just taping it down (If you have better ideas then let me know). Then put your LED anywhere you think will be easily visible. I recommend taping the wires down with electrical tape as well, or zip-tying it down. You then want to zip-tie all loose wires and attach them to the Arduino somewhere that you have free space. I recommend putting electrical tape on the bottom of the Arduino AND Velcro-ing it down, that way your Arduino doesn’t short, and it won’t move.
I was lucky enough to have a working USB port INSIDE my computer, so that I could leave my Arduino plugged in. The unlucky one’s out there will need to upload the code before they put it in and power it off of a battery, or find some way to get a programming cable inside of their case. After the Arduino code (below) is uploaded, everything should work fine. I set the default room temperature as 17C because that’s how it is in my boiling dorm- but that could easily be changed.
int bluepin = 5; int redpin = 6; int tempPin = A0; int blueout = 0; int redout = 0; float conv = 0.55555; //Wouldnt let me do 5/9 float tempC; int limitinC = 50; void setup() { Serial.begin(9600); pinMode(bluepin, OUTPUT); pinMode(redpin, OUTPUT); } void loop() { float tempVolts = (analogRead(tempPin) * .004882814); //Reads temp sensor and converts it to a voltage level float tempF = (tempVolts - .5) * 100; //Converts the voltage level into a temp(F) float tempC = (conv * (tempF - 32)); //Converts the temp into Celcius //Serial.print("tempC ="); //Commented out for testing //Serial.println(tempC); //Serial.print("tempF ="); //Serial.println(tempF);
float CelConstraint = (tempC - 15); //The average temp of my room in C (limiting the colors to be blue at 15 and red at 50) float CelCtoVal = (CelConstraint*29.68);//converts the value //Serial.print("CelCtoVal = "); //Commented out for testing //Serial.println(CelCtoVal); 
redout = CelCtoVal; blueout = ((512 - CelCtoVal) + 512) //Inverts the colors so 1024 = 0 and 0 = 1024 //redout = ((redout+CelCtoVal)/2); //Use these lines instead of the above if the sensor sometimes is flickering (averages the values) //blueout = ((((512 - CelCtoVal) + 512)+blueout)/2); //Serial.print("blueout ="); //Commented out for testing //Serial.println(blueout); //Serial.print("redout ="); //Serial.println(redout); analogWrite(bluepin, blueout); analogWrite(redpin, redout); if (tempC > limitinC){ Serial.print(1, BYTE); //Send 1 to Processing sketch if too hot delay(100); } else{ Serial.print(0, BYTE); //Send 0 to Processing sketch if cold delay(100); } }

Work In Progress

Below, I have a processing sketch that will read whether or not your Arduino is overheating and write a ‘1’ into a .txt file if it is. I also have a C++ program that will read that file. This is a work in progress. I just started to learn processing and only know very basic C. I hope eventually to make a program that will print the temp in C, F, and to pop-up when the temp is greater than a certain temperature.


Download Everything


Let me know how this works for you guys! If you have any comments/questions be sure to post below or tweet me!

4 comments:

  1. You shoot sparrow with cannon

    ReplyDelete
  2. i have had loads of gpu's that get well over 50°C i would say 80 is the bad point for gpu's and 70 is a max if you dont want your bios to turn off your p.c to stop damage. 50 would be great if you have water cooling! but for over clockers i would say higher than this?!

    ReplyDelete
  3. @ 'anonymous 5:45' ... WTF are you talking about? Mods are for fun, we don't care about 'cause', just 'effect' and the 'getting there'. Now, hitting a canon with a sparrow, that's modding. Go play with yer iPad friend.

    ReplyDelete
  4. I can help you out with C++ programming if you need it for file writes and reads. Just send me an email at "kamaljot.dhaliwal@gmail.com". I've been working with general C++ for about 3 years now

    ReplyDelete