Interfacing Arduino with LM35 sensor and 7-segment display

This topic shows how to make a simple temperature measurement station using Arduino UNO board and LM35 analog temperature sensor where temperature value is displayed on 3-digit 7-segment display.

The LM35 temperature sensor is a three pin device (VCC, OUT and GND) with an output voltage linearly related to Centigrade temperature. Since the LM35 output varies with dependent to the temperature, we need an ADC (Analog-to-Digital Converter) module to measure this voltage.

To see how to interface Arduino with 7-segment display visit the following post:
Interfacing Arduino with 7-segment display | 4-Digit counter example

Also for more details about the LM35 sensor and how to interface it with Arduino, see this project:
Arduino and LM35 temperature sensor interfacing

Hardware Required:

  • Arduino UNO board
  • 3-Digit (or 4-digit) common anode 7-segment display
  • LM35 temperature sensor   —->   datasheet
  • 3 x PNP transistor (2SA1015, 2S9015, 2N3906 …)
  • 8 x 100 ohm resistor
  • 3 x 4.7k ohm resistor
  • Breadboard
  • Jumper wires

Interfacing Arduino with LM35 sensor and 7-segment display circuit:
The image below shows project circuit schematic diagram.

Arduino with LM35 sensor and 7-segment display - LM35 7 segment

The LM35 sensor has 3 pins (from left to right):
Pin 1 is power supply pin, connected to Arduino 5V pin
Pin 2: output pin, connected to Arduino analog pin 0 (A0)
Pin 3: GND (ground), connected to Arduino GND pin.

The 3 transistors are of the same type (PNP).

Interfacing Arduino with LM35 sensor and 7-segment display code:
The Arduino code below doesn’t use any library for the 7-segment display.

Reading voltage quantity using the ADC gives a number between 0 and 1023 (10-bit resolution), 0V is represented by 0 and 1.1V is represented by 1023 (ADC positive reference is 1.1V) . Converting back the ADC digital value is easy, we can use the following equation:
Voltage (in Volts) = ADC reading * 1.1 / 1023
Multiplying the previous result by 100 (LM35 scale factor is 10mV/°C = 0.01V/°C) gives the actual temperature:
Temperature( °C) = ADC reading * 0.1075  , or
Temperature( °C) = ADC reading / 9.3
where: 0.1075 = 100 * 1.1 / 1023  and  9.3 = 1 / 0.1075
To use the internal 1.1V reference I used the command: analogReference(INTERNAL);

In this example I used one number after the decimal point, multiplying the temperature by 10 will remove the decimal point, so the final result is:

The decimal point is displayed on the screen before printing the last digit (most right) which means it displayed with digit 2.

Full Arduino code:

The following video shows Proteus simulation of this project (simulation circuit is not the same as real hardware circuit, example circuit diagram is shown above):

Proteus simulation file download:
Arduino + LM35 sensor + 7-segment display

Leave a Reply

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