CONTENTS

Home
Projects
  Electronics
  Graphics
  Java
  Java Mobile
  Android
  Other Stuff
Resume
Music
Pictures
Contact



Analog/Digital Thermometers

More electronics projects on mikekohn.net here.

July 1, 2010

Introduction

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 on my naken430asm page.

Pictures

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.

Explanation
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.

Schematic

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



Copyright 1997-2012 - Michael Kohn

This page was designed to work with all standard HTML compatible web browsers including Firefox, IE, Safari, and Links.