Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Sensors
  4. ›DS18B20 Waterproof Temperature Sensor
Step 9 of 18 in Sensors and measurementPart of a learning path.
Next

Component guide · Beginner · 3 min read

DS18B20 Waterproof Temperature Sensor

Wiring and Code

By Geekobot Learning Team · Updated 24 Oct 2026

On this page
Short answerWiringCode with OneWire and DallasTemperatureReading 85 °C or −127 °C?Try itCommon mistakesFAQsParts and next steps
Short answer

The DS18B20 is a digital temperature sensor that talks over a single data wire called 1-Wire. It measures −55 to +125 °C, accurate to ±0.5 °C between −10 and +85 °C, and runs from 3.0 to 5.5 V. It needs a 4.7 kΩ pull-up resistor from data to VCC. Each sensor has a unique 64-bit address, so many probes can share one pin. The waterproof steel probe suits water, soil and freezers.

Key specs at a glance

Range
−55 to +125 °C
Accuracy
±0.5 °C from −10 to +85 °C
Resolution
9 to 12 bits (0.5 to 0.0625 °C)
Conversion time
Up to 750 ms at 12-bit
Supply
3.0 to 5.5 V
Interface
1-Wire with a 4.7 kΩ pull-up; unique 64-bit ROM address
01

Wiring

TO-92 package (flat face towards you, legs down): left GND, middle DQ (data), right VDD.

Waterproof probe: red is VDD, black is GND, and yellow (sometimes white) is data. Colours vary between sellers, so check the listing.

Connect VDD to 3.3 V or 5 V, GND to GND, data to any digital pin, and a 4.7 kΩ resistor between data and VDD. With long cables (over about 10 m) or many sensors, a lower pull-up such as 2.2 kΩ and a 3-wire connection help. Parasite power, where VDD is tied to GND, saves a wire but is less reliable; use normal power when you can.

02

Code with OneWire and DallasTemperature

Install the OneWire and DallasTemperature libraries.

`` #include <OneWire.h> #include <DallasTemperature.h> OneWire bus(4); DallasTemperature sensors(&bus); void setup(){ Serial.begin(115200); sensors.begin(); } void loop(){ sensors.requestTemperatures(); Serial.println(sensors.getTempCByIndex(0)); delay(1000); } ``

For several probes on one pin, print each sensor's address once with getAddress(), then read them by address so the order never changes. Reducing resolution to 10 bits cuts conversion time to about 190 ms.

03

Reading 85 °C or −127 °C?

−127 °C

(DEVICE_DISCONNECTED_C) means the library cannot see the sensor: check the pull-up resistor, wiring order and the pin number.

85 °C

is the power-on reset value: the reading was taken before a conversion finished, often because the sensor is on parasite power or the supply dips.

Readings jump

on long cables: lower the pull-up value, use twisted-pair or shielded cable, and add a 100 nF capacitor near the sensor.

Many low-cost probes use clone chips that are less accurate; check against a known thermometer and apply an offset if needed.

04

Try it: Voltage drop calculator

Change the values and the diagram and results update as you type.

05

Common mistakes to avoid

  • !Leaving out the 4.7 kΩ pull-up resistor.
  • !Swapping VDD and GND, which makes the sensor hot.
  • !Reading by index with several sensors, so the order changes.
  • !Relying on parasite power with long cables.
  • !Expecting fast readings at 12-bit resolution.
06

Frequently asked questions

Why does my DS18B20 read -127?

The sensor is not detected. Check the 4.7 kΩ pull-up, wiring order and that the code uses the right pin.

Why does my DS18B20 always read 85 °C?

85 °C is the power-on value. The conversion did not complete, usually due to parasite power or a weak supply.

How many DS18B20 sensors can I put on one pin?

Dozens in theory, each with its own 64-bit address. In practice 10 to 20 on a few metres of cable works well; lower the pull-up for more.

Can the DS18B20 work at 3.3 V?

Yes, from 3.0 to 5.5 V, so it suits ESP32 and Raspberry Pi Pico.

Is the waterproof DS18B20 safe to submerge?

The steel probe tip and cable are sealed for water. Keep the cable end with the wires dry, and avoid long immersion in hot liquids above the cable's rating.

Parts for this guide

  • Resistor Assortment Kit (30 Values)
    ₹33View
Shop Gas & Weather SensorsShop Resistors

Calculators

Voltage drop calculator

Terms in this guide

1-WireA bus that carries data and timing on a single wire plus ground, with each device identified by a unique 64-bit address. Used by the DS18B20 temperature sensor.Pull-up resistorA resistor from a signal line to the supply that keeps the line high when nothing pulls it low.ResolutionThe smallest step a measurement or output can represent. A 12-bit ADC on 3.3 V has steps of about 0.8 mV.CalibrationMeasuring a sensor against known conditions so its raw numbers can be converted into meaningful values, such as dry and wet readings for a soil sensor.

Projects that use it

Put this into practice: 154 step-by-step builds in our project library use parts from this guide.

Beginner · 1 hourFreezer temperature alarmView projectIntermediate · 2 hoursAquarium heater controllerView projectBeginner · 45 minutesBig-digit room thermometerView project
Browse all 154 projects

Keep learning

ComparisonBeginnerDHT11 vs DHT22DHT11 vs DHT22 compared: accuracy, range and sampling rate, plus wiring, pull-up, Arduino/ESP32 code and when to pick a BME280 or SHT31.3 min read · SensorsComparisonBeginnerBME280 vs BMP280The BMP280 measures temperature and air pressure; the BME280 adds relative humidity.3 min read · SensorsConcept explainerBeginnerPull-Up and Pull-Down ResistorsA pull-up resistor connects an input pin to the supply so it reads HIGH when nothing drives it; a pull-down connects it to ground so it reads LOW.3 min read · Electronics FundamentalsComparisonBeginnerSoil Moisture SensorsResistive (YL-69) vs capacitive v1.2/v2.0 soil moisture sensors: why resistive probes corrode, Arduino and ESP32 wiring, dry and wet calibration, auto watering.3 min read · SensorsComponent guideBeginnerArduino UnoThe Arduino Uno is a beginner-friendly microcontroller board that reads sensors and controls LEDs, motors and relays using simple C++ programs called sketches.5 min read · Boards & Microcontrollers

Sources

  • Analog Devices (Maxim) DS18B20 datasheet
  • OneWire and DallasTemperature library documentation

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWiringCode with OneWire and DallasTemperatureReading 85 °C or −127 °C?Try itCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide1 item · ₹340

Sonoff DS18B20 Waterproof Temperature Sensor Probe w/ 1m Cable – 1-Wire Interface

Ask the Community

Ask a question