ESP32 S3 UNO - Temperature Sensor - LCD
This ESP32 S3 Uno temperature sensor LCD tutorial shows you how to build a small digital thermometer. The ESP32 S3 Uno form board reads a DS18B20 one-wire temperature sensor and shows the value on a 16x2 LCD I2C display. You see the temperature in both Celsius and Fahrenheit, updated twice per second.
In this tutorial, you will:
- Wire a DS18B20 temperature sensor and an LCD I2C to the ESP32 S3 Uno
- Install the DallasTemperature, OneWire and DIYables LCD I2C libraries in Arduino IDE
- Read the DS18B20 temperature in °C and convert it to °F
- Display the temperature on the LCD I2C screen

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
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
This project joins two parts that each have their own tutorial. If you have never used one of them, read its tutorial first. There you learn the pinout, how the part works, and the basic code.
- ESP32 S3 Uno - Temperature Sensor tutorial covers the DS18B20 sensor and the one-wire bus.
- ESP32 S3 Uno - LCD I2C tutorial covers the 16x2 LCD, its I2C address and how to print text.
The DS18B20 sends a digital value over a single data wire, so the ESP32 S3 Uno does not need its ADC here. The LCD only needs the two I2C lines, SDA and SCL.
ESP32 S3 Uno Pinout
The image below shows the pinout of the ESP32 S3 Uno form board. Use it to find the D2, SDA and SCL header pins and their GPIO numbers before you wire the circuit.

Wiring Diagram
The DS18B20 data pin goes to D2, and the LCD goes to the SDA and SCL header pins. Follow the diagram and the table below.

This image is created using Fritzing. Click to enlarge image
| Component Pin | ESP32 S3 Uno Pin |
|---|---|
| DS18B20 VCC | 3.3V |
| DS18B20 GND | GND |
| DS18B20 DQ (data) | D2 (GPIO18) |
| LCD VCC | 5V |
| LCD GND | GND |
| LCD SDA | SDA (GPIO8) |
| LCD SCL | SCL (GPIO9) |
If you use the DS18B20 without an adapter, add a 4.7 kΩ pull-up resistor between the DQ pin and 3.3V. The adapter module already has this resistor.
WARNING
The ESP32 S3 Uno pins work at 3.3V and are NOT 5V tolerant. Power the DS18B20 from 3.3V, so its pull-up keeps the data line at 3.3V. Many LCD I2C backpacks pull SDA and SCL up to their own 5V supply. To keep the board safe, pass SDA and SCL through a bidirectional 5V to 3.3V level converter, or remove the pull-up resistors on the LCD backpack.
※ NOTE THAT:
On the ESP32 S3 Uno, A4 and A5 are NOT I2C pins. Always wire the LCD to the SDA and SCL header pins.
ESP32 S3 Uno Code
The sketch asks the DS18B20 for a new reading every 500 ms. It reads the temperature in Celsius, converts it to Fahrenheit, then prints °C on the first LCD row and °F on the second row. The sensor data pin is set to GPIO18, which is the D2 header pin.
※ NOTE THAT:
The I2C address of an LCD can be different from one maker to another. The code uses 0x27, which is the address of the DIYables LCD. If your screen stays empty, scan for the address and change it in the code.
Detailed Instructions
Do these steps in order:
- New to the ESP32 S3 Uno? Follow ESP32 S3 Uno - Getting Started first.
- Wire it up as shown in the diagram.
- Connect the board to your computer with a USB Type-C cable.
- Open Arduino IDE, choose the ESP32S3 Dev Module board and the correct COM port.
- Open the Library Manager by clicking the Libraries icon on the left side of Arduino IDE.
- Install DallasTemperature: search for DallasTemperature, 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.
- Install the dependency: Arduino IDE asks to install the OneWire library too. Click Install All.
- Install the LCD library: search for DIYables LCD I2C, 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.
- Copy the code above and paste it into Arduino IDE.
- Upload the code by clicking the Upload button.

- Test it: hold the sensor in your hand, or put it in hot or cold water.
- Look at the LCD: the first row shows °C and the second row shows °F. The numbers change as the sensor warms up or cools down.
- Tip: if the LCD shows -127.00, the board cannot find the sensor. Check the DQ wire on D2 (GPIO18) and the pull-up resistor.
If the LCD shows nothing, read the Troubleshooting for LCD I2C.
Code Explanation
The comments in the code explain each line. In short, DS18B20.begin() starts the one-wire sensor, and lcd.init() with lcd.backlight() starts the screen. In the loop, requestTemperatures() starts a new reading and getTempCByIndex(0) gets the value from the first sensor on the bus. The code prints (char)223 to show the degree sign (°) on the LCD.
Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
FAQ
Can I power the DS18B20 from 3.3V on the ESP32 S3 Uno?
Yes. The DS18B20 works from 3.0V to 5.5V, so 3.3V is fine. Powering it from 3.3V is the safe choice, because the pull-up resistor then keeps the data line at 3.3V, which the ESP32 S3 Uno pins can handle.
Why is the LCD wired to SDA and SCL and not to A4 and A5?
On the UNO R4, A4 and A5 are the I2C pins. On the ESP32 S3 Uno they are only analog pins. I2C is on the separate SDA (GPIO8) and SCL (GPIO9) header pins, and Wire.begin() uses them by default.
Why does the LCD show -127.00?
The value -127 means the DallasTemperature library could not talk to the sensor. Usually the DQ wire is loose, it is on the wrong pin, or the 4.7 kΩ pull-up resistor is missing when you use the sensor without an adapter.
Can I use other pins for the DS18B20?
Yes. Any normal I/O pin works for a one-wire bus. Change SENSOR_PIN to the GPIO number, not the D label. For example, D7 is 14. Avoid D6 (GPIO3) and D9 (GPIO46), because they are boot strapping pins.
Can I connect more than one DS18B20 to the same pin?
Yes. All DS18B20 sensors can share one data wire. Read each one with getTempCByIndex(0), getTempCByIndex(1) and so on, then print them on the LCD rows.
What if my project needs more pins than the Uno headers give?
The ESP32 S3 Uno has two extra rows of holes with more GPIOs. GPIO15 and GPIO16 support I/O, PWM and analog. GPIO45 and GPIO35 to GPIO42 support I/O and PWM. GPIO47 and GPIO48 are output only, with PWM. Solder pin headers to use them and write the GPIO number in code. For an extra DS18B20 bus or a button, GPIO35 to GPIO42 are a good choice. Do not use GPIO47/GPIO48 for inputs. Be careful with two things. First, GPIO47 and GPIO48 may run at 1.8V instead of 3.3V on some modules (especially ones with "V" in the name, like R8V or R16V), so 3.3V devices can be damaged or act strangely. Second, GPIO0, GPIO3 (D6), GPIO45 and GPIO46 (D9) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code. Use the other extra pins first.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port in Arduino IDE | USB driver is missing or the board is not in upload mode | Install the CP210x or CH340 driver, or hold BOOT while pressing RESET |
| LCD shows nothing at all | LCD not powered, or SDA/SCL wired to A4/A5 | Power the LCD from 5V and wire SDA and SCL to the SDA (GPIO8) and SCL (GPIO9) header pins |
| LCD backlight is on but there is no text | Wrong I2C address or low contrast | Run an I2C scanner, set the right address in the code, and turn the contrast screw on the backpack |
| LCD shows -127.00 | The board cannot find the DS18B20 | Check the DQ wire on D2 (GPIO18), the GND wire, and the 4.7 kΩ pull-up resistor |
| LCD shows 85.00 all the time | The sensor gives its power-on value, often from weak power | Check the VCC and GND wires and power the sensor from 3.3V |
| Compile error about DallasTemperature.h or DIYables_LCD_I2C.h | A library is not installed | Install DallasTemperature, OneWire and DIYables_LCD_I2C from the Library Manager |
| Temperature looks wrong or jumps | Sensor is touching a warm part, or the wires are long and noisy | Keep the sensor away from the board and use shorter wires |