Close

The Inverter Master Problem

A project log for GRIDNET — Powerline Mesh Terminal

Open hardware mesh terminal that runs over power lines. No internet. No GSM. No servers. Works during blackouts.

yaar-satrYaşar Satır 05/02/2026 at 17:480 Comments

Log 2: The Inverter Master Problem

Published: May 2026

When I first sketched out GRIDNET's "keep talking when the grid is dead" feature, I thought it would be the simplest part of the project. Just put an inverter on every device, and when the power goes out, they all start injecting AC onto the wire to keep PLC signaling alive.

I was wrong. It took me about ten minutes of thinking through it before I realized I had walked into a much bigger problem than I expected.

The Naive Design

Here's what I originally drew:

Grid power lost → every device starts injecting 24V AC → PLC keeps working

Clean. Simple. Wrong.

The problem hits you the moment you imagine more than one device on the same wire. If your terminal is injecting 24V at one phase, and your neighbor's terminal is injecting 24V at a slightly different phase, the two signals don't add up — they fight each other.

Two AC sources on the same wire is the kind of thing electrical engineers normally try very hard to prevent, not encourage. Best case, the signals cancel and PLC stops working. Worst case, you get circulating currents flowing between the inverters, the coupling transformers heat up, and something eventually gives out.

I needed exactly one device to be the inverter at any given time. But which one? And what happens when that one runs out of battery?

What I Couldn't Do

Some obvious approaches were off the table:

Pre-assigned master. I can't ship a device with a fixed "you are the master" flag, because that device might not be plugged in, might be broken, might not exist in this particular building. The system has to work with whatever devices happen to be present.

Central coordinator. This is GRIDNET. There is no central anything. The whole point is that it works when no central anything works.

Manual selection. Asking the user to pick which device should be the inverter during an earthquake is not a serious answer.

The protocol had to figure it out by itself, with no prior coordination, in the dark, possibly underwater. It needed to be:

The Solution: Listen, Then Speak

The protocol I ended up with is built on a single rule that turns out to solve almost everything:

The lowest-address active device is the master. Everyone else is silent.

Here's what each device does when grid power fails:

Grid power lost  ↓
Wait 2 seconds (let the dust settle)  ↓
Listen on the wire — is there 24V AC there already?  ├── YES → Someone else is the master. Stay silent. Just receive.  └── NO  → Become master. Start injecting.

The 2-second delay matters. It gives the lowest-address device time to assert itself before higher-address devices even consider the question. By the time you check, if you're not the lowest, you'll hear the master and stay silent.

Keeping It Alive

The master broadcasts a small packet called MASTER_ALIVE every 10 seconds. It contains its address, sequence number, injected voltage, and battery level.

If 30 seconds pass without hearing one — three missed heartbeats — the slaves know the master is gone. They run the same selection logic again, and the new lowest-address device takes over.

Master master master master ... [silence] ... new master takes over   │                              │              │   10s intervals                  30s gap        smooth handoff

In practice, the network experiences a brief stutter — maybe 20-30 seconds where messages don't propagate — and then it's back. Better than nothing. Much better than nothing.

The Split-Brain Problem

The hard case I kept worrying about: what if two devices both think they're the master? This can happen if MASTER_ALIVE packets get lost in both directions for long enough.

Now you have two inverters injecting simultaneously, and you're back to the original problem.

The fix is at the hardware layer: voltage sensing. Every device has a circuit (V-Sense) that watches the wire. If the master injects 24V at phase A, and the wire actually shows 24V at some weird interfered waveform, V-Sense notices the conflict within one cycle — about 7 microseconds at 148kHz.

When V-Sense detects a conflict:

Both devices immediately stop injecting  ↓
Wait random delay (exponential backoff)  ↓
Re-run master selection from scratch  ↓
Lower address wins

It's the same exponential backoff trick that Ethernet uses for collision detection, just adapted to the energy layer instead of the data layer.

What I Learned

The thing that surprised me most about this whole problem is how much it resembles classic distributed systems work — leader election, heartbeats, split-brain detection — but at the electrical layer instead of the network layer.

Computer scientists have spent fifty years figuring out how to make distributed systems agree on things. None of those algorithms care whether the "thing being agreed on" is who holds a lock, who serves a request, or who powers the wire. The math works the same way.

I just had to translate it down a few layers.

What's Next

Next log will probably be the hardware deep-dive — why two boards instead of one, why the protection circuit looks the way it does, why the PLC adapter is a separate unit instead of integrated. After that, I want to write something on why I chose Forth as the application platform, because that decision keeps surprising people.

If you've worked on distributed protocols and want to poke holes in this design, please do. The whole point of putting it on Hackaday before the prototype is built is to catch the mistakes while they're still cheap.

— Yasar

GitHub: github.com/denorath-sys/gridnet Full inverter protocol spec: docs/inverter-master.md

Discussions