Android / iOS


Analog/Digital Thermometers

Posted: July 1, 2010


This is a dual project for reading the temperature from a DS18S20 1-Wire digital temperature sensor and an analog LM34 temperature sensor. Since the Atmel ATtiny2313 doesn't have A/D converters, I used this chip to read the DS18S20. For the analog I used the dsPIC30F3012. This is my first time using a dsPIC chip and my first time writing code for a microcontroller in C. I'm an assembly guy when it comes to hardware :).

Update: August 25, 2011 - I've been working on a new circuits using a DS18B20 temperature sensor /w MSP430's. I have a bluetooth thermometer and a talking clock thermomter along with some small sample programs the naken_asm page.

Related Projects

Thermometers: Thermometers, Clock Thermometer, Bluetooth Thermometer, MSP430 DCO, E-Ink Thermometer


DS18S20 and LM34 circuits

Top: DS18S20 digital temperature sensor with an Atmel ATtiny2313 microcontroller. The 2 BCD to 7 seg display show the current temperature in celcius.

Bottom: LM34 analog temperature sensor with a dsPIC30F3012 microcontroller. The 2 BCD to 7 seg display show the current temperature in Fahrenheit.

I soldered both circuits to look identical hole for hole except for the color of the 7 seg displays and microcontrollers and sensor circuit.


So basically both circuits read the temperature from their 3 pin sensors and display the data using MC14511 BCD to 7 seg display chips. For a minus sign I used a flat LED. The DS18S20 (which I believe is discontinued? SparkFun still sells the DS18B20 which should be 100% compatible as a part of the DS1820 family). I probably overkilled it pretty badly. I used a kind of state machine linked list of interrupt routines to bitbang to and from the 1-Wire bus. Probably I could have run it at 1MHz and used a bunch of NOP's or a tight loop to do the timings, which seem to not need to be that accurate for this chip.

The LM34 seems to be a pretty common chip. It outputs an analog voltage which represents the temperature in fahrenheit. I was originally going to convert it to celcius, but that would cause more precision loss on a 16 bit mpu, so I decided to leave it with the evil fahrenheit measurement.


Here is a newer circuit I made with a DS18B20, MSP430, and a bubble LED. I'll post a schematic and the code sometime later.

Thermometer schematic

Source code
thermometer.asm (DS18S20 / Atmel ATtiny2313)
thermometer.c (LM34 / dsPIC30F3012)

Copyright 1997-2018 - Michael Kohn