ESP32 S3 - Temperature Sensor - LCD

This tutorial shows you how to use the ESP32 S3 to read temperature data from a DS18B20 sensor and display it live on an LCD I2C 16x2 display. By combining two popular peripherals on a single board, you build a self-contained temperature monitor that requires no computer once programmed.

What you'll build:

  1. A circuit connecting the DS18B20 temperature sensor and LCD I2C to the ESP32 S3
  2. Arduino code that reads temperature and writes it to the LCD in real time
  3. A display that shows both Celsius and Fahrenheit values on separate lines
  4. A foundation you can extend into smart thermostats, data loggers, or environmental monitors

https://newbiely.com/images/cover/esp32-s3-temperature-sensor-lcd.jpg

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×LCD I2C Display 3.3V
1×Alternatively, LCD I2C 20x4
1×DS18B20 Temperature Sensor (WITH Adapter)
1×DS18B20 Temperature Sensor (WITHOUT Adapter)
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 .

Buy Note: Many DS18B20 sensors available in the market are unreliable. We strongly recommend buying the sensor from the DIYables brand using the link provided above. We tested it, and it worked reliably.

Buy Note: Most LCD I2C displays available on the market are 5V displays. They may work with this board, but it is unsafe and can damage the board. We strongly recommend using the 3.3V LCD I2C display recommended above.

Overview of Temperature Sensor and LCD

The DS18B20 temperature sensor and LCD I2C 16x2 are two of the most popular peripherals used with the ESP32 S3. The DS18B20 communicates over a single-wire 1-Wire bus and delivers accurate digital temperature readings, while the LCD I2C uses just two I2C lines to display characters on a 16-column by 2-row screen. Combining them creates a standalone temperature monitor that is both compact and easy to wire.

We have dedicated tutorials covering each component individually with detailed pinout information, wiring diagrams, and standalone code examples. Review them before starting this project if you are not yet familiar with either peripheral:

Key Specifications

The DS18B20 operates on 3.0V to 5.5V and is fully compatible with the ESP32 S3's 3.3V GPIO pins. It measures temperatures from -55°C to +125°C with ±0.5°C accuracy between -10°C and +85°C, communicating over a single data wire that supports multiple sensors in parallel. The LCD I2C 16x2 runs on 5V and communicates at the standard I2C address of 0x27 or 0x3F, providing a 16-column by 2-row display with adjustable contrast and a built-in backlight for clear reading in low-light conditions.

Wiring Diagram

Connect the DS18B20 temperature sensor and the LCD I2C display to your ESP32 S3 following the diagrams below. Both components share the same power and ground rails, so a breadboard makes the build straightforward. Use a DS18B20 adapter module with a built-in pull-up resistor to simplify wiring and avoid the need for a separate 4.7kΩ resistor.

Safety Notes

Power the DS18B20 from the ESP32 S3's 3.3V pin and power the LCD I2C from the VBUS (5V) pin — do not swap these, as applying 5V to the DS18B20 data pin without level shifting can cause damage. Always ensure the ground lines of both components are connected to the same GND on the ESP32 S3 to prevent floating references. If using the bare TO-92 DS18B20 package without an adapter, never omit the 4.7kΩ pull-up resistor between the DATA and VCC lines, as the 1-Wire protocol requires it.

Wiring diagram:

The wiring diagram between ESP32 S3 Temperature Sensor LCD

This image is created using Fritzing. Click to enlarge image

If the project will run for a long time, or sit inside a box, it is better to fix the wires with screws. Try a Screw Terminal Block for ESP32 S3: the ESP32 S3 sits on it, and each pin gets its own screw terminal. The wiring stays the same. Only the wires now go to the screw terminals, as shown below.

The wiring diagram between ESP32 S3 Temperature Sensor LCD Screw Terminal

This image is created using Fritzing. Click to enlarge image

You can also use a GPIO Breakout Board for ESP32 S3. It gives each GPIO its own S, 3.3V and GND pins, so module wires plug straight in:

The wiring diagram between ESP32 S3 Temperature Sensor LCD GPIO Breakout Board

This image is created using Fritzing. Click to enlarge image

DS18B20 Temperature Sensor connections:

DS18B20 Pin ESP32 S3 Pin
GND GND
VCC 3.3V
DATA GPIO1 (or any digital pin)

LCD I2C connections:

LCD I2C Pin ESP32 S3 Pin
VCC VBUS (5V)
GND GND
SCL GPIO9 (I2C Clock)
SDA GPIO8 (I2C Data)

ESP32 S3 Code

The following code reads temperature from the DS18B20 sensor using the DallasTemperature library and displays both Celsius and Fahrenheit values on the LCD I2C 16x2 display, updating once per second. It initializes the 1-Wire bus on the configured data pin, requests a conversion from the sensor, and then writes the formatted temperature strings to the LCD rows using the DIYables LCD I2C library. The DallasTemperature library handles all 1-Wire protocol communication, keeping your sketch readable and easy to modify.

/* * 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-temperature-sensor-lcd */ /* * 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-temperature-sensor-lcd */ #include <OneWire.h> #include <DallasTemperature.h> #include <DIYables_LCD_I2C.h> #define SENSOR_PIN 1 // ESP32-S3 pin GPIO1 connected to DS18B20 sensor's DQ pin OneWire oneWire(SENSOR_PIN); DallasTemperature DS18B20(&oneWire); DIYables_LCD_I2C lcd(0x27, 16, 2); // I2C address 0x27 (from DIYables LCD), 16 column and 2 rows float tempC; // temperature in Celsius float tempF; // temperature in Fahrenheit void setup() { DS18B20.begin(); // initialize the sensor lcd.init(); // initialize the lcd lcd.backlight(); // open the backlight } void loop() { DS18B20.requestTemperatures(); // send the command to get temperatures tempC = DS18B20.getTempCByIndex(0); // read temperature in Celsius tempF = tempC * 9 / 5 + 32; // convert Celsius to Fahrenheit lcd.clear(); lcd.setCursor(0, 0); // display position lcd.print(tempC); // display the temperature in Celsius lcd.print((char)223); // display ° character lcd.print("C"); lcd.setCursor(0, 1); // display position lcd.print(tempF); // display the temperature in Fahrenheit lcd.print((char)223); // display ° character lcd.print("F"); delay(500); }

※ NOTE THAT:

The LCD I2C address can be different from each manufacturer. In the code, we used address of 0x27 that is specified by DIYables manufacturer. If your LCD doesn't display anything, try address 0x3F instead.

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Open Library Manager: Click the Libraries icon on the left sidebar of Arduino IDE.
  3. Install DallasTemperature: Type "DallasTemperature" in the search box, find the library by Miles Burton, and click Install.
  • Search for DallasTemperature created by Miles Burton , Tim Newsome , Guil Barros , Rob Tillaart and click the Install button.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Library Manager
Type:
All
Topic:
All
DallasTemperature by Miles Burton , Tim Newsome , Guil Barros , Rob Tillaart
Supports DS18B20, DS18S20, DS1822, DS1820 More info
3.9.0
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32S3 Dev Module on COM15
1
  1. Install dependency: When prompted, click Install All to also install the required OneWire library.
ESP32 S3 onewire library
  1. Install DIYables LCD I2C library: Type "DIYables LCD I2C" in the search box, find the DIYables_LCD_I2C library by DIYables, and click Install.
  • Search for DIYables LCD I2C created by DIYables.io and click the Install button.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Library Manager
Type:
All
Topic:
All
DIYables LCD I2C by DIYables.io
This library is designed for HD44780-based I2C LCD displays. It provides LiquidCrystal-compatible API plus helper functions (text alignment, progress bars, predefined custom characters). Supports multiple I2C buses (Wire, Wire1, Wire2) for advanced boards like Arduino Giga, Due, and ESP32. Compatible with all Arduino-based platforms including Arduino Uno, Mega, Nano, ESP32, ESP8266, STM32, and Raspberry Pi Pico. More info
1.0.0
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32S3 Dev Module on COM15
1
  1. Wire the components: Follow the wiring diagram above to connect both the DS18B20 sensor and the LCD I2C to your ESP32 S3.
  2. Connect your board: Plug the ESP32 S3 into your computer using a USB Type-C cable.
  3. Select your board: In Arduino IDE, choose the ESP32 S3 board and the correct COM port.
  4. Upload the code: Copy the code above, paste it into Arduino IDE, and click the Upload button.
  5. View the LCD: The display will show the current temperature in Celsius on the top row and Fahrenheit on the bottom row, updating every second.
  6. Test the sensor: Hold the DS18B20 probe in your hand or place it in warm or cold water to see the readings change on the LCD.
  7. Pro Tip: If the LCD shows nothing at all, adjust the small contrast potentiometer on the back of the LCD module — turning it slightly is often all that is needed to make the text visible.

Serial Monitor Output

Once you upload the code and open the Serial Monitor at 115200 baud, you will see temperature readings printed every second alongside what is displayed on the LCD. The output below shows a typical session as the sensor warms up from room temperature.

∞
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-03-10 14:22:01] Temperature: 23.12°C / 73.62°F [2026-03-10 14:22:02] Temperature: 23.18°C / 73.72°F [2026-03-10 14:22:03] Temperature: 23.31°C / 73.96°F [2026-03-10 14:22:04] Temperature: 23.44°C / 74.19°F
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Applications and Project Ideas

Combining a temperature sensor and an LCD display with the ESP32 S3 opens the door to a wide variety of practical and educational projects.

  1. Home thermometer: Display indoor temperature on the LCD so you always have a quick reading without opening a phone app.
  2. Aquarium monitor: Place a waterproof DS18B20 probe in a fish tank and show water temperature on an LCD mounted outside the tank.
  3. Smart thermostat: Read temperature on the LCD and trigger a relay to switch a heater or fan on and off based on set-point thresholds.
  4. Greenhouse controller: Monitor growing-space temperature and display alerts on the LCD when values go outside safe ranges for your plants.
  5. Server room monitor: Mount the sensor and display in a rack to show ambient temperature at a glance without accessing a network dashboard.
  6. Food storage tracker: Keep an eye on refrigerator or freezer temperatures with a visible LCD readout and audible buzzer alert for unsafe values.

Video Tutorial

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

Challenge Yourself

Once your temperature sensor and LCD are working together, these challenges will push your ESP32 S3 skills further with progressively more complex tasks.

  1. Beginner: Add a second DS18B20 sensor and display both readings simultaneously — one on each row of the LCD.
  2. Beginner: Show a warning message on the LCD when the temperature rises above a threshold you define in the code.
  3. Intermediate: Add a push button that toggles the LCD display between Celsius-only and Fahrenheit-only modes when pressed.
  4. Intermediate: Log temperature readings with timestamps to the Serial Monitor every minute while the LCD shows a live reading every second.
  5. Advanced: Build a web server on the ESP32 S3 that serves a real-time temperature graph accessible from any browser on your local network, with the LCD showing the current value locally.
  6. Advanced: Add an RTC module so the LCD displays both the current time and temperature, and log data with timestamps to an SD card for long-term analysis.

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