Saturday, December 24, 2011

Dual PIC Thermometer


The geek inside me has always wanted a fridge that shows the inside temperature for both the freezer and the fridge compartments. However, when we recently replaced our very old fridge we ended up getting a new one without the built in thermometer. So I decided that one of my next projects would have to rectify this problem.
This dual thermometer can also be used to measure inside and outside temperatures at home.


Since all I wanted was to show two different temperatures, the circuit is very simple. It contains the temperature sensors, the display modules and a microcontroller to manage some simple tasks.
The microcontroller of choice was a PIC16F886 because I had used it for some experiments and wanted to build it into something. It has all the functions I needed, e.g. an internal oscillator to cut down on external parts needed, a timer for refreshing the display, enough digital I/O lines for connecting to two display modules without extra hardware.
The display modules are some common cathode 4 digit 7 segment ones. The advantage of these common cathode (or anode) modules is that they use less microcontroller I/O lines then ordinary 7 segment modules. The drawback is that the software is a little more complex since the displayed values must constantly be refreshed. At any given time there is only one digit displayed, all the others are off. Displaying 8 digits for 1ms each means that refreshing rate is about 8ms, or 125Hz. This is fast enough for the human eye to not see separate digits flashing but a constant set of characters.
Schematics of the dual thermometer

The temperature sensing part I used for this project is a high-precision 1-Wire digital thermometer chip from Dallas Semiconductors. There are a number of similar ones available; I used the DS1820 because I have a few of them left over from previous projects. This one uses the 1-Wire protocol to communicate with the PIC, doesn’t need any external components and it’s easy to be placed inside a fridge.
The 1-Wire protocol allows many 1-Wire devices to use the same data line but the software overhead is so high (at least in assembly) that I decided to use two separate lines for the two thermometers. This is not the most elegant thing to do but I didn’t find any assembly code on the internet I could steal borrow. Having two 1-Wire lines made my code a lot longer than it could be but this time I had plenty of program memory in the PIC. This chip provides the results of the measurements in Celsius format.
Of course, a mandatory ICSP header is also included on the board, just in case.
I tend to use as many SMD parts as I can to save on PCB size and make it look nicer. This time, however, the PIC I used is a TTH version because I had that already and wanted to use it up.


After connecting the circuit to power (>7.5VDC, a 7805 regulator is on board) first it does a display test for a few seconds then it starts normal operation. Temperature is measured about once per second.

At the moment the resolution of the temperature displayed is 0.5C. This can be further refined from software. I might do it in the future, but for now I am eager to get it in the fridge and the living room.


This time I decided to put the PCB behind a modified transparent photograph holder which I got for about half a euro in the local stationery store: First I cut off the rear part of the plexiglass (that normally would hold the photograph against the front one), then I drilled 4 holes into the front one and with the help of some long screws I mounted the circuit behind it.

Here you can see easily how I mounted the PCB on the back of the clear plexiglass.