Electric floor heating controller

Holds the room temperature with a solid-state relay while limiting the floor temperature, with a web set point.

Level: Advanced Board: ESP32 DevKit V1 (WROOM-32) Smart home

⚠ Safety

Mains voltage can kill. Use certified isolated modules in an enclosure, fuse and RCD the circuit, switch the power off before wiring, and ask a qualified electrician if you are unsure. Check the rules for your country.

What you need

Buy the parts kit · Estimated total: $24.00

ESP32 DevKit V1 (30 pin, WROOM-32) × 1
$4.00
Buy at AliExpress Buy at Amazon.com
DS18B20 waterproof probe × 2
$3.00
Buy at AliExpress Buy at Amazon.com
Solid-state relay SSR-25DA + heatsink (for heaters) × 1
$6.00
Buy at AliExpress Buy at Amazon.com
Resistor kit 1/4W (1k, 2k, 4.7k, 10k, 22k, 100k) × 1
$1.50
Buy at AliExpress Buy at Amazon.com
Inline fuse holder + fuses × 1
$1.50
Buy at AliExpress Buy at Amazon.com
Plastic project enclosure × 1
$3.00
Buy at AliExpress Buy at Amazon.com
Lever connectors (WAGO type) 2/3-pin × 2
$5.00
Buy at AliExpress Buy at Amazon.com
🇺🇦 Ukraine🌍 Other countries

Ukraine: we buy and sell these parts ourselves, order them on this site.

Some links are affiliate links: we may earn a commission at no extra cost to you.

Wiring

ModuleModule pinESP32 pinNote
DS18B20 x2 DATA1-WireGPIO4one 4.7 kΩ pull-up; one probe in the floor sleeve, one on the room wall
SSR input +/-signalGPIO26 / GNDSSR sized for the heating mat with margin, on a heatsink
Heating matpowerthrough the SSRkeep the original floor limit thermostat or protection in the circuit

Libraries

Arduino IDE → Tools → Manage Libraries, then install:

  • OneWire
  • DallasTemperature

Code

floor-heating.ino
#include <WiFi.h>

const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASS = "YOUR_PASSWORD";

bool connectWiFi(uint32_t timeoutMs = 20000) {
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  uint32_t t0 = millis();
  while (WiFi.status() != WL_CONNECTED && millis() - t0 < timeoutMs) {
    delay(250);
    Serial.print(".");
  }
  Serial.println();
  if (WiFi.status() == WL_CONNECTED) {
    Serial.print("IP: ");
    Serial.println(WiFi.localIP());
    return true;
  }
  return false;
}
#include <WebServer.h>

WebServer server(80);
String buildJson();   // implemented in the project below

String num(float v, int d = 1) { return isnan(v) ? String("null") : String(v, d); }

const char PAGE_HTML[] PROGMEM = R"rawliteral(
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>ESP32</title>
<style>body{font-family:system-ui;background:#0b0f14;color:#e6edf3;margin:20px}table{border-collapse:collapse}td{padding:6px 14px;border-bottom:1px solid #223}button,input{font-size:16px;padding:8px 14px;margin:4px;border-radius:6px;border:1px solid #345;background:#16202b;color:#e6edf3}</style>
</head><body><h2>ESP32</h2><table id="t"></table>
<script>
function load(){fetch('/json').then(r=>r.json()).then(d=>{let h='';for(const k in d){h+='<tr><td>'+k+'</td><td>'+d[k]+'</td></tr>';}document.getElementById('t').innerHTML=h;});}
load();setInterval(load,2000);
</script></body></html>
)rawliteral";

void startWeb() {
  server.on("/", []() { server.send_P(200, "text/html", PAGE_HTML); });
  server.on("/json", []() { server.send(200, "application/json", buildJson()); });
  server.begin();
}
#include <OneWire.h>
#include <DallasTemperature.h>

OneWire ow(4); DallasTemperature ds(&ow);
const int PIN_SSR = 26;
float ROOM_SET = 22.0, ROOM_HYST = 0.5;     // target room temperature
const float FLOOR_MAX = 32.0;               // hard floor limit (wood and laminate need about 27-28)
const uint32_t MIN_SWITCH_MS = 60000;       // protect the SSR and the mat from rapid cycling
float floorC = NAN, roomC = NAN; bool heat = false; uint32_t lastSwitch = 0;
// Sensor order: probe 0 = floor, probe 1 = room. If they are swapped, swap the indexes below.
String buildJson() { return String("{\"floor\":") + num(floorC) + ",\"room\":" + num(roomC) + ",\"heating\":" + (heat ? 1 : 0) + ",\"set\":" + num(ROOM_SET) + "}"; }

void setup() {
  Serial.begin(115200); pinMode(PIN_SSR, OUTPUT); ds.begin(); connectWiFi(); startWeb();
  server.on("/set", []() { if (server.hasArg("t")) ROOM_SET = constrain(server.arg("t").toFloat(), 10, 30); server.send(200, "text/plain", String(ROOM_SET)); });
}
void loop() {
  server.handleClient();
  static uint32_t t = 0;
  if (millis() - t > 5000) {
    t = millis(); ds.requestTemperatures(); floorC = ds.getTempCByIndex(0); roomC = ds.getTempCByIndex(1);
    bool ok = floorC > -100 && roomC > -100;
    bool want = heat;
    if (!ok || floorC >= FLOOR_MAX) want = false;                       // sensor fault or floor limit: heater off
    else if (roomC < ROOM_SET - ROOM_HYST) want = true;
    else if (roomC > ROOM_SET + ROOM_HYST) want = false;
    if (want != heat && (millis() - lastSwitch > MIN_SWITCH_MS || !want)) { heat = want; lastSwitch = millis(); digitalWrite(PIN_SSR, heat); }
  }
}

Flash a ready firmware from the browser Paste your error into the AI Error Doctor

Build tips

  • Check which DS18B20 is which by warming one of them and swap the indexes if needed.
  • Keep the original floor limit thermostat in the circuit as the last line of protection.

← ← All projects

Related ideas

⛔ High risk

Never replace the boiler's own safety thermostat or overheat protection. The ESP32 is only an extra controller; use a certified relay and a fuse.

Solid-fuel boiler controller

Controls the draft fan and circulation pump by flue-gas and water temperature, with overheat and CO warnings.

  • Board ESP32 DevKit V1 (WROOM-32)
  • Level ●●● Advanced
  • Build time 4–6 h
Pick parts / kit
⛔ High risk

Mains 220–230 V can kill. Work with the power off, use certified isolated modules in an enclosure, fuse the line, and ask a qualified electrician if you are not sure.

Pipe freeze guard with heating cable

Watches the temperature of an unheated pipe, switches a heating cable and warns you when the cable cannot work because the power is out.

  • Board ESP32 DevKit V1 (WROOM-32)
  • Level ●●○ Intermediate
  • Build time 2–3 h
Pick parts / kit
⛔ High risk

Mains 220–230 V can kill. Work with the power off, use certified isolated modules in an enclosure, fuse the line, and ask a qualified electrician if you are not sure.

Night-tariff water heater scheduler

Heats the water heater only in the cheap night tariff zone or from surplus solar power, with a temperature limit.

  • Board ESP32 DevKit V1 (WROOM-32)
  • Level ●●● Advanced
  • Build time 3–5 h
Pick parts / kit

Comments

No comments yet. Share your experience or ask a question.

Comments are moderated.