ESP32 S3 - Temperature Sensor

Learn how to connect a DS18B20 temperature sensor to your ESP32 S3 and read accurate temperature data in both Celsius and Fahrenheit. This beginner-friendly tutorial walks you through everything from wiring to writing Arduino code.

What you'll build:

  1. A circuit connecting the DS18B20 sensor to your ESP32 S3
  2. Arduino code that reads temperature using the 1-Wire protocol
  3. Serial Monitor output showing live Celsius and Fahrenheit readings
  4. A foundation you can extend into weather stations, aquariums, or smart thermostats
ESP32 S3 - Temperature Sensor

Hardware Preparation

1×ESP32 S3 WROOM N16R8
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×DS18B20 Temperature Sensor (WITH Adapter)
1×DS18B20 Temperature Sensor (WITHOUT Adapter)
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack

Or you can buy the following kits:

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.

Overview of DS18B20 Temperature Sensor

The DS18B20 is a digital temperature sensor that communicates using the 1-Wire protocol, making it simple to integrate with the ESP32 S3 using just a single data pin. Its wide operating range, good accuracy, and support for multiple sensors on one wire make it a popular choice for environmental monitoring projects.

Key Specifications

The DS18B20 operates on 3.0V to 5.5V, which makes it fully compatible with the ESP32 S3's 3.3V GPIO pins. It measures temperatures from -55°C to +125°C (-67°F to +257°F) with an accuracy of ±0.5°C between -10°C and +85°C. Resolution is adjustable from 9-bit to 12-bit, and the sensor communicates over a single data wire — meaning you can chain multiple DS18B20 sensors on the same pin. A waterproof probe version is also available, making it suitable for liquid temperature measurement. Long cable runs of up to 100 meters are supported, which is useful for remote monitoring installations.

DS18B20 Temperature Sensor Pinout

The DS18B20 sensor comes in two common forms: a TO-92 transistor-like package and a waterproof probe version. Both expose the same three connections.

  1. GND pin: Connect to ground (0V)
  2. VCC pin: Connect to power supply (3.3V or 5V)
  3. DATA pin: 1-Wire data bus — connect to any digital pin on the ESP32 S3
DS18B20 temperature sensor Pinout

Traditional DS18B20 wiring requires a 4.7kΩ pull-up resistor between the DATA and VCC pins. Many DS18B20 adapter modules now include a built-in pull-up resistor and screw terminals, which simplifies wiring significantly. Using an adapter module is recommended for beginners.

Wiring Diagram

Connect your DS18B20 temperature sensor to the ESP32 S3 following the diagrams below. For beginners, using a DS18B20 adapter module with a built-in pull-up resistor is the easiest approach and reduces the chance of wiring errors.

Safety Notes

Always power the DS18B20 from the ESP32 S3's 3.3V pin rather than 5V unless you have confirmed your specific module is 5V-tolerant. Ensure your ground connections are solid — a floating ground is a common cause of -127°C error readings. If you are using the bare TO-92 package without an adapter, do not omit the 4.7kΩ pull-up resistor between DATA and VCC, as the 1-Wire protocol requires it for reliable communication.

Wiring with breadboard (without adapter):

The wiring diagram between ESP32 S3 Temperature Sensor

This image is created using Fritzing. Click to enlarge image

DS18B20 Pin ESP32 S3 Pin
GND GND
VCC 3.3V
DATA GPIO8 (or any digital pin)
Pull-up Resistor 4.7kΩ between DATA and VCC

Wiring with adapter module (recommended):

The wiring diagram between ESP32 S3 DS18B20

This image is created using Fritzing. Click to enlarge image

DS18B20 Module Pin ESP32 S3 Pin
GND (or -) GND
VCC (or +) 3.3V
DATA (or S) GPIO8 (or any digital pin)

For easier setup, purchase a DS18B20 sensor with a wiring adapter that includes the built-in resistor.

ESP32 S3 Code

The following code reads temperature data from the DS18B20 sensor using the DallasTemperature library and prints the results to the Serial Monitor every second. It initializes the 1-Wire bus on the configured data pin, requests a temperature conversion from the sensor, and then outputs the reading in both Celsius and Fahrenheit. The DallasTemperature library handles the low-level 1-Wire communication, so your sketch stays clean and readable.

/* * 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 */ #include <OneWire.h> #include <DallasTemperature.h> #define SENSOR_PIN 8 // The ESP32 S3 pin GPIO8 connected to DS18B20 sensor's DATA pin OneWire oneWire(SENSOR_PIN); DallasTemperature DS18B20(&oneWire); float temperature_C; // temperature in Celsius float temperature_F; // temperature in Fahrenheit void setup() { Serial.begin(115200); // Initialize the Serial to communicate with the Serial Monitor. DS18B20.begin(); // initialize the DS18B20 sensor } void loop() { DS18B20.requestTemperatures(); // send the command to get temperatures temperature_C = DS18B20.getTempCByIndex(0); // read temperature in °C temperature_F = temperature_C * 9 / 5 + 32; // convert °C to °F 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

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Install required libraries: Open Library Manager in Arduino IDE (click the library icon on the left sidebar).
  3. Search for DallasTemperature: Type "DallasTemperature" in the search box.
  4. Install the library: Find the DallasTemperature 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 OneWire library.
ESP32 S3 onewire library
  1. Wire the components: Follow the wiring diagram above to connect the DS18B20 sensor 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 ESP32 S3 and the correct COM port.
  4. Upload the code: Copy the code above, paste it into Arduino IDE, and click Upload.
  5. Open Serial Monitor: Set the baud rate to 115200 to view temperature readings.
  6. Test the sensor: Hold the DS18B20 probe in your hand to warm it up, or place it in hot or cold water to see temperature changes.
  7. Pro Tip: If readings show -127°C or 185°F, check your wiring connections — this almost always indicates a communication error with the sensor, often caused by a missing pull-up resistor or a loose DATA wire.

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 starting at room temperature and gradually rising as the sensor warms up.

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-01-15 09:12:01] Temperature: 23.12°C ~ 73.62°F [2026-01-15 09:12:02] Temperature: 23.18°C ~ 73.72°F [2026-01-15 09:12:03] Temperature: 23.25°C ~ 73.85°F [2026-01-15 09:12:04] Temperature: 23.31°C ~ 73.96°F
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Applications and Project Ideas

The DS18B20 temperature sensor paired with the ESP32 S3's Wi-Fi and processing power opens the door to a wide range of practical monitoring and automation projects.

  1. Home weather station: Monitor indoor and outdoor temperatures with wireless connectivity and log data to the cloud.
  2. Aquarium temperature monitor: Keep track of water temperature for fish tanks and trigger alerts if values drift out of range.
  3. Smart thermostat: Create an automated heating or cooling control system that responds to real-time sensor readings.
  4. Refrigerator monitor: Receive alerts when your fridge temperature goes out of the safe range.
  5. Greenhouse automation: Monitor and log temperature for optimal plant growth and trigger ventilation fans automatically.
  6. Server room monitoring: Track temperature in computer or server rooms with remote alerts sent via email or push notification.

Video Tutorial

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

Challenge Yourself

Once your temperature sensor is working, there are many directions you can take this project to deepen your ESP32 S3 skills.

  1. Beginner: Add an LED that turns on when the temperature exceeds a set threshold.
  2. Beginner: Display temperature data on an OLED screen instead of the Serial Monitor.
  3. Intermediate: Connect multiple DS18B20 sensors to one ESP32 S3 and read all of them simultaneously on the same data pin.
  4. Intermediate: Send temperature data to your smartphone over Wi-Fi using the ESP32 S3's built-in wireless radio.
  5. Advanced: Create a web server on the ESP32 S3 to display real-time temperature graphs accessible from any browser on your local network.
  6. Advanced: Log temperature data with timestamps to an SD card or cloud service for long-term monitoring and trend 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!