Hello, IoT
This is the IoT section. I'll be writing about the small electronics projects I run at home — battery-powered sensors, glue between off-the-shelf gear, and the occasional stubbornly low-level bug. Most of it is built on ESP32 or ESP8266 boards talking MQTT to a Home Assistant instance running on a Raspberry Pi.
If you've never wired up a microcontroller before, the ESP-IDF getting-started guide is the most reliable starting point I've found.
What I tend to write about
Most posts here will fall into one of three buckets:
- Hardware notes — board pinouts, power budgets, what actually fits in the enclosure I 3D-printed at 2am.
- Firmware patterns — task scheduling, low-power sleep, OTA updates, watchdog gotchas.
- Integration tricks — getting devices to behave nicely with Home Assistant, Node-RED, or whatever else is on the network.
A typical small project goes through these phases, in order:
- Wire the breadboard, blink an LED, feel briefly competent.
- Add the sensor, discover the datasheet lied about the I²C address.
- Add MQTT, watch the broker quietly drop messages until QoS is fixed.
- Spend three weeks finishing the enclosure.
The hardware is never the hard part. The hard part is finding out, six months later, why the device only crashes on Tuesdays.
A small example
Here's a minimal sketch for an ESP32 that reports a temperature reading
every 30 seconds. It uses PubSubClient for MQTT and assumes you've already
joined a Wi-Fi network elsewhere.
package main
import (
"fmt"
"math/rand"
"time"
)
func readTemperature() float64 {
// Placeholder for a real sensor read.
return 20.0 + rand.Float64()*6.0
}
func publish(topic, payload string) {
// Placeholder for MQTT publish.
fmt.Printf("publish %s => %s\n", topic, payload)
}
func main() {
rand.Seed(time.Now().UnixNano())
ticker := time.NewTicker(30 * time.Second)
defer ticker.Stop()
for {
t := readTemperature()
publish("workshop/temp", fmt.Sprintf("%.1f", t))
<-ticker.C
}
}
Inline dht.readTemperature() returns NaN until the sensor warms up
(usually one or two seconds), which is why the isnan check matters more
than it looks.
Power profile
If you're running off a battery, the numbers below are roughly what I measure on a bare ESP32-WROOM with a DHT22, no display, and the radio off between samples.
| Mode | Current | Notes |
|---|---|---|
| Active + Wi-Fi TX | ~160 mA | Only during the publish window |
| Active, radio idle | ~80 mA | Reading the sensor |
| Light sleep | ~0.8 mA | Wakes on timer |
| Deep sleep | ~10 µA | RTC + ULP only; full reboot on wake |
Deep sleep is the only mode where a small LiPo will last more than a few days. Plan accordingly.
That's the kind of thing you'll find in this section. If something here helps you avoid an evening of soldering frustration, mission accomplished.