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();

}
 

Share this post

Leave a Reply

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

Back to Tutorial