vernier: Sat Nov 17 03:39:00 2007

Sat Nov 17 03:39:00 2007

Picked up a Vernier GoTemp, a $40 USB temperature probe designed for the science education market (there are bulk discounts, and courseware examples on their site) with an eye towards having the Chumby record and forward local temperatures to a central logging and analysis server (I'm still looking for ideas and/or solutions for that part - the popular first guess, rrdtool, isn't really the right answer for accumulating long-baseline data...)

Turns out to be a quite solidly-made device, ie. "will survive extensive student use" rather than just "cheap enough for schools to afford". I'm pleased, given the extent to which I bang things around :-)

It is recognized under Linux via the LDUSB driver, and it looks like that's enough to read packets from it; turns out that an 8-byte read (from /dev/ldusb0) gets you a one-byte sample count, a one-byte sequence number, and three two-byte little-endian temperature samples which appear to be 100ths of a degree celsius EDIT 128ths! see later post. It appears to generate around 2.5 samples per second, which is probably overkill. gotemp-ldusb.py has the terribly simple code.

One can also talk to it with pyusb as well (0.3.5-4 from Ubuntu Gutsy), and I started with the code I used for the Foam Rocket Launcher; the only real issues were that detachKernelDriver caused an error if LDUSB was already detached by a previous run of the script, and that if I read too soon, interruptRead would raise usb.USBError: No error. On the positive side, this path gets consistent zero values for unused sample slots (there is space for three samples in every packet, but the leading count tells you how many of them are actually supplied), where the LDUSB path appears to leak values from the previous packet; as far as getting samples out goes, this doesn't matter at all, since you've got to go by the sample count, not the value, anyway. gotemp-pyusb.py

The LDUSB approach probably has the edge, in that one can configure udev to make the device accessible, where as the direct usb driver needs root. pyusb might be more useful in distinguishing among multiple probes on the same machine, based on USB topology, but /sys/class/usb/ldusb0 appears to have equivalent information.

Amusingly, a good source of information on talking to this probe from Linux was Greg Kroah-Hartman himself - at the 2005 Ottawa Linux Symposium, he gave a "Write a Real Linux Driver" tutorial, and used the GoTemp as the example hardware, providing a single "temperature now" value from it. (It's not really worth the trouble for my application, it still layers on top of LDUSB after all - but it's an excellent skeleton for figuring out what the USB pieces are all about.)

Footnotes: