← Back to SmartHome

Ed Chen Lab · Building

SmartHome

How does your house feel right now?

An online dashboard I built for myself that connects everything I measure in my house: the solar array, the battery, the power meters and the indoor air.

Right now, from the database

⚡ Grid voltage
·V
loading
〰️ Grid frequency
·Hz
loading
🌡️ Office temperature
·°C
loading
💦 Office humidity
·%
loading

Grid: the median of three meters at my house, per 15 minutes. Office: one sensor at MIT, about once a minute.

The meter that read double

A hand holds a shunt on its black plastic base inside an electrical box; an inset magnifies the stamp on the bar, 50A 75mV. Behind it, the upstream DC meter reads 80.0 V and 7.22 A.
The shunt, lifted to read its stamp: 50A 75mV. Behind it is the upstream meter the camera photographed.

At 08:51 the meter said 9.98 A, and nothing about that number looked wrong.

The meter is a PZEM-017 on the solar line to the inverter. On its first morning its voltage matched the meter upstream, 78.17 against 78.0 V, while current, power and energy were each twice too high.

When only the quantities that pass through the shunt are wrong, the fault is in the current scale, not the wiring. Register 0x0003 holds the range the meter assumes for its shunt, and it read 100 A. The order said the shunt is the 50 A part, and the stamp on the bar says 50A 75mV. The meter was reading 75 mV as if it meant 100 A.

I wrote 50 A to the register at 09:11, 39 minutes after first contact, and read it back rather than trust the echo.

Proving it was harder than fixing it. The upstream meter could only be read minutes apart from this one, while the sun raised the current by amps a minute, so the first comparisons gave 1.94 and 2.37: around two, and nowhere near a measurement. So I pointed a camera at the upstream meter and photographed its display on the same 90-second schedule as the polls. Twenty pairs, 10:33 to 11:02, and none near two. The 14 taken while the current was steady agreed within 0.9 percent. The rest scattered because a cloud crossed at 10:45, and on a ramp a photograph and a register read a few seconds apart disagree. A wrong scale would push every point the same way; the two low-current points landed on opposite sides of one.

The run stopped at 20 of 40 points, when the laptop driving it had to leave with me.

Why I built it

Every device in a house comes with its own app and its own cloud, and none of them talk to each other. I wanted one place for the whole house, built to be:

Easy to extend

A small ESP32 board forwards each meter's raw reply untouched, and a Cloudflare Worker decodes it. Adding a meter or fixing a reading is a change on the server; the unit in the house is never reflashed.

Easy to customise

No finished product covers what I measure: solar and battery, DC and AC power meters (one of them bidirectional) and an office sensor, each speaking its own protocol. I choose the register, the schedule and what each page shows.

Private by design

Readings go to my own database. I use only each device's local function, never the part that sends data to its maker. Three audiences are enforced on the server, and this public page never shows load, power or when anything runs.

How it works

Architecture drawing in three parts. Local: sensors on RS485 to an ESP32 board. Cloud: Cloudflare Workers, then D1, then Pages. Client: a browser fed by Pages.
Read left to right and then down: the sensors talk RS485 to a small ESP32 board, which posts to a Cloudflare Worker once a minute; the Worker writes the database (D1), and Pages reads it and serves the browser.

Fix a reading without visiting the house

Constraint
A decoding bug on the board would mean reflashing the unit in the house.
Decision
The board forwards each raw reply untouched; a Cloudflare Worker decodes it.
Result
No reflashing to fix a reading. The decoder is tested against real frames and against its Python original.

Never guess a sign

Constraint
Some readings carry the size of the battery current but not its direction.
Decision
Store the size and leave the signed value empty.
Result
A default can never file a discharge as a charge.

Privacy enforced on the server

Constraint
Three audiences: this public page, friends behind an emailed code, and me.
Decision
Each endpoint answers only what its audience may see; nothing is hidden in the browser.
Result
The source of this page cannot show more than its endpoints send.

Store what I use

Constraint
An AI agent wanted the voltage of every one of the 16 cells in the battery pack.
Decision
I overruled it: current in or out, state of charge, capacity left.
Result
Fewer fields, and no false picture: the port reports only the master pack, so a cell view would show 16 of the bank's 32 cells while looking like all of them.

Me and AI, plainly. I make the measurements and decide what matters. AI agents helped me debug, told me where to look and got the server online, which cut a week of exploring to a day, and they taught me a lot about the server and Cloudflare side.

Historical data: Solar output of a week in Oct 2026

Line chart of the battery charge current by hour of day for seven days in October, rising at about 7:00, dipping twice in the morning, peaking near 15 amps around 11:00 to 13:00 and falling to zero by 18:00

One week of the array charging the battery, folded onto hour of day.

The two morning dips come back at the same clock time every day, which is what a fixed shadow does and what a passing cloud does not.

Built with

What I learned

Choose by function, not by box

Problem
I tested serial servers before I knew which functions I needed. One does RS-232 only, one only turns RS-485 into USB, one is made by a vendor I did not want to use, and one cannot do the automatic query.
Result
What worked is a small Waveshare ESP32 board with RS-485 and nothing else, with no laptop in the path.

A week of silence

Problem
The humidity sensor in my MIT office sent nothing out.
Cause
My school's network lets a device send data out only after its MAC address is registered. Finding that took about a week.
Result
Once the address was registered, the sensor began posting.

Two kinds of RS-485

Problem
Some serial servers could not query a device on their own.
Cause
One kind is Modbus. The other is a protocol the vendor made up for itself.
Result
It took me a while to tell them apart; now it is the first thing I check.

Status

Building. Recording now, with no laptop in the path: the battery, the office sensor at MIT, a DC meter on the solar line, and AC meters on four house circuits. Next is the aquaponics: the weight of the water and its conductivity.

QR code that opens this page, drawn inside a red heart
Scan to open this page on your phone.