ESP32 S3 - Temperature Sensor - OLED

Learn how to connect a DS18B20 one-wire temperature sensor to an ESP32 S3 and display live temperature readings on an SSD1306 OLED screen. This tutorial walks you through every step, from wiring the hardware to uploading the finished code, so you can see real temperature data on a crisp OLED display in minutes.

What you'll build:

  1. A circuit connecting the DS18B20 sensor and SSD1306 OLED to the ESP32 S3
  2. Firmware that reads temperature in Celsius and Fahrenheit from the DS18B20 one-wire sensor
  3. An OLED display that updates in real time, showing temperature centered on screen
  4. A foundation you can extend into weather stations, data loggers, and smart home displays

https://newbiely.com/images/cover/esp32-s3-temperature-sensor-oled-display.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×SSD1306 I2C OLED Display 128x64
1×SSD1306 I2C OLED Display 128x32
1×DS18B20 Temperature Sensor (WITH Adapter)
1×DS18B20 Temperature Sensor (WITHOUT Adapter)
1×Breadboard
1×Jumper Wires
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: If you want a bigger OLED display, use the 2.42 inch OLED Display 128x64 .

Overview of OLED and DS18B20 Temperature Sensor

The SSD1306 OLED and the DS18B20 one-wire temperature sensor are two of the most widely used components in ESP32 S3 projects because both are inexpensive, easy to wire, and well supported by mature Arduino libraries. The OLED communicates over I2C using just two signal wires, while the DS18B20 uses a single data line with a pull-up resistor and supports reading multiple sensors on the same wire. If you want a deeper understanding of either component before continuing, the dedicated tutorials below cover pinouts, operating principles, and standalone code examples in full.

Key References

Wiring Diagram

Connecting the ESP32 S3 to both the DS18B20 sensor and the OLED display requires only a handful of jumper wires because the OLED uses I2C and the sensor uses a single data line. Using a DS18B20 module that includes a built-in adapter board is strongly recommended, since the adapter's onboard resistor eliminates the need to add a separate 4.7 kΩ pull-up resistor to your breadboard.

Safety Notes

Always power the SSD1306 OLED from the 3.3 V rail of the ESP32 S3 — applying 5 V directly to a 3.3 V-only display will damage it permanently. The DS18B20 is tolerant of both 3.3 V and 5 V, but using 3.3 V keeps everything on a single supply rail and avoids any level-shifting concern. If you are using the raw DS18B20 sensor without an adapter, place a 4.7 kΩ resistor between the DATA pin and VCC; without it the one-wire bus will not function reliably.

  • How to connect ESP32 S3 with temperature sensor and OLED using breadboard
The wiring diagram between ESP32 S3 Temperature Sensor OLED

This image is created using Fritzing. Click to enlarge image

If you plan to keep this circuit, think about screw terminals. Put the ESP32 S3 on a Screw Terminal Block for ESP32 S3, then tighten each wire under a screw. Below is the wiring diagram with the screw terminal board.

The wiring diagram between ESP32 S3 Temperature Sensor OLED Screw Terminal

This image is created using Fritzing. Click to enlarge image

Another choice is a GPIO Breakout Board for ESP32 S3. Each GPIO has a signal pin with 3.3V and GND pins next to it, as shown below:

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

This image is created using Fritzing. Click to enlarge image

How to connect ESP32 S3 with temperature sensor and OLED

This image is created using Fritzing. Click to enlarge image

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

We suggest purchasing a DS18B20 sensor that comes with a wiring adapter for easy connection. The adapter has a built-in resistor, eliminating the need for a separate one in the wiring.

ESP32 S3 Code - Temperature from DS18B20 and Display on OLED

The following code initializes both the SSD1306 OLED over I2C and the DS18B20 sensor on its one-wire data pin, then enters a loop that reads the current temperature and prints it centered on the OLED screen every two seconds. Both Celsius and Fahrenheit values are calculated so you can choose which unit to display with a simple change in the source.

/* * 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-oled */ /* * 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-oled */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <OneWire.h> #include <DallasTemperature.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define SENSOR_PIN 1 // The ESP32-S3 pin GPIO1 connected to DS18B20 sensor's data pin Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); // create SSD1306 display object connected to I2C OneWire oneWire(SENSOR_PIN); // setup a oneWire instance DallasTemperature DS18B20(&oneWire); // pass oneWire to DallasTemperature library String temperature; void setup() { Serial.begin(9600); // initialize OLED display with address 0x3C for 128x64 if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); while (true); } delay(2000); // wait for initializing oled.clearDisplay(); // clear display oled.setTextSize(2); // text size oled.setTextColor(WHITE); // text color oled.setCursor(0, 10); // position to display DS18B20.begin(); // initialize the sensor temperature.reserve(10); // to avoid fragmenting memory when using String } void loop() { DS18B20.requestTemperatures(); // send the command to get temperatures float tempCelsius = DS18B20.getTempCByIndex(0); // read temperature in Celsius temperature = String(tempCelsius, 2); // two decimal places temperature += char(247) + String("C"); Serial.println(temperature); // print the temperature in Celsius to Serial Monitor oledDisplayCenter(temperature); } void oledDisplayCenter(String text) { int16_t x1; int16_t y1; uint16_t width; uint16_t height; oled.getTextBounds(text, 0, 0, &x1, &y1, &width, &height); // display on horizontal and vertical center oled.clearDisplay(); // clear display oled.setCursor((SCREEN_WIDTH - width) / 2, (SCREEN_HEIGHT - height) / 2); oled.println(text); // text to display oled.display(); }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Prepare the wiring: Connect the DS18B20 sensor and SSD1306 OLED to your ESP32 S3 according to the wiring diagram above.
  3. Connect to computer: Plug the ESP32 S3 into your computer using a USB Type-C cable.
  4. Open Arduino IDE: Launch the Arduino IDE on your computer.
  5. Select your board: Choose ESP32 S3 from the board selector and select the correct COM port.
  6. Install the OLED library: Click the Libraries icon on the left bar of the Arduino IDE.
  7. Search for SSD1306: Type "SSD1306" in the search box and find the SSD1306 library by Adafruit.
  8. Install the library: Click the Install button to install the library.
  • Search for Adafruit SSD1306 created by Adafruit 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
Adafruit SSD1306 by Adafruit
SSD1306 oled driver library for monochrome 128x64 and 128x32 displays More info
2.5.9
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32S3 Dev Module on COM15
1
  1. Install dependencies: When prompted, click Install All to install all required library dependencies including Adafruit GFX.
  2. Install DallasTemperature: Search "DallasTemperature" in the search box, then look for the DallasTemperature library by Miles Burton.
  3. Install: Click the Install button to install the DallasTemperature library.
  • 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 OneWire: When asked to install the dependency, click Install All to install the OneWire library.
  2. Upload the code: Copy the code above, paste it into Arduino IDE, and click the Upload button.
  3. Test the sensor: Put the sensor in hot or cold water, or grasp it with your hand to change its temperature.
  4. View the result: Watch the temperature update live on the OLED display.

https://newbiely.com/images/tutorial/esp32-s3-displays-temperature-on-oled.jpg

※ NOTE THAT:

The code automatically centers the temperature text both horizontally and vertically on the OLED display.

Serial Monitor Output

Open the Serial Monitor at 115200 baud to see the raw temperature values as they are read from the DS18B20 sensor, which is useful for debugging before the OLED display is connected.

∞
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 09:01:02] Temperature: 24.12°C ~ 75.42°F [2026-06-16 09:01:04] Temperature: 24.25°C ~ 75.65°F [2026-06-16 09:01:06] Temperature: 35.50°C ~ 95.90°F [2026-06-16 09:01:08] Temperature: 36.10°C ~ 97.00°F
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Applications and Project Ideas

The ESP32 S3 paired with a DS18B20 sensor and SSD1306 OLED makes a self-contained temperature display module that fits into a wide range of real-world projects. Here are practical ways to put this circuit to work:

  1. Standalone thermometer: Build a portable, battery-powered thermometer that shows temperature on the OLED without any serial connection.
  2. Aquarium temperature monitor: Submerge the waterproof DS18B20 probe to track water temperature and alert when it drifts out of range.
  3. Home weather station: Place sensors in multiple rooms and log readings over Wi-Fi to a dashboard or cloud database.
  4. Food probe: Use the DS18B20's waterproof version to monitor cooking or fermenting temperatures with a clear OLED readout.
  5. Server room guard: Continuously monitor rack temperature and trigger an alarm relay if it exceeds a safe threshold.
  6. Greenhouse controller: Read soil or air temperature and drive ventilation or heating equipment automatically.
  7. DIY thermostat: Combine with a relay module to build a smart temperature controller for any heating or cooling system.

Video Tutorial

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

Challenge Yourself

Now that your ESP32 S3 is reading temperature from the DS18B20 and displaying it on an OLED, push the project further with these progressively harder challenges:

  1. Beginner: Add a second line to the OLED that shows the temperature in Fahrenheit below the Celsius reading.
  2. Beginner: Add an LED indicator that turns on when the temperature rises above 30 °C as a simple over-temperature warning.
  3. Intermediate: Connect two DS18B20 sensors on the same data wire and display both readings on the OLED simultaneously, using the one-wire multi-sensor addressing feature.
  4. Intermediate: Log timestamped temperature readings to a microSD card so you can analyze historical data over hours or days.
  5. Advanced: Build an ESP32 S3 web server that serves a live temperature chart in the browser, pulling data from the DS18B20 every five seconds via an AJAX call.
  6. Advanced: Add MQTT publishing over Wi-Fi so the temperature appears on a Home Assistant dashboard and triggers automations when thresholds are exceeded.

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