{"id":52225,"date":"2026-11-01T10:50:41","date_gmt":"2026-11-01T10:50:41","guid":{"rendered":"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/"},"modified":"2026-11-01T10:50:41","modified_gmt":"2026-11-01T10:50:41","slug":"ds18b20-waterproof-temperature","status":"publish","type":"siratek_tutorial","link":"https:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/","title":{"rendered":"Waterproof Temperature with DS18B20"},"content":{"rendered":"<body><p><\/p>\n<h2>What it does<\/h2>\n<p>A DS18B20 in a stainless steel probe on the end of a cable. It reads from about -55 to +125 degrees Celsius to a tenth of a degree, and the sealed tip means it can go into soil, a tank, a fermenter or a fridge.<\/p>\n<p>It is a better sensor than the DHT11 in every way that matters for temperature: more accurate, much wider range, and it does not have to be kept dry. It also introduces something new, because it speaks <strong>1-Wire<\/strong>, a protocol where data and the clock share a single line, and many devices share that one line.<\/p>\n<h2>Before you begin<\/h2>\n<h3>Required parts and tools<\/h3>\n<ul>\n<li>An Arduino Uno or compatible board.<\/li>\n<li>One waterproof DS18B20 probe. This is Siratek product 49704.<\/li>\n<li><strong>One 4.7 kilohm resistor. The sensor will not work without it, and one is not supplied.<\/strong><\/li>\n<li>A breadboard and three jumper wires.<\/li>\n<\/ul>\n<h3>Three bare wires<\/h3>\n<p>The Siratek part is a probe with a one-metre cable ending in <strong>three tinned wires, no connector and no breakout board<\/strong>:<\/p>\n<table>\n<thead>\n<tr>\n<th>Wire<\/th>\n<th>Function<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Red<\/td>\n<td><code>VDD<\/code>, 3.0 to 5.5 V<\/td>\n<\/tr>\n<tr>\n<td>Yellow<\/td>\n<td><code>DQ<\/code>, the data line<\/td>\n<\/tr>\n<tr>\n<td>Black<\/td>\n<td><code>GND<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Colours are near-universal on these probes but not guaranteed. If yours differ, the data wire is the one that is neither red nor black.<\/p>\n<p>Bare wire ends do not sit reliably in a breadboard. Tin them, fit a short length of solid-core wire, or use a small screw terminal. A probe that works when you hold the wires and fails when you let go is a connection problem, not a sensor problem.<\/p>\n<h3>The pull-up resistor, which is the whole trick<\/h3>\n<p>1-Wire works by letting every device pull a single shared line <strong>down<\/strong>, and nothing ever drives it up. The line is held high by one resistor, and any device can win by pulling it low.<\/p>\n<p>That resistor is not in the probe. You have to fit it: <strong>4.7 kilohms between the yellow data wire and the red power wire.<\/strong><\/p>\n<p>Leave it out and the data line floats. The sensor is found inconsistently or not at all, and the library returns <code>-127.00<\/code>, which is its code for \u201cno reply\u201d. Almost every \u201cmy DS18B20 reads -127\u201d is this.<\/p>\n<p>A second value worth knowing: <strong>85.00<\/strong> means the sensor powered up and was read before it finished its first conversion. That one is usually a timing or power problem rather than wiring.<\/p>\n<h3>Why one line can hold many sensors<\/h3>\n<p>Every DS18B20 leaves the factory with a unique 64-bit address burnt into it. Because each one answers only to its own address, you can connect a dozen probes to the same pin with the same one resistor, and read them individually.<\/p>\n<p>That is genuinely useful: a tank with probes at three depths costs you one Arduino pin. The example below starts with one, then shows how to find and read several.<\/p>\n<h2>Pin reference<\/h2>\n<table>\n<thead>\n<tr>\n<th>Wire<\/th>\n<th>Connect to<\/th>\n<th>Purpose<\/th>\n<th>Notes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Red<\/td>\n<td>Uno <code>5V<\/code><\/td>\n<td>Power<\/td>\n<td>3.3 V works too<\/td>\n<\/tr>\n<tr>\n<td>Yellow<\/td>\n<td>Uno <code>D2<\/code>, <strong>and<\/strong> through 4.7 k to <code>5V<\/code><\/td>\n<td>Data<\/td>\n<td>The resistor is required<\/td>\n<\/tr>\n<tr>\n<td>Black<\/td>\n<td>Uno <code>GND<\/code><\/td>\n<td>Ground<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<figure class=\"siratek-tutorial-figure\"><img decoding=\"async\" src=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/ds18b20-waterproof-temperature-wiring.svg\" alt=\"A DS18B20 probe with red to 5V, black to ground, yellow to pin 2, and a 4.7 kilohm resistor between the yellow wire and 5V\" loading=\"lazy\"><figcaption>The 4.7 kilohm pull-up is not supplied with the probe and nothing works without it.<\/figcaption><\/figure>\n<h2>Wiring steps<\/h2>\n<ol>\n<li>Unplug the USB cable.<\/li>\n<li>Put the three wire ends into three separate breadboard rows.<\/li>\n<li>Red to <code>5V<\/code>.<\/li>\n<li>Black to <code>GND<\/code>.<\/li>\n<li>Yellow to <code>D2<\/code>.<\/li>\n<li>Fit the 4.7 k resistor between the yellow wire\u2019s row and the <code>5V<\/code> rail.<\/li>\n<li>Check that the resistor really bridges data and power. This is the step people skip.<\/li>\n<li>Plug the USB cable back in.<\/li>\n<\/ol>\n<h2>Software and libraries<\/h2>\n<p>Install two libraries through Library Manager:<\/p>\n<ul>\n<li><strong>OneWire<\/strong>, which handles the protocol.<\/li>\n<li><strong>DallasTemperature<\/strong>, which turns it into readable calls.<\/li>\n<\/ul>\n<p>The second needs the first. Install OneWire too if Library Manager does not bring it along.<\/p>\n<h2>Minimal working example<\/h2>\n<pre><code>\/\/ Siratek: reading one DS18B20 probe.\n\n#include &lt;OneWire.h&gt;\n#include &lt;DallasTemperature.h&gt;\n\nconst int oneWirePin = 2;\n\nOneWire oneWire(oneWirePin);\nDallasTemperature sensors(&amp;oneWire);\n\nvoid setup() {\n  Serial.begin(9600);\n  sensors.begin();\n\n  Serial.print(\"Siratek: found \");\n  Serial.print(sensors.getDeviceCount());\n  Serial.println(\" sensor(s).\");\n}\n\nvoid loop() {\n  sensors.requestTemperatures();\n  float c = sensors.getTempCByIndex(0);\n\n  if (c == DEVICE_DISCONNECTED_C) {\n    Serial.println(\"no reply. Check the 4.7k pull-up.\");\n  } else {\n    Serial.print(\"temperature = \");\n    Serial.print(c, 1);\n    Serial.println(\" C\");\n  }\n\n  delay(1000);\n}<\/code><\/pre>\n<p>The device count printed in <code>setup()<\/code> is the first thing to look at. <strong>Zero means the wiring is wrong<\/strong>, almost always the resistor, and no amount of reading further output will help.<\/p>\n<p>Checking against <code>DEVICE_DISCONNECTED_C<\/code> rather than printing whatever arrives is worth the two lines. It turns a mysterious <code>-127.00<\/code> into a sentence that names the cause.<\/p>\n<h3>Several probes on one pin<\/h3>\n<pre><code>\/\/ Siratek: reading every DS18B20 on the line.\n\n#include &lt;OneWire.h&gt;\n#include &lt;DallasTemperature.h&gt;\n\nOneWire oneWire(2);\nDallasTemperature sensors(&amp;oneWire);\n\nint count = 0;\n\nvoid setup() {\n  Serial.begin(9600);\n  sensors.begin();\n  count = sensors.getDeviceCount();\n\n  Serial.print(\"Siratek: \");\n  Serial.print(count);\n  Serial.println(\" probe(s) on the line.\");\n}\n\nvoid loop() {\n  sensors.requestTemperatures();\n\n  for (int i = 0; i &lt; count; i++) {\n    Serial.print(\"probe \");\n    Serial.print(i);\n    Serial.print(\" = \");\n    Serial.print(sensors.getTempCByIndex(i), 1);\n    Serial.println(\" C\");\n  }\n\n  Serial.println();\n  delay(2000);\n}<\/code><\/pre>\n<p>One warning about <code>getTempCByIndex()<\/code>: the index is the order the library discovered the devices in, which depends on their addresses, not on where they are in your tank. Add a probe and the numbering can change.<\/p>\n<p>For anything permanent, read each sensor\u2019s address once with <code>getAddress()<\/code>, write those addresses into your sketch, and read by address. Then \u201cprobe 0\u201d means the probe you meant.<\/p>\n<h3>Why reading takes time<\/h3>\n<p><code>requestTemperatures()<\/code> waits while the sensor converts. At the default 12-bit resolution that is up to <strong>750 milliseconds<\/strong>, during which your sketch does nothing else.<\/p>\n<p>Three quarters of a second is a long time in a loop that is also watching a button. The fixes, in order of effort: lower the resolution with <code>setResolution(9)<\/code>, which takes about 94 ms and gives half a degree instead of a sixteenth; or call <code>setWaitForConversion(false)<\/code> and collect the reading on a later pass, using the pattern from <em>Timing Without delay()<\/em>.<\/p>\n<p>For a thermometer that updates once a second, leave it alone.<\/p>\n<h2>Expected result<\/h2>\n<p>A device count of 1 in <code>setup()<\/code>, then a temperature once a second to one decimal place.<\/p>\n<p>Hold the metal tip between your fingers and the reading should climb within a few seconds. It will not jump instantly: the steel sheath has to warm up first, and that thermal lag is real and worth knowing about if you are measuring something that changes quickly.<\/p>\n<h2>Troubleshooting<\/h2>\n<table>\n<thead>\n<tr>\n<th>Symptom<\/th>\n<th>Likely cause<\/th>\n<th>Check or fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Reads -127.00<\/td>\n<td>No pull-up resistor<\/td>\n<td>4.7 k between the data wire and <code>5V<\/code><\/td>\n<\/tr>\n<tr>\n<td>Found 0 sensors<\/td>\n<td>Same, or data on the wrong pin<\/td>\n<td>Check the resistor, then the pin number<\/td>\n<\/tr>\n<tr>\n<td>Reads 85.00<\/td>\n<td>Read before the first conversion finished<\/td>\n<td>Check power; let <code>requestTemperatures()<\/code> complete<\/td>\n<\/tr>\n<tr>\n<td>Works when held, fails when let go<\/td>\n<td>Bare wires not seated<\/td>\n<td>Tin the ends or use a screw terminal<\/td>\n<\/tr>\n<tr>\n<td>Readings jump between two values<\/td>\n<td>Loose connection, or a long unshielded cable<\/td>\n<td>Reseat; try 2.2 k for a long run<\/td>\n<\/tr>\n<tr>\n<td>One of several probes disappears<\/td>\n<td>Index order changed<\/td>\n<td>Read by address, not by index<\/td>\n<\/tr>\n<tr>\n<td>Sketch feels sluggish<\/td>\n<td>750 ms conversion time<\/td>\n<td>Lower the resolution, or do not block<\/td>\n<\/tr>\n<tr>\n<td>Compile error about OneWire<\/td>\n<td>Library missing<\/td>\n<td>Install OneWire as well as DallasTemperature<\/td>\n<\/tr>\n<tr>\n<td>Reading is right but slow to change<\/td>\n<td>Thermal mass of the steel tip<\/td>\n<td>Expected; allow it to settle<\/td>\n<\/tr>\n<tr>\n<td>Reads correctly in air, wrongly in water<\/td>\n<td>Cable entry not sealed<\/td>\n<td>Only the tip is waterproof; keep the joint dry<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Next steps<\/h2>\n<ul>\n<li><strong>Easier first:<\/strong> <em>Read Temperature and Humidity with DHT11<\/em>, which needs no extra resistor.<\/li>\n<li><strong>Related:<\/strong> <em>I2C, Two Wires and Many Devices<\/em>, to compare how the two shared buses address devices.<\/li>\n<li><strong>Next project:<\/strong> a standalone data logger, writing temperature and a timestamp to an SD card.<\/li>\n<\/ul>\n<h2>Sources and attribution<\/h2>\n<p>All text, wiring guidance and code in this tutorial are original Siratek work.<\/p>\n<ul>\n<li>Maxim DS18B20 datasheet for the temperature range, the 64-bit address, the conversion times at each resolution and the recommended pull-up value.<\/li>\n<li>DallasTemperature and OneWire library documentation for the calls used.<\/li>\n<\/ul>\n<p>The probe described here has three bare wires and no breakout board, read from the Siratek product photograph for item 49704, which is why the pull-up resistor is treated as a required part rather than an optional one. Wire colours are near-universal on these probes but the reader is told what to do if theirs differ. No third-party tutorial text, diagrams, photographs or code has been reproduced here.<\/p>\n<p><\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>A DS18B20 in a stainless steel probe on the end of a cable. It reads from about -55 to +125 degrees Celsius to a tenth of a degree, and the sealed tip means it can go into soil, a tank,&#8230;<\/p>\n","protected":false},"featured_media":0,"template":"","siratek_tutorial_level":[],"class_list":["post-52225","siratek_tutorial","type-siratek_tutorial","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Waterproof Temperature with DS18B20 - siratek<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Waterproof Temperature with DS18B20 - siratek\" \/>\n<meta property=\"og:description\" content=\"A DS18B20 in a stainless steel probe on the end of a cable. It reads from about -55 to +125 degrees Celsius to a tenth of a degree, and the sealed tip means it can go into soil, a tank,...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/\" \/>\n<meta property=\"og:site_name\" content=\"siratek\" \/>\n<meta property=\"og:image\" content=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/ds18b20-waterproof-temperature-wiring.svg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/ds18b20-waterproof-temperature\\\/\",\"url\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/ds18b20-waterproof-temperature\\\/\",\"name\":\"Waterproof Temperature with DS18B20 - siratek\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/ds18b20-waterproof-temperature\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/ds18b20-waterproof-temperature\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/ds18b20-waterproof-temperature-wiring.svg\",\"datePublished\":\"2026-11-01T10:50:41+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/ds18b20-waterproof-temperature\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/ds18b20-waterproof-temperature\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/ds18b20-waterproof-temperature\\\/#primaryimage\",\"url\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/ds18b20-waterproof-temperature-wiring.svg\",\"contentUrl\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/ds18b20-waterproof-temperature-wiring.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/ds18b20-waterproof-temperature\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/siratek.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorials\",\"item\":\"https:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Waterproof Temperature with DS18B20\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\",\"url\":\"https:\\\/\\\/siratek.net\\\/\",\"name\":\"siratek\",\"description\":\"Your Best Electronic Retail Shop\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/siratek.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Waterproof Temperature with DS18B20 - siratek","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/","og_locale":"en_US","og_type":"article","og_title":"Waterproof Temperature with DS18B20 - siratek","og_description":"A DS18B20 in a stainless steel probe on the end of a cable. It reads from about -55 to +125 degrees Celsius to a tenth of a degree, and the sealed tip means it can go into soil, a tank,...","og_url":"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/","og_site_name":"siratek","og_image":[{"url":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/ds18b20-waterproof-temperature-wiring.svg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/","url":"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/","name":"Waterproof Temperature with DS18B20 - siratek","isPartOf":{"@id":"https:\/\/siratek.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/#primaryimage"},"image":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/#primaryimage"},"thumbnailUrl":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/ds18b20-waterproof-temperature-wiring.svg","datePublished":"2026-11-01T10:50:41+00:00","breadcrumb":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/#primaryimage","url":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/ds18b20-waterproof-temperature-wiring.svg","contentUrl":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/ds18b20-waterproof-temperature-wiring.svg"},{"@type":"BreadcrumbList","@id":"http:\/\/siratek.net\/index.php\/tutorials\/ds18b20-waterproof-temperature\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/siratek.net\/"},{"@type":"ListItem","position":2,"name":"Tutorials","item":"https:\/\/siratek.net\/index.php\/tutorials\/"},{"@type":"ListItem","position":3,"name":"Waterproof Temperature with DS18B20"}]},{"@type":"WebSite","@id":"https:\/\/siratek.net\/#website","url":"https:\/\/siratek.net\/","name":"siratek","description":"Your Best Electronic Retail Shop","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/siratek.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial"}],"about":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/types\/siratek_tutorial"}],"version-history":[{"count":0,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52225\/revisions"}],"wp:attachment":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/media?parent=52225"}],"wp:term":[{"taxonomy":"siratek_tutorial_level","embeddable":true,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial_level?post=52225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}