This is the software for

article07051: "A simple digital thermometer"

See http://tuxgraphics.org/electronics

I2C communication and temperature measurement with the Atmega8 microcontroller
with local LCD display and readout possibility from Linux via rs232 port

Copyright of all software and diagrams: Guido Socher
License: GPL V2
---------------------------------------------------------------------------

 All parts needed to build this litte thermometer can be ordered from 
 http://shop.tuxgraphics.org/                                          

To compile the Atmega8 software:
make 

To compile the Atmega8 software and download it to the Atmega8 use the command:
make load

To see a list of all possible build targets run the command:
make help


Building the I2C communication software
---------------------------------------
The "bin" sub-directory contains pre-compiled linux commands
for reading out this thermometer:

bin/i2c_rs232_pintest --  test (using a voltmeter) that the DTR and RTS 
                          lines of your rs232 port are working.

bin/i2ctemp_linux     -- read out the temperature values

bin/2ctalk_linux   -- a generic program to send any command over I2C

bin/i2ctempgui     -- a little gui wrapper for i2ctemp_linux (uses i2ctemp_linux)

You can also compile those commands with:
make linuxprgs


The i2ctemp_linux assumes by default that your thermometer is connected to
COM1 (/dev/ttyUSB0). You can change this with the option -p. Example:

> i2ctemp_linux -p /dev/ttyS0
In :i=19.8
Out:o=19.3

Note: If you have a avrusb500 programmer also connected then a PL2303 usb to 
rs232 converter may be at /dev/ttyUSB1. You can see what is connected where
by looking at kernel messages: dmesg | grep tty

Reading temperature values with MacOS, solaris or Windows
---------------------------------------------------------
There is no "i2ctemp_linux" equivalent for acOS, solaris or Windows
instead a generic i2ctalk program is provided. The commands
to read the temperature values are "i" for in-door temperature and
"o" for out-door temperature.

Thus:
i2ctalk i
and
i2ctalk o

The software is in the sub-directory other_OS

Using a USB to rs232 converter
------------------------------
For laptops which do these days not have a rs232 interface you can simply use
USB to rs232 adapter. I use e.g a no-name adapter which contains a Prolific 2303 chip.
It looks like this in the /proc/bus/usb/devices file:
Vendor=067b ProdID=2303 Rev= 2.02

The kernel module for this chip is called pl2303.

Makeing data available over the web
-----------------------------------
Never run i2ctemp_linux directly from the webserver. Instead add a contab entry
which runs a script to generate an appropriate webpage e.g every 15 minutes:

The script:
#!/bin/sh
webpagefile=/home/httpd/html/temp.html
echo "

Local temperatures

" > $webpagefile
i2ctemp_linux | sed -e 's/i=/inside  /;s/o=/outside /' >> $webpagefile
echo "
" >> $webpagefile Run the above script e.g from a crontab entry which looks like this (load a file containing this line with the command crontab): 1,15,30,45 * * * * /the/above/listed/scriptfile Calibrating the thermometer --------------------------- First of all you should note that this thermometer is already in unclibrate state more accurate than most household thermometers. If you get the right parts (e.g from shop.tuxgraphics.org) then you will already have an accuracy of +/- 0.5'C without any calibration. If you want to calibrate it then edit the file ntc.h Instructions on what to do are included. The recommended oprating range is: -30'C to + 45'C for the outdoor sensor and +10 to +45'C for the indoor sensor. The indoor sensor is more accurate than the outdoor because the ADC uses a smaller reference voltage. This limits the 0..1023 digital values of the ADC to a smaller range and gives thus higher accuracy (the disdvantage is that the indoor sensor can then not measure below 9'C, but it should not be soooo cold in your house ;-) Revision history ---------------- 2007-05-04: version I2Ctemp-20074-1.0 -- based on linuxI2Ctemp_lcd-0.6.tar.gz