Arduino Nano ESP32 - LM35 Temperature Sensor

This tutorial provides instructions on how to use Arduino Nano ESP32 to read temperature value from LM35 temperature sensor, and print it to Serial Monitor.

Hardware Preparation

1×Arduino Nano ESP32
1×USB Cable Type-C
1×LM35 Temperature Sensor
1×Jumper Wires
1×(Optional) DC Power Jack
1×(Recommended) Screw Terminal Adapter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you. We appreciate your support.

Overview of LM35 Temperature Sensor

LM35 Temperature Sensor Pinout

LM35 temperature sensor has three pins:

  • VCC pin: connect this pin to VCC (3.3V)
  • GND pin: connect this pin to GND (0V)
  • OUT pin: This pin outputs voltage in proportion to the temperature value.
LM35 temperature sensor Pinout

How LM35 Temperature Sensor Works

The LM35 sensor outputs the voltage in linearly proportion to the Celsius temperature. The output scale factor of the LM35 is 10 mV/°C. By measuring the voltage on the LM32's OUT pin, we can calculate the temperature value.

Wiring Diagram between LM35 Temperature Sensor and Arduino Nano ESP32

The wiring diagram between Arduino Nano ESP32 and LM35 temperature sensor

This image is created using Fritzing. Click to enlarge image

Arduino Nano ESP32 Code

/* * This Arduino Nano ESP32 code was developed by * * This Arduino Nano ESP32 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * */ #define ADC_VREF_mV 3300.0 // in millivolt #define ADC_RESOLUTION 4096.0 #define PIN_LM35 A0 // The Arduino Nano ESP32 pin connected to LM35 void setup() { Serial.begin(9600); } void loop() { // read the ADC value from the temperature sensor int adcVal = analogRead(PIN_LM35); // convert the ADC value to voltage in millivolt float milliVolt = adcVal * (ADC_VREF_mV / ADC_RESOLUTION); // convert the voltage to the temperature in °C float temperature_C = milliVolt / 10; // convert the °C to °F float temperature_F = temperature_C * 9 / 5 + 32; // print the temperature in the Serial Monitor: Serial.print("Temperature: "); Serial.print(temperature_C); // print the temperature in °C Serial.print("°C"); Serial.print(" ~ "); // separator between °C and °F Serial.print(temperature_F); // print the temperature in °F Serial.println("°F"); delay(500); }

Detailed Instructions

  • If this is the first time you use Arduino Nano ESP32, see how to setup environment for Arduino Nano ESP32 on Arduino IDE.
  • Copy the above code and paste it to Arduino IDE.
  • Compile and upload code to Arduino Nano ESP32 board by clicking Upload button on Arduino IDE
  • Make the sensor colder or hotter. For example, putting the sensor near an ice cup
  • Check out the result on the Serial Monitor. It looks like the below:
Temperature: 26.31°C ~ 79.36°F Temperature: 26.44°C ~ 79.59°F Temperature: 26.50°C ~ 79.70°F Temperature: 26.56°C ~ 79.81°F Temperature: 27.06°C ~ 80.71°F Temperature: 27.75°C ~ 81.95°F Temperature: 28.37°C ~ 83.07°F Temperature: 29.00°C ~ 84.20°F Temperature: 29.56°C ~ 85.21°F Temperature: 30.00°C ~ 86.00°F Temperature: 30.31°C ~ 86.56°F Temperature: 30.62°C ~ 87.12°F Temperature: 30.87°C ~ 87.57°F
Autoscroll Show timestamp
Clear output
9600 baud  

Video Tutorial


  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!