Lilly, our leopard gecko, hasn’t been eating and the vet recommended we keep a sharp eye on the temperature in the enclosure, a 10-gallon glass fish tank. During the day, the temperature should range between 82°F and 92°F. At night, it shouldn’t dip below 70°F.
I could have purchased a little glass thermometer for the fish tank and taped it to the inside of the tank, but how much fun would it be to get up every half hour over a a day, or two, to record the temperature on a note pad?
Linux, like all other problems in the known and unknown universe, proved to be the solution.
Linux and Lilly
My presentation at OSCON next month couldn’t have come at a better time. It’ll cover using an Arduino to read a DS18B20 one-wire temperature sensor and transmit the data to my Linux notebook over a pair of Xbee 2.4 GHz transceiver modules.
In other words, I could use the system to track the temperature in Lilly’s tank.
So, I hooked everything up and put the Arduino, Xbee radio, and experimenter’s board next to the gecko tank. The temperature sensor wire was just long enough to reach the correct tank height.
The Arduino uses a bit of Processing code to poll the sensor about once every two seconds, then prints the temperature out to the serial line. The serial line is hooked up to one of the Xbee radios. The radio link acts as a wireless USB serial cable. At the notebook end, the second Xbee attaches to a TTL-232R-5.0V (USB to serial) cable, which plugs into one of my Asus Xubuntu notebook USB ports.
It’s a simple matter of opening a terminal and using cat to read the data from the USB line and dump it into a file. Quick and dirty.
rob% cat /dev/ttyUSB0 >> rob.txt &
The “&” symbol puts the command in the background, so if I inadvertently close the terminal, the data will continue to accumulate in the rob.txt file.
I use the tail command to show a running list of the temperatures. A real-time graphing program, like kst, can also suck data in from the rob.txt file and update the display continuously. Linux Journal Magazine posted my article on using kst with the Arduino, a while back.
Tweak here, tweak there
As it turned out, I had to make a few adjustments to the temperature in Lilly’s tank. The temperature was only hitting about 80° F, during the day. The 40-watt ceramic basking element was replaced with a 60 watt incandescent, turning the temperature range into an ideal 85°- 87° F. The light is also on a timer, turning on at 6:30 AM and switching off at 6:30 PM. Nighttime temperatures vary between 75° and 77° F.
I should note that the DS18B20 sensor is a precision chip with a pretty fast response time. If you breath on the thing, you can actually watch the temperature go up. For example, my central air-conditioning was cycling on and off, changing the temperature in Lilly’s tank by 1.5 degrees each time.
Linux saves the day again…
and Lilly, seems to be doing better, too.
- ”Hacking Together A Basic Remote Temperature Sensor Using An Arduino, Xbee Radios, And Linux” [Rob Reilly]
- Real-Time Plots with kst and a Microcontroller [Linux Journal]