Back to Tutorial

Digital Temperature Monitoring: ESP32 + DS18B20 Sensor System


🌡️ What is DS18B20?

The DS18B20 is a digital temperature sensor from Maxim Integrated (now Analog Devices), known for:

✅ Accurate temperature readings
✅ Unique 64-bit serial code (for multiple sensors on one wire)
✅ 1-Wire interface (needs only 1 data line + GND + VCC)
✅ Waterproof versions available


📋 Key Features

FeatureDescription
Temperature Range-55°C to +125°C
Accuracy±0.5°C (from -10°C to +85°C)
Interface1-Wire digital
ResolutionProgrammable: 9 to 12 bits
Voltage3.0V to 5.5V
ID AddressEach sensor has a unique ID

🧰 Components Used

ComponentDescription
ESP32 Dev BoardMicrocontroller
DS18B20 SensorWaterproof or standard TO-92 version
4.7kΩ ResistorPull-up resistor for 1-Wire
Jumper WiresFor connections
Breadboard (opt.)For prototyping

🔌 DS18B20 Pinout and ESP32 Wiring

DS18B20 PinWire Color (usually)Connect to ESP32Description
VCCRed3.3V or 5VPower
GNDBlackGNDGround
DQ (Data)YellowGPIO 15 (example)1-Wire Data

🔧 Add a 4.7kΩ resistor between VCC and DQ.

VCC | | [4.7kΩ] | DQ --------+-------- GPIO 15 (1-Wire pin) | GND


🧩 Step-by-Step in Arduino IDE

📚 Step 1: Install Required Libraries

  1. Open Arduino IDE
  2. Go to Sketch > Include Library > Manage Libraries
  3. Search and install:
    • OneWire by Paul Stoffregen
    • DallasTemperature by Miles Burton

🎯 Applications of DS18B20

ApplicationUse Case Example
🏠 Home AutomationRoom/ambient temperature
🚰 Water MonitoringCheck water heater/cooler
🌿 AgricultureSoil/environmental sensing
🔥 Fire DetectionOverheat alert in machines
🐢 Aquarium MonitoringCheck fish tank or pet enclosures

🛠️ Troubleshooting

ProblemFix
Reading -127.00 °CSensor not connected or wrong pin
Output always 0.00 °CMissing pull-up resistor
Sensor not detectedUse .getDeviceCount() to debug
Multiple sensors issueUse .getAddress() with sensor ID
HOW TO OPERATE

#include <OneWire.h>

#include <DallasTemperature.h>

#define DATA 2



void setup() {
 Serial.begin(9600);
}

void loop() {
 int TEMP;
 TEMP=analogRead(DATA);
 Serial.print(TEMP);
 Serial.println();

}
 
iotwebplanet.com - 1

Share this post

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Tutorial