## Low cost data logging with Arduino

I’ve been wanting to play around with an Arduino for a while, so I bought a Duemilanove without a set goal in mind. Recently I’ve been working with Solar thermal and I needed to measure several temperatures simultaneously so decided this would be as good a project as any. I bought some “4700 ohm” thermistors and hooked them up with some other 4700 ohm resistors in a voltage divider configuration. The output of which is hooked up to the analog inputs on the Arduino. I found a Thermistor Example in the Arduino playground which I had to modify somewhat to make work with my configuration. I was confused for about a day as to why my thermistor equation $T=\frac{\beta }{\ln \left ( \frac{R_{T}}{R_{25C}}\right )+\frac{\beta}{298.15}}-273.15$ was giving me garbage. After doubting my ablity to do math pretty severely I finally figured out that my math was indeed correct and as it turns out the “4700 ohm” thermistor package was incorrectly labeled and were actually only 470 ohm. Anyway, I modified the code so it would work with my thermistors and pass multiple temperatures back across the serial line.

Arduino Thermistor Sketch

Then I wrote some quick and dirty python code to read the values coming off the serial line and write it to a csv file which I could open with OpenOffice.

import serial
import time
ser = serial.Serial('/dev/tty.usbserial-A6008dxP', 9600, timeout=1)
logfile = open('test.csv', 'a')

while 1:   # read a '\n' terminated line
if not line:
break
words = line.split()
now = time.strftime("%d/%m/%Y %H:%M:%S", time.localtime())
a =  "%s, %s" % (now, line)
if line.find(',') != -1:
logfile.write(a)
logfile.flush()

logfile.close()
ser.close()


The resolution isn’t that great because the inputs are only a 10bit ADCs but it’s more than enough to get trends. Without a more accurate thermometer, I can’t tell for certain how accurate it is, but as far as I can tell it reads faster and more accurately than the mercury thermometer we have. In university I would have done this with a fairly expensive LabVIEW system. The impressive thing is that I can get good enough information for what I need with Python and less than \$30US in parts including the Arduino.