FriendlyARM Mini2440 + AREXX TL-500 temperature logger on Linux

Some notes on how to connect the AREXX TL-500 temperature logger system to Linux hosts. Example includes instructions for use with the FriendlyARM Mini2440 ARM9 development board.

As AREXX only provides Windows drivers for the TL-500, accessing it from Linux is not quite straightforward. The TL-500 does not use a generic transfer protocol like FTDI, so we are left with a plain and undocumented USB protocol.

Kornelius Rohmeyer analyzed the USB traffic and wrote up an usblib based example for accessing the TL-500 on Linux, read up on it here:

http://algorithm-forge.com/techblog/2010/01/linux-usb-driver-for-the-arexx-tl-500-part-ii/

Based on his work it was easy enough to write up a crude but usable data collecting program polling and logging TL-3TSN, TSN-33MN and TSN-TH70E temperature and humidity sensor values. Includes support for hot (un)plugging of the TL-500 as well as output formatting and timestamping.
$ wget http://m68k.org/ul/tl-500-0.7.tar.gz
$ tar xfvz tl-500-0.7.tar.gz
$ cd tl-500-0.7
$ make
gcc -Wall -g -c -o tl-500.o tl-500.c
gcc -lusb-1.0 -g -o tl-500 tl-500.o 
$ ./tl-500
Found AREXX TL-500 on USB bus.
2010-03-04 00:40:43 11600 3447 26.9 C
2010-03-04 00:41:13 11807 3431 26.8 C
2010-03-04 00:41:33 11639 3439 26.8 C
..
The diagnostics line goes to STDERR, the output format on STDOUT is:

yyyy-mm-dd hh:mm:ss <sensor id> <raw value> <temperature> C

The latest sample of each sensor is stored in /tmp/tv-500_<sensor id> files.

Use with the FriendlyARM Mini2440 board and the default qtopia linux installation requires crosscompiling and installing libusb 1.0. Example using the GNU Toolchain sgpp compiler.

Extract toolchain into /usr/src/mini2440/arm-2008q3 and set up the build environment.
$ TOOLCHAIN=/usr/src/mini2440/arm-2008q3
$ PATH=$PATH:$TOOLCHAIN/bin
$ CC='arm-none-linux-gnueabi-gcc -march=armv4t -mtune=arm920t'
$ CROSS_COMPILE=arm-none-linux-gnueabi-
$ export CC CROSS_COMPILE
Grab a copy of the usblib source, crosscompile and install the ARM library into toolchain.
$ tar xfv libusb-1.0.6.tar
$ cd libusb-1.0.6
$ ./configure --host arm-linux
$ make
$ cd libusb
$ cp libusb.h $TOOLCHAIN/arm-none-linux-gnueabi/libc/usr/include/
$ cp .libs/libusb-1.0.so $TOOLCHAIN/arm-none-linux-gnueabi/libc/armv4t/usr/lib/
Now rebuild tl-500 to crosscompile and copy the ARM binary along with the fresh libusb-1.0.so to the FriendlyARM board and you got yourself a nifty thermometer. The TL-3TSN and TSN-33MN sensors appear to be quite accurate and well calibrated for the price.

Combined with 3G connectivity for the board the logger data can be accessed over the net.

10 comments:

Kevin said...

Very cool! Any thoughts on developing code to graph the sensor history on a webserver?

Anonymous said...

RRDtool?
Just wanted to say this is great work.
I bought one of these thinking it would be a simple serial protocol and I'd have it up and running on my home router in no time. Wrong!
I guess I'm stuck using windows for while.

Steve

Anonymous said...

Do you know if the TL-300 uses the same protocol?

Sven said...

Humidity over 60% are calculated wrong. See my posting at http://www.arexx.com/forum/viewtopic.php?f=43&t=1324 (german).

Solution:

Instead of

0.6 + value * 0.03328

use this formula:

0.698847572766711 + 0.0322868348833273*value + 0.00000175838509577984*value*value - 0.000000000764068120532725*value*value*value

Yes, more complex, but seems to work good (at least MUCH better than the old one) for low and high values.

Bye

Sven

m68k said...

Thanks Sven, new formula now in http://m68k.org/ul/tl-500-0.5.tar.gz

Unknown said...

I'm getting a 404 when trying to download? Has the URL for tl-500-0.5.tar.gz changed? :(

Anonymous said...

Hm, Peter seems to be offline for about one month now ... I hope he's fine.

He developed the last versions on my dockstar mini pc. I think version 0.5 should be the same as the development version. It works very well. You can download it here:

http://www.stdio.de/tl-500-0.4b.tar.gz

Carsten

m68k said...

Update with a few small fixes and rrdtool example:

http://m68k.org/ul/tl-500-0.7.tar.gz

Unknown said...

Well m68k, your RRD perl script is no much more elegant than mine! I noticed you have a calibartion offset on your sensors. How are you calibrating them? I just put all my sensors in the same location, let them settle and then set the offset for each one as the difference from the mean temp of all sensors. Just wondering if you might have a better solution?

Martin Mares said...

When looking for a Linux driver for my Arexx data logger, I missed your site, so I have written my own daemon. It is available on ftp://atrey.karlin.mff.cuni.cz/pub/local/mj/linux/arexxd-1.0.tar.gz if anybody is interested.

I think I have a more complete description of the protocol, which includes clock synchronization and transfer of multiple data points per packet.

Also, I use somewhat different formulae for conversion of raw values of RH%. Mine are based on the coefficients in the original Windows program (there is a XML file which defines the conversions).