ESP32 S3 - LM35 Temperature Sensor

Learn how to connect an LM35 temperature sensor to your ESP32 S3 and read analog temperature data in both Celsius and Fahrenheit. This beginner-friendly tutorial walks you through everything from wiring to writing Arduino code and viewing live readings in the Serial Monitor.

What you'll build:

  1. A circuit connecting the LM35 analog temperature sensor to your ESP32 S3
  2. Arduino code that reads the ADC voltage and converts it to degrees Celsius and Fahrenheit
  3. Serial Monitor output showing live temperature readings in real time
  4. A foundation you can extend into data loggers, fan controllers, or wireless temperature monitors
ESP32 S3 - LM35 Temperature Sensor

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×Alternatively, ESP32 S3 SuperMini Dev Module
1×Alternatively, ESP32 S3 Uno-form Board
1×Alternatively, ESP32 S3 Camera Board
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×LM35 Temperature Sensor
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack
1×Recommended: Screw Terminal Expansion Board for ESP32 S3
1×Recommended: Breakout Expansion Board for ESP32 S3
1×Recommended: Power Splitter for ESP32 S3

Or you can buy the following kits:

1×DIYables ESP32 S3 Starter Kit (ESP32 S3 included)
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.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of LM35 Temperature Sensor

The LM35 is a precision analog temperature sensor that outputs a voltage linearly proportional to temperature in degrees Celsius, making it one of the simplest sensors to interface with a microcontroller's ADC. It requires no external calibration, operates from a wide supply voltage range, and produces a clean output that the ESP32 S3's ADC can read directly.

Key Specifications

  • Output scale factor: 10 mV/°C (e.g., 250 mV at 25°C)
  • Temperature range: -55°C to +150°C
  • Supply voltage: 4V to 30V
  • Accuracy: ±0.5°C typical at room temperature
  • Output impedance: low — suitable for long cable runs to the ADC
  • No external calibration required

LM35 Temperature Sensor Pinout

The LM35 comes in a TO-92 transistor-style package and exposes three pins for straightforward wiring.

  1. VCC pin: Connect to power supply (5V recommended for best accuracy)
  2. GND pin: Connect to ground (0V)
  3. OUT pin: Analog output voltage proportional to temperature — connect to an ADC-capable GPIO on the ESP32 S3
LM35 temperature sensor Pinout

How LM35 Temperature Sensor Works

The LM35 outputs voltage in linear proportion to the Celsius temperature using a fixed scale factor of 10 mV per degree Celsius. By reading the voltage on the OUT pin with the ESP32 S3's ADC and applying the conversion formula, you can calculate the exact temperature in real time.

Wiring Diagram

Connect your LM35 temperature sensor to the ESP32 S3 following the diagram below. The sensor's OUT pin connects to any ADC-capable GPIO so the ESP32 S3 can sample the analog voltage and convert it to a temperature reading.

Safety Notes

Power the LM35 from the 5V pin on the ESP32 S3 to maximize the sensor's output swing and improve measurement accuracy, since the full-scale output at 150°C is 1.5V — well within the ESP32 S3's 3.3V ADC input range. Avoid routing the sensor's OUT wire near high-frequency signals, as the LM35's output is a low-level analog signal that can pick up noise and cause inaccurate readings.

The wiring diagram with power supply from USB cable:

The wiring diagram between ESP32 S3 LM35 temperature sensor

This image is created using Fritzing. Click to enlarge image

The wiring diagram with power supply from 5V adapter:

The wiring diagram between ESP32 S3 LM35 temperature sensor

This image is created using Fritzing. Click to enlarge image

LM35 Pin ESP32 S3 Pin
VCC 5V
GND GND
OUT GPIO4 (or any ADC-capable GPIO)

ESP32 S3 Code

The following code reads the analog voltage from the LM35 OUT pin using the ESP32 S3's ADC, converts it to a temperature in Celsius using the 10 mV/°C scale factor, and then derives the Fahrenheit equivalent before printing both to the Serial Monitor. The ADC reference voltage on the ESP32 S3 is 3.3V over a 12-bit range (0–4095), so the conversion math accounts for this when computing the actual voltage at the sensor output.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-lm35-temperature-sensor */ /* * This ESP32-S3 code is created by esp32io.com * * This ESP32-S3 code is released in the public domain * * For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-s3-lm35-temperature-sensor */ #define ADC_VREF_mV 3300.0 // in millivolt #define ADC_RESOLUTION 4096.0 #define PIN_LM35 4 // ESP32-S3 pin GPIO4 (ADC1_CH3) connected to LM35 void setup() { Serial.begin(9600); // set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); } 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 tempC = milliVolt / 10; // convert the °C to °F float tempF = tempC * 9 / 5 + 32; // print the temperature in the Serial Monitor: Serial.print("Temperature: "); Serial.print(tempC); // print the temperature in °C Serial.print("°C"); Serial.print(" ~ "); // separator between °C and °F Serial.print(tempF); // print the temperature in °F Serial.println("°F"); delay(500); }

※ NOTE THAT:

This tutorial uses the analogRead() function to read values from an ADC (Analog-to-Digital Converter) connected to a LM35 sensor. The ESP32 S3 ADC is good for projects that do NOT need high accuracy. However, for projects that need precise measurements, please note:

  • The ESP32 S3 ADC is not perfectly accurate and might need calibration for correct results. Each ESP32 S3 board can be a bit different, so you need to calibrate the ADC for each individual board.
  • Calibration can be difficult, especially for beginners, and might not always give the exact results you want.

For projects that need high precision, consider using an external ADC (e.g ADS1115) with the ESP32 S3 or using an Arduino, which has a more reliable ADC. If you still want to calibrate the ESP32 S3 ADC, refer to ESP32 ADC Calibration Driver

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Connect the LM35 sensor to the ESP32 S3 as shown in the wiring diagram above.
  3. Connect the ESP32 S3 board to your computer using a USB Type-C cable.
  4. Open Arduino IDE on your computer.
  5. Select the correct ESP32 S3 board and COM port in Arduino IDE.
  6. Copy the code above and paste it into Arduino IDE.
  7. Click the Upload button in Arduino IDE to compile and upload the code to your ESP32 S3.
Arduino IDE Upload Code
  1. Open the Serial Monitor in Arduino IDE.
How to open serial monitor on Arduino IDE
  1. Set the baud rate to 115200 in the Serial Monitor.
  2. Observe the temperature readings updating in the Serial Monitor.
  3. Make the sensor colder or hotter — for example, hold the sensor in your hand or place it near an ice cup — and watch the readings change.
  4. Pro Tip: If your readings seem off by several degrees, check that the LM35 VCC is connected to 5V rather than 3.3V. Powering from 3.3V limits the output range and can cause the ADC to read inaccurate values near the top of the temperature scale.

Serial Monitor Output

Once you upload the code and open the Serial Monitor, you will see continuous temperature readings updating every second. The output below shows a typical session captured in 2026, starting at room temperature and rising gradually as the sensor warms up from handling.

∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-06-16 10:15:01] Temperature: 26.31°C ~ 79.36°F [2026-06-16 10:15:02] Temperature: 26.44°C ~ 79.59°F [2026-06-16 10:15:03] Temperature: 27.06°C ~ 80.71°F [2026-06-16 10:15:04] Temperature: 28.37°C ~ 83.07°F
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Applications and Project Ideas

The LM35's straightforward analog interface paired with the ESP32 S3's processing power and built-in Wi-Fi makes it suitable for a broad range of temperature sensing and automation projects.

  1. Home temperature monitor: Display room temperature on an OLED or LCD screen and log readings over time.
  2. Fan speed controller: Automatically increase or decrease a DC fan's speed based on the measured ambient temperature.
  3. Over-temperature alarm: Trigger a buzzer or relay when a machine or enclosure exceeds a safe temperature threshold.
  4. Data logger: Record temperature readings with timestamps to an SD card for trend analysis and reporting.
  5. Wi-Fi temperature dashboard: Send readings over the ESP32 S3's Wi-Fi to a web server or cloud service for remote monitoring.
  6. Smart greenhouse: Monitor air temperature in a greenhouse and automatically activate ventilation or heating as needed.

Video Tutorial

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

Challenge Yourself

Once your LM35 temperature sensor is working with the ESP32 S3, try these exercises to deepen your skills and extend the project.

  1. Beginner: Change the ADC pin used in the code to a different ADC-capable GPIO and verify the readings remain accurate.
  2. Beginner: Add an LED that lights up when the temperature rises above a defined threshold, such as 30°C.
  3. Intermediate: Display the live temperature reading on an OLED or LCD screen instead of the Serial Monitor.
  4. Intermediate: Send temperature readings over Wi-Fi using the ESP32 S3's wireless radio and display them on a simple web page.
  5. Advanced: Log temperature data with timestamps to an SD card and create a graph from the recorded data.
  6. Advanced: Build a closed-loop temperature controller that activates a fan or heater relay to maintain a target temperature automatically.

※ OUR MESSAGES

  • 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!