Dual Digital Thermometer

Based on PIC16F877 and DS1820

A simple thermometer using DS1820 thermal probes that have a tolerance within 0.5°C.

I originally wanted a thermometer to monitor temperatures on my over clocked Video Card. Below are some pictures, schematic and PCB layout for the thermometer. The code I used wasn’t written by me. It was downloaded from http://www.warburtech.com/compilers/picbasic.pro/sample.code.htm (labeled “onewire.bas” near the bottom) and modified to display 2 temperatures instead of one temperature in Celsius and Fahrenheit. Some of the ports were also changed.`Here is the modified code:

trisc = %11111111
temperature VAR	WORD			' Temperature storage
count_remain VAR BYTE			' Count remaining
count_per_c VAR	BYTE			' Count per degree C

DQ	VAR	PORTC.0			' One-wire data pin
DQ1	VAR	PORTC.1

' Define LCD registers and bits
DEFINE	LCD_DREG	PORTD
DEFINE	LCD_DBIT	4
DEFINE	LCD_RSREG	PORTE
DEFINE	LCD_RSBIT	0
DEFINE	LCD_EREG	PORTE
DEFINE	LCD_EBIT	1

	ADCON1 = 7			' Set PORTA and PORTE to digital
	Low PORTE.2			' LCD R/W line low (W)

mainloop: OWOut DQ, 1, [$CC, $44]       ' Start temperature conversion
          OWOut DQ1, 1, [$CC, $44]
waitloop: OWIn DQ, 4, [count_remain]	' Check for still busy converting
          OWIn DQ1, 4, [count_remain]
	IF count_remain = 0 Then waitloop

	OWOut DQ, 1, [$CC, $BE]		' Read the temperature
        OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]

	' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)
	temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
	LCDOut $fe, 1, DEC (temperature / 100), ".", DEC2 temperature, %11011111, "C"

  	OWOut DQ1, 1, [$CC, $BE]		' Read the temperature
        OWIn DQ1, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]

	' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)
	temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
	LCDOut $fe, $c0 , " ",DEC (temperature / 100), ".", DEC2 temperature, %11011111, "C"

        Pause 1000                      ' Display about once a second

	GoTo mainloop			' Do it forever

Here is the code as download and the Circuitmaker200 PCB as download.

This is my thermometer with the LCD un-socketed. The three holes seen to the left of the 14pin SIP are for a potentiometer if the display you use requires a contrast control. My display did not have this function so I did not have to put a potentiometer on it. However all the connections are there, so if you need a pot for your display one just needs to be soldered in.

This is the picture again of the Thermometer without the display in place. This shot shows how the thermal probes and power are connected.

Here is the display running with probe 1 sitting next to it monitoring ambient house temperature, and the second probe left in the fridge for a couple minutes.

Copyright 2006 Barret R. de Visser

5 thoughts on “Dual Digital Thermometer

Leave a Reply

Your email address will not be published. Required fields are marked *