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 (2SA10152S90152N3906 …)
  • 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

4 thoughts on “Interfacing Arduino with LM35 sensor and 7-segment display”

  1. Roméo Fabrice DONGMO

    Please sir, I don’t understand what this line does. Could you please help with some explanations? Line 70 current_digit = (current_digit % 3) + 1;

    1. That’s because we have 3 digits and each time only one digit is turned ON, others are OFF. The MCU starts with the first digit (when current_digit equals to 1) and then 2nd digit (current_digit = 2) and then it turns ON the 3rd digit (current_digit = 3), after it rolls over to the first digit.
      The % symbol is just division operation reminder.

  2. Hola tengo problema con el circuito lo montado pero en el display la temperatura no marca bien , esta siempre cambiando mide cosas raras no se estabiliza , porque puede ser

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