Digital Thermometer using PIC18F4550, Nokia 5110 LCD and DS18B20

This project shows how to make a simple digital thermometer using PIC18F4550 microcontroller and DS18B20 temperature sensor where temperature value is displayed on Nokia 5110 (Nokia 3310) graphical LCD which has a resolution of 84×48 pixel.
The compiler used in this project is CCS PIC C.

The DS18B20 temperature sensor is a 3-pin electronic component (like a simple transistor) from Maxim (formerly Dallas) which uses 1-wire protocol to communicate with master device (microprocessor, microcontroller ….). Each DS18B20 device has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-wire bus and controlled with one master device.
The DS18B20 sensor provides 9-bit to 12-bit Celsius temperature measurement resolution (programmable resolution).

To see how to interface the PIC18F4550 with the Nokia 5110 for the first time, visit the post below:
Interfacing PIC18F4550 MCU with NOKIA 5110 LCD

and the following project shows how to interface PIC18F4550 MCU with DS18B20 sensor and 16×2 LCD:
PIC18F4550 with DS18B20 sensor and LCD project

PIC18F4550 with DS18B20 temperature sensor and Nokia 5110 LCD

Hardware Required:

  • PIC18F4550 microcontroller
  • Nokia 5110 LCD screen
  • DS18B20 temperature sensor   —->   datasheet
  • 5 x 3.3k ohm resistor
  • AMS1117 3V3 voltage regulator
  • 10 uF capacitor
  • 100 nF ceramic capacitor
  • 5 x 2.2k ohm resistor
  • 4.7k ohm resistor
  • 5V power source
  • Breadboard
  • Jumper wires

PIC18F4550 MCU with DS18B20 sensor and Nokia 5110 LCD circuit:
The following image shows project circuit schematic diagram.

PIC18F4550 Nokia 5110 lcd DS18B20 temperature sensor circuit

All the grounded terminals are connected together.

The DS18B20 sensor has 3 pins (from left to right): GND, data pin and VCC (or VDD) where:
GND: connected to circuit ground (0V),
data pin: connected to PIC18F4550 RB2 (#35) and
VCC: sensor power supply pin, connected to circuit +5V.

A pull-up resistor of 4.7k ohm is required because the DS18B20 has an open drain output.

In this project the PIC18F4550 uses its internal oscillator and MCLR pin function is disabled.

PIC18F4550 MCU with DS18B20 sensor and Nokia 5110 LCD C code:
The C code below is for CCS C compiler, it was tested with version 5.051.

To be able to compile project C code, a driver for the Nokia 5110 LCD is required, download link is below. After you download the driver file which named NOKIA5110.c, add it to your project folder:
Nokia 5110 LCD driver for CCS C compiler

Connection of LCD reset, chip select and data/command pins are defined in the code as:

and the DS18B20 sensor data pin is defined as:

Functions used in the code:
int1 ds18b20_start(): used to know if the DS18B20 sensor is correctly connected to the circuit, returns 1 if OK and 0 if error.
ds18b20_write_bit(int1 value): writes (sends) 1 bit to the DS18B20 sensor, the bit is ‘value’ which may be 1 or 0.
ds18b20_write_byte(int8 value): writes 1 byte (8 bits) to the DS18B20 sensor, this function is based on the previous function. This function writes LSB first.
int1 ds18b20_read_bit(void): reads 1 bit from the DS18B20 sensor, returns the read value (1 or 0).
int8 ds18b20_read_byte(void): reads 1 byte from the DS18B20 sensor, this function is based on the previous function. This function reads LSB first.
int1 ds18b20_read(int16 *raw_temp_value): reads the temperature raw data which is 16-bit long (two 8-bit registers), the data is stored in the variable raw_temp_value, returns 1 if OK and 0 if error.

The value of the temperature in degree Celsius is equal to the raw value divided by 16 (in case of 12-bit resolution). The default resolution of the DS18B20 is 12 bits.

Note that 1/16 = 0.0625

Full CCS C code:

Proteus simulation of this project should give the same result as shown in the following video where Arduino UNO is used instead of the PIC18F4550 microcontroller:

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top