Create a cheap PC thermometer with PS2/Gamepad Controller
16 years ago cheap, electronics, PC thermometer
You might be thinking what does this post have to do with vegetable gardening? Bear with me, I don’t have time to do a complete write up on it right now but letโs just say this is a component for “Project Everbearing” I gave my 7-year-old the honors of coming up with the codename, since he is my faithful assistant and cheerleader.
For my current project I need the ability to measure temperature with my PC. Now there are plenty of gadgets out there I could have simply purchased a commercial product for around $40+ and saved myself a lot of time but I really wanted to brush some dust off my soldering iron and try to save some cash, this is the CHEAP vegetable gardener after all.
After a little searching online seemed like a good place to start was to pick up a few thermoresistors which is a special type of resistor which increases resistance as the temperature increases. With no luck at my local RadioShack I picked up a few on EBay for less than $1 a piece.
Now comes the hard part of actually using them, since the computer I was using was old enough it still have an old 15-pin game port I went that route first. This would have been my easiest method of implementation by simply connecting the resistor to pin 1 and pin 3, since analog joysticks work with variable resistance as well. They use what is called a potentiometer which as the user moved the stick to left/right it raises/lowers the resistance. If this would have worked all that I would have needed to do is get the measurement and start calibration. Unfortinately this port was no longer responsive so I have to go with another option
Fortunately I never throw anything electrical out and pulled an old PS2 controller with an USB adapter out of my junk box. Knowing that the analog controllers also work with potentiometers, I found my victim. After removing the screws in the back I started warming up the old soldering iron to completely void the long gone warrantee on the controller. Now all I needed to do was attach two wires connected to the thermoresistors, solder the wires to the point connected to the potentiometer and that is pretty much did it. Given there are two sticks with X and Y axises for both you could have up to 4 temperature sensors (I chose to go with 2) The controller did does have one feature where it automatically turns off the analog control after no use for a couple minutes. After thinking about some more complicated solutions, I went low tech by forcing the L2 button to the on position by applying a piece of electrical tape over it.
I won’t go into the gritty details of the software to actually get the numbers from the joystick since M Harris has already done that so well on his CodeProject writeup.
Last comes calibration, when I purchased the thermoresistors they also included detailed specifications on the tested resistance values at various temperatures, which with a little bit of physics and some fun math, in theory I could have avoided the whole calibration but given the length of wire and/or my sloppy soldering could skew the accuracy of the temperatures I opted for a more manual approach. I put my “thermometer” in a plastic bag along with my trusty $5 digital thermometer and dropped it in an ice cold water bath, while recording the temperature changes as the temperature increased to room temperature. I followed this by doing the same with hot water bath until it lowered to room temperature, recording values as the temperature decreased.
With this data I entered it into Microsoft Excel and got a nice graph (see below) which gave my nice magic formula of:
Temperature = 0.0059(joystick X Axis position) – 138.57
By simply doing the math I now can capture values on my PC.
Tags: cheap, led, vegetables
16 years ago
Wow, I wish I was smart.
15.2 years ago
you said you, this can be used to measure the resistance of the soil moisture sensor.. how come? can you expain it to me..? thank you..
15.2 years ago
Freddie, check out this post for much more details and how to actually create a moisture sensor. The concept is pretty simple, material (in this case gypsum) cannot conduct electricity when dry (no path for electrons) and as you add moisture it becomes more conductive (less resistance) thus returning higher numbers.
15.2 years ago
yeah, i already made that gypsum block.. and i would like to record the values of the resistance of that soil moisture sensor e.q.950 ohms = wet5000 ohms = dryinfinity = dust.like that? i have a analog multitester here. but i would like to get the value view comp to compare the changes in resistance using graphs. thans mr cheap vegetable gardener for your response-sincerely yours,fred
15.2 years ago
i get it. thanks ๐
15 years ago
nice post!!! ๐
12 years ago
Nice solution, i’m surprised by the linearity of the curve actually!
11.9 years ago
[…] existing controller (PS2 Controller, parallel port with various wires to control relays) worked but was not exactly […]
11.9 years ago
[…] all that is needed was to solder these wires to a couple open points on my PS2 Controller which I am already using as a cheap temperature sensor The great thing about this implementation is the “resistor” has a broad range from no […]
11.9 years ago
[…] let your plants die or at least get watering back into your winter routine. Though I imagine with a PS2 Controller, handful of galvanized nails, some wire, and a little coding someone could put together a cheaper […]
11.6 years ago
[…] existing controller (PS2 Controller, parallel port with various wires to control relays) worked but was not exactly […]
10.9 years ago
[…] fan when it gets too hot.ย In order to allow the computer to know these temperatures I used a PS2 controller to create two temperature sensors one for the area the plants are growing and another for the top area where the CPU resides […]