Thu
May 3

A simple DS18B20-based temperature logger

Update: Made temperature readings asynchronous and put the code on Github.

I recently made a little temperature logger, based on the DS18B20 temperature sensor and the Minimus AVR USB v1. This is a super cheap device: you can get DS18B20s for under £2 on eBay, probably cheaper in bulk, and my Minimus V1 was £2.50.

Hex file: logger.hex
Source code: logger.tar.gz

To set it up, get the hex file onto your Minimus. I use dfu-programmer: put the device into DFU mode by pressing reset, pressing the button that isn't reset, releasing reset, and then releasing the other button; then run dfu-programmer at90usb162 flash logger.hex.

Connect the DS18B20: the data line should go into PORTD6. Connect power and ground lines appropriately.

To start logging, reset the device (if it's in DFU mode), then press the hardware button. The blue light will start flashing to indicate that it's recording. Memory is full when the blue light is solid.

When connected to a computer, the device presents a USB serial interface. Connect to it at 57600 bps, and press ? to see a menu. Most importantly, buttons 1 to 9 will change the recording frequency, and 'd' will show the data.

The device logs to its internal EEPROM, which is quite small (1024 bytes). At the default logging frequency of once every 15 seconds, you get almost four and a half hours of recording. (One byte per measurement, 4 bytes used for EEPROM header).

Update: If you check out the Github repo and compile the code, you can instead choose to log to a 24Cxxx series external EEPROM. Connect the EEPROM so that A0=A1=A2=GND (ie, it is device 0 on the bus), connect the data line to PD1, and connect the clock line to PD0 -- or edit logger.c (for the device number) or i2cmaster.S (for the ports). If you do this, you'll want to change MAX_EEPROM_LOCATION in logger.c: it is currently set up for a 24C128 (i.e., 16 kilobytes of EEPROM).

It would be better to have the device show up as a USB mass storage device (i.e. a disk) rather than a USB serial port. I might work on that later.

Thanks to: the LUFA USB stack; the DS18x20 interface library; Peter Fleury's I2C bitbang interface.

All my code is in the public domain. Email me with any questions.