My radio shack is cupboard size and has a small fan heater in it which very quickly warms the space. But just how quickly…
![Heater](http://lh5.ggpht.com/-yYDQjEMt0lg/ThkuhB2X8XI/AAAAAAAAAKw/PSwSQfNZ5F0/heater.jpg?imgmax=800)
A while back I built a PIC based thermometer that reads a Maxim 1-wire temperature sensor and sends the readings out a serial port at 9600 baud.
![Device](http://lh6.ggpht.com/-jbfVyBcFYWc/ThkuRSCLs1I/AAAAAAAAAKs/h1a-JEPAIwE/device.jpg?imgmax=800)
USB serial cables seem to just work out of the box on linux these days:
![Serial port](http://lh6.ggpht.com/-Nk11GJXcL9U/ThkupaOz70I/AAAAAAAAAK0/y1If8WmjaKA/serial%252520port.jpg?imgmax=800)
A little bit of python using pyserial to read lines from the serial port and log them to a text file suitable for reading in to a spreadsheet.
#!/usr/bin/env python
"""Utility to log temperatures from a serial device.
"""
import serial
import time
LOGFILE = '/tmp/temperatures.txt'
ser = serial.Serial('/dev/ttyUSB0')
log = open(LOGFILE, "a")
line = ser.readline()
while line:
logline = "%s\t%s\n" % (time.ctime(),
line.split()[0])
log.write(logline)
log.flush()
line = ser.readline()
Here's a bit of the log file:
Sun Jul 10 14:31:07 2011 28.0
Sun Jul 10 14:31:09 2011 28.5
Sun Jul 10 14:31:11 2011 28.5
Sun Jul 10 14:31:13 2011 28.5
Sun Jul 10 14:31:15 2011 28.5
Sun Jul 10 14:31:17 2011 29.0
Here is the temperature in my shack from window close to toasty warm.
![Temperatures](http://lh4.ggpht.com/-TH2C8AHr0Iw/ThkvPYCFWdI/AAAAAAAAAK4/hHt3yLuw3v0/temperatures.png?imgmax=800)
No comments:
Post a Comment