Maker tech hub — AI · 3D print · Pi · ESP32 · plus the classic tech archive.

Free ESP32 kit · AI tools directory · Books · Archive

Project · Intermediate · ESP32

ESP32 Home Automation with Sensors & Relays (Safe Bench Build)

Sensors publish; actuators subscribe. Keep v1 on low-voltage practice loads. Pairs with the Pi + ESP32 MQTT architecture and free ESP32 kit PDF. Scope & non-goals In scope: BME280/DHT class sensors, opto…

Written by

Avery J. Parker

IT veteran, maker educator, and author of Network Ninja, 3D Printing Mastery, and AI Workflow Mastery. Business IT: Diversified Tech Solutions.

Project template

  • Goal & materials
  • Steps / firmware
  • Troubleshooting
  • AI assist notes
  • Related gear & books
ESP32 sensors and relay overview
Sensors publish; actuators subscribe. Keep v1 on low-voltage practice loads.

Pairs with the Pi + ESP32 MQTT architecture and free ESP32 kit PDF.

Scope & non-goals

  • In scope: BME280/DHT class sensors, opto-isolated relay modules on low-voltage practice loads, serial + optional MQTT publish.
  • Out of scope for beginners: mains switching, unlabeled relay modules without ratings, “smart home” cloud lock-in on day one.

BOM (one node)

ItemQtyBallpark
ESP32 DevKit1$4–12
BME280 (I²C) or DHT221$3–10
Opto relay module (logic-level)1$3–8
12V LED strip segment / DC load for practice1$5–15
4.7k pull-ups if needed for I²C2$0.10

Bring-up order

  1. Blink + serial (prove the board) — first project.
  2. I²C scan / sensor readings with units printed every 2s.
  3. GPIO drive of relay on a safe low-V load.
  4. Only then add Wi-Fi + MQTT publish of the same JSON you already print to serial.

Expected serial (example)

t_c=24.10 rh=41.2 relay=0
t_c=24.12 rh=41.1 relay=0

Failure table

SymptomLikely causeTest
I²C address missingWiring / 5V sensor on 3.3V busScan bus; check level shift
Humidity stuck / NaNDHT timing / bad librarySwap sensor; verify supply
Relay chattersFloating input / no debounce / shared groundExplicit GPIO mode; common GND
Wi-Fi OK, no MQTTBroker IP / firewallPing Pi; mosquitto_sub on LAN

Export / repo pack

Download skeleton: pi-esp32-mqtt-lab.zip · PlatformIO path: platformio-esp32-starter.zip

Verdict

Ship sensors and low-V actuators first. Mains and “whole house” automations wait until isolation, enclosures, and a local broker are boringly reliable.

Related: home lab AI stack · Mosquitto review