• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Resource icon

PIC Single-Chip 4-Digit DS18x20 Temperature Monitor 2014-05-19

Here is a Digital Temperature Monitor project that uses a Maxim/Dallas 1-Wire® DS18S20 or DS18B20 temperature sensor attached to a simple 4-digit display board. The display board contains a PIC16F1828 micro controller, a miniature 4-digit red, green, yellow, white, or blue display available from Sparkfun, and just a few other parts.

The DS18S20 and DS18B20 sensors can measure temperatures in the range of -55° to 125° Celsius with accuracy to ±0.5°C over the range of -10°C to +85°C. Unlike analog temperature sensors that output a voltage proportional to temperature which must be translated using ADC (analog to digital conversion), the DS18S20 and DS18B20 produce a digital temperature value that can be read directly from the sensors via a bidirectional 1-Wire® bus.

The board powers up using the Celsius temperature scale but you can toggle between Celsius and Fahrenheit scales by pressing the Right Arrow key.

4-Digit #4.jpg


The circuit was built on a Radio Shack prototype board (sku 276-149) with a plastic coated paper silk-screen glued onto the component side of the board. I used 30 guage Kynar wire and point-to-point wiring on the copper side of the board.

The circuit does not include column/digit driver transistors and relies on the combined ~250 ohm RDS(ON) resistance of the PIC I/O pin high side and low side FET drivers for segment current limiting. The display is refreshed one segment at a time (1/32nd duty cycle) to provide even brightness across the entire display.

4-Digit Schematic #2.jpg

Parts List

1 ea. PIC16F1828-I/P (DIP package)
1 ea. 0.1-uf (100nf) ceramic capacitor
1 ea. 10 kOhm, 1/8th watt carbon film resistor
4 ea. 1N914 or 1N4148 silicon switching diode
1 ea. Sparkfun COM-09483 Red Common Anode 4-Digit Display
4 ea. generic momentary contact switch
1 ea. Soberton GT111P Piezo Speaker
1 ea. Maxim/Dallas DS18B20 (TO-92 package), or, DS18B20 Probe Kit (eBay)
Misc. sockets, connectors, prototype circuit board​


The HEX file in the ZIP file attachment can be used directly with a PICKIT2, PICKIT3, or similar device programmer to program the PIC16F1828. The program source file is also included in the ZIP file attachment. The program was written using the free/lite version of BoostC from Sourceboost and it uses 427 of the 4096 words of program memory available in the 16F1828.

The program configures the 16F1828 to run from the internal oscillator at 8-MHz. The Timer 2 module is used to generate 250-usec (500 cycle) interrupts and the ISR (interrupt service routine) refreshes one new segment of the display each interrupt (1/32nd duty cycle). All thirty two segments of the display are updated once every 8-msecs for a 125-Hz refresh rate.

Temperature data is collected from the temperature sensor about once per second in the main program loop. The program reads the sensors "family ID" byte (the first byte of the sensors eight byte ROM ID) to determine if the sensor is a DS1820 or DS18S20 (family ID 0x10) with 9-bit temperature data, or a DS18B20 (family ID 0x28) with 12-bit temperature data. The program automatically converts 9-bit temperature data (0.5° resolution) to the higher resolution 1/16° 12-bit format (0.0625° resolution) and then displays the temperature as a decimal value rounded to one decimal place.

Regards, Mike
Mike - K8LH
First release
Last update
0.00 star(s) 0 ratings

More resources from Mike - K8LH

Latest threads

EE World Online Articles