ESP32 C3 Super Mini - Temperature Sensor

Learn how to connect a DS18B20 temperature sensor to your ESP32 C3 Super Mini and read accurate temperature data. This beginner-friendly tutorial covers everything from wiring to code.

In this tutorial, you'll learn:

ESP32 C3 Super Mini - Temperature Sensor

Hardware Preparation

1×ESP32 C3 Super Mini
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.

  • Operating voltage: 3.0V to 5.5V (compatible with ESP32 C3 Super Mini)
  • Temperature range: -55°C to +125°C (-67°F to +257°F)
  • Accuracy: ±0.5°C between -10°C and +85°C
  • Resolution: 9-bit to 12-bit adjustable
  • Single data wire: Uses only one digital pin for communication
  • Multiple sensors: You can connect multiple DS18B20 sensors on the same wire
  • Waterproof option: Available in waterproof probe format
  • Perfect for beginners: Simple wiring and easy-to-use Arduino libraries

Why choose DS18B20 for your projects:

  • No analog-to-digital conversion needed
  • Long cable lengths possible (up to 100 meters)
  • Great for weather stations, aquariums, and HVAC projects
  • Affordable and widely available

DS18B20 Temperature Sensor Pinout

The DS18B20 sensor comes in two common forms: a TO-92 transistor-like package and a waterproof probe version.

  • GND pin: Connect to ground (0V)
  • VCC pin: Connect to power supply (3.3V or 5V)
  • DATA pin: 1-Wire data bus - connect to any digital pin on ESP32 C3 Super Mini
DS18B20 temperature sensor Pinout

Note about the pull-up resistor:

  • Traditional DS18B20 wiring requires a 4.7kΩ pull-up resistor between DATA and VCC
  • Many DS18B20 modules now include a built-in pull-up resistor and screw terminals
  • Using an adapter module simplifies your wiring significantly

Wiring Diagram

Connect your DS18B20 temperature sensor to the ESP32 C3 Super Mini following the diagrams below.

  • Note: For beginners, we recommend using a DS18B20 sensor with an adapter module that includes a built-in pull-up resistor

Wiring with breadboard (without adapter):

The wiring diagram between ESP32 C3 Super Mini Temperature Sensor

This image is created using Fritzing. Click to enlarge image

DS18B20 Pin ESP32 C3 Super Mini Pin
GND GND
VCC 3.3V
DATA D9 (or any digital pin)
Pull-up Resistor 4.7kΩ between DATA and VCC

Wiring with adapter module (recommended):

The wiring diagram between ESP32 C3 Super Mini DS18B20

This image is created using Fritzing. Click to enlarge image

DS18B20 Module Pin ESP32 C3 Super Mini Pin
GND (or -) GND
VCC (or +) 3.3V
DATA (or S) D9 (or any digital pin)

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

ESP32 C3 Super Mini Code

The code below reads temperature data from the DS18B20 sensor and displays it on the Serial Monitor.

What this code does:

  • Initializes the DS18B20 temperature sensor using the OneWire protocol
  • Requests temperature readings from the sensor
  • Converts the raw data to Celsius
  • Calculates and displays temperature in both Celsius and Fahrenheit
  • Updates readings every second
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-temperature-sensor */ #include <OneWire.h> #include <DallasTemperature.h> #define SENSOR_PIN D9 // The ESP32 C3 SuperMini pin D9 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(9600); // 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

  • New to ESP32 C3 Mini? Complete our Getting Started with ESP32 C3 Mini tutorial first to set up your development environment.
  • Install required libraries: Open Library Manager in Arduino IDE (click the library icon on the left sidebar)
  • Search for DallasTemperature: Type "DallasTemperature" in the search box
  • 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
ESP32C3 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
ESP32C3 Dev Module on COM15
1
  • Install dependency: When prompted, click Install All to also install the OneWire library
ESP32 C3 Super Mini onewire library
  • Wire the components: Follow the wiring diagram above to connect the DS18B20 sensor to your ESP32 C3 Super Mini
  • Connect your board: Plug the ESP32 C3 Super Mini into your computer using a USB Type-C cable
  • Select your board: In Arduino IDE, choose ESP32 C3 Super Mini and the correct COM port
  • Upload the code: Copy the code above, paste it into Arduino IDE, and click Upload
  • Open Serial Monitor: Set the baud rate to 9600 to view temperature readings
  • Test the sensor: Hold the DS18B20 probe in your hand to warm it up, or place it in hot/cold water to see temperature changes
  • Pro Tip: If readings show -127°C or 185°F, check your wiring connections - this usually indicates a communication error with the sensor.

Serial Monitor Output

Once you upload the code and open the Serial Monitor, you'll see continuous temperature readings like this:

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
Temperature: 23.12°C ~ 73.62°F Temperature: 23.18°C ~ 73.72°F Temperature: 23.25°C ~ 73.85°F Temperature: 23.31°C ~ 73.96°F Temperature: 24.06°C ~ 75.31°F Temperature: 25.18°C ~ 77.32°F Temperature: 26.44°C ~ 79.59°F Temperature: 27.75°C ~ 81.95°F Temperature: 29.12°C ~ 84.42°F Temperature: 30.25°C ~ 86.45°F Temperature: 31.00°C ~ 87.80°F
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

Applications and Project Ideas

The DS18B20 temperature sensor with ESP32 C3 Super Mini opens up many practical applications:

  • Home weather station: Monitor indoor and outdoor temperatures with wireless connectivity
  • Aquarium temperature monitor: Keep track of water temperature for fish tanks
  • Smart thermostat: Create an automated heating/cooling control system
  • Refrigerator monitor: Get alerts when your fridge temperature goes out of safe range
  • Greenhouse automation: Monitor and log temperature for optimal plant growth
  • Server room monitoring: Track temperature in computer or server rooms with remote alerts

Video Tutorial

Watch the video below for a visual walkthrough of this project.

Challenge Yourself

Ready to take your DS18B20 temperature sensor project further? Try these challenges:

  • Easy: Add an LED that turns on when temperature exceeds a certain threshold
  • Easy: Display temperature data on an OLED screen instead of Serial Monitor
  • Medium: Connect multiple DS18B20 sensors to one ESP32 C3 Super Mini and read all simultaneously
  • Medium: Send temperature data to your smartphone via Bluetooth
  • Advanced: Create a web server to display real-time temperature graphs accessible from any browser
  • Advanced: Log temperature data to an SD card with timestamps for long-term monitoring

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