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.