Home IoT Hub Series · 08

[Part 8] Is the boiler actually running? Pipe-temperature monitoring with DS18B20

Monitor boiler operation and hot water pipe temperature with two DS18B20 sensors.

This node uses two DS18B20 probes: one for boiler operation and one for hot-water pipe temperature. It lets the hub understand whether heat is actually moving.

Multiple DS18B20 sensors can share the same data pin. The key is to identify each sensor address once and then assign the right value to the right slot.

[Part 8] Is the boiler actually running? Pipe-temperature monitoring with DS18B20 hero image
System architecture and data pipeline note
This article is part of the Home IoT Hub system connected to the central NodeMCU server built in Part 2: Building the Brain. Two DS18B20 probes report heating-water and hot-water pipe temperatures so the hub can distinguish heating, hot-water use, and freeze risk. The collected data is sent over the local IoT_Hub_Net network and updates slot 5 for boiler pipe temperature and slot 17 for hot-water pipe temperature on the central server (/set?no5=boiler&no17=hotwater), becoming part of the decision pipeline for the 20-channel smart-home controller.

Parts and cost

PartQtyUnit price
Wemos D1 Mini1 pc$1.50
DS18B20 waterproof type2 pc$3
4.7kΩ resistor1 pc$0.10
Jumper wires4 pc
Total$4.40

Pin wiring

[Part 8] Is the boiler actually running? Pipe-temperature monitoring with DS18B20 wiring diagram

Full code

[Part 8] Is the boiler actually running? Pipe-temperature monitoring with DS18B20 - Code 2
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <OneWire.h>
#include <DallasTemperature.h>

const char* ssid     = "IoT_Hub_Net";
const char* password = "iothub1234";
const char* hubURL   = "http://192.168.1.1";

#define ONE_WIRE_BUS 5
#define INTERVAL     15000

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  sensors.begin();

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("Connecting to IoT_Hub_Net");
  while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
  Serial.println("\nConnected! " + WiFi.localIP().toString());
}

void loop() {
  sensors.requestTemperatures();

  // index 0 = first detected sensor, 1 = later detected sensor
  // distinguish boiler and hot water by temperature value
  float t0 = sensors.getTempCByIndex(0);
  float t1 = sensors.getTempCByIndex(1);

  // note
  float boiler = (t0 > t1) ? t0 : t1;
  float hotWater = (t0 > t1) ? t1 : t0;

  if (boiler < -50 || hotWater < -50) {
    Serial.println("Sensor error, retry...");
    delay(2000); return;
  }

  Serial.printf("Boiler: %.1f C, HotWater: %.1f C\n", boiler, hotWater);

  WiFiClient client; HTTPClient http;
  String url = String(hubURL) + "/set?no5=" + String(boiler)
             + "&no17=" + String(hotWater);
  http.begin(client, url);
  int code = http.GET(); http.end();
  Serial.print("HTTP "); Serial.print(code);
  Serial.print(" -> "); Serial.println(url);
  Serial.println();

  delay(INTERVAL);
}

Upload and check

Connect the Wemos D1 Mini to the PC with a USB data cable, select the ESP8266 board and port in the Arduino IDE, upload the sketch, then open Tools → Serial Monitor and set the baud rate to 115200.

Serial Monitor

After uploading, open Tools → Serial Monitor in the Arduino IDE and set the baud rate to 115200. The following is an example Serial Monitor flow for checking normal operation. This is not a real screenshot. It shows how boiler and hot-water pipe temperatures update slots 5 and 17.

[BOOT] Home IoT Node #08 - Boiler and hot-water pipes
[1-WIRE] boiler sensor OK, hot-water sensor OK
[SENSOR] boiler_pipe=43.7C hot_water_pipe=51.2C
[FILTER] thermal_lag=stable, offset=0.0C
[HTTP] GET /set?no5=43.7&no17=51.2
[HUB] 200 OK - slots no5/no17 updated
[STATE] heating=ON, hot_water=ON
  • If Connected or connected appears, the Wi-Fi step passed.
  • If HTTP 200 or 200 OK appears, the value reached the brain server.
  • If the value does not update, check both the slot number in the URL and the sensor wiring.

Build notes

  • Warm the pipe briefly and confirm only the intended value rises. If the two readings are swapped, switch the sensor address mapping in code.
  • Power on the hub brain first so the node can join IoT_Hub_Net.
  • Use the same slot number written in the source code.
  • Open the serial monitor at 115200 baud and confirm HTTP 200.
  • If the value does not appear on the hub, recheck wiring, GPIO number, and Wi-Fi connection.

What Boiler + Hot-Water Pipe Temperature Can Do

By putting two DS18B20 sensors on a single OneWire bus to read the heating (radiant) pipe and the hot-water pipe at the same time, you go beyond raw numbers and see your home's energy flow in real time.

Troubleshooting checkpoints

The node code can look short, but real home installation is affected by placement, power, Wi-Fi quality, and sensor noise. Check these points before letting the node become a decision input for the brain server.

SymptomLikely causeField fix
Pipe temperature reads too lowThe probe is not tightly coupled to the pipe and also reads room airApply thermal grease to the metal probe, fasten it with a cable tie, and cover it with aluminum and insulation tape.
Boiler and hot-water labels swapOneWire sensor order changes or temperature-based detection is ambiguousRecord each sensor address before installation and hard-map labels in code; verify with a temporary heating test.
Values rise with a delayed step patternThere is thermal lag between pipe surface and water insideUse 3-5 minute trend and supply/return temperature difference rather than one instant value.
Freeze-risk alerts are late in winterPoor insulation around the probe mixes outside air and pipe temperatureInsulate the probe with multiple layers and alert before the pipe approaches 3°C.

Practical Uses

  • Confirm the boiler is running: if pipe temperature climbs above 40°C within 5-10 minutes it ignited normally; if it stays flat you can remotely detect a failed ignition or a gas cutoff.
  • Heating and hot-water efficiency: logging the temperature difference (ΔT) between the outgoing and returning pipes tells you how much the boiler is actually heating the water and whether circulation is healthy.
  • Freeze-prevention alerts: when an outdoor pipe drops below 3°C, push a phone alert so you can trickle hot water or fire the boiler before it freezes.
  • Away-mode heating check: verify the pipes stay above the minimum anti-freeze temperature while you're out, and run the boiler only briefly when needed to avoid waste.
  • Cut gas bills: spot wasteful re-firing when the hot-water pipe is already hot, or nighttime overheating, then adjust settings — winter bills drop noticeably.

Recommended Install Spots

  • Tight to the pipe surface: apply a thin film of thermal grease to the sensor's metal face, press it onto the pipe with aluminum tape, then wrap insulating tape over it to shut out room air.
  • Separate inflow and outflow: attach one sensor to the pipe leaving the boiler (outflow, hot) and one to the returning pipe (inflow, lukewarm) to compute ΔT.
  • Outdoor freeze points: put the outdoor sensor where things freeze first — the meter box, exposed pipe running up an outer wall, or a cold corner of the boiler room.

Field Tips and Cautions

  • Surface vs internal error: surface temperature usually reads 3-8°C lower than the water inside. Judge by trend and ΔT rather than absolute value.
  • Distinguish multiple sensors: each sensor has a unique 64-bit address, so connect them one at a time before install, record the addresses, and label them "boiler/hot-water" in code.
  • Heat-rated cable: hot-water pipes easily exceed 60°C, so use silicone or Teflon heat-resistant cable instead of ordinary PVC and finish the joints cleanly at the pipe.
  • Insulation finish: poor insulation over the sensor lets room temperature drag the reading around. Wrap at least 2-3 layers to stabilize it.

FAQ

  • Q. Is surface mounting (without cutting the pipe) actually useful? Yes. The absolute reading is just slightly low; surface mounting is plenty for run/stop detection and ΔT analysis.
  • Q. My two sensors report swapped values. The address mapping in your code is likely reversed. Warm one sensor by hand, see which label rises, and correct the address assignment.
  • Q. How do I weatherproof the outdoor sensor? Use a stainless waterproof DS18B20 and double-seal the cable entry with heat-shrink tube and butyl tape — it stays reliable all winter.