Bitcoin miners and a hot-tub controller

Designed and built the controller · 2022 · Archived

I designed the controller box and wrote the software for an investor's home Bitcoin mining rig, including a program to heat a hot tub with the miners' waste heat.

An investor wanted to run Bitcoin miners at home and do it properly, without an off-the-shelf rig or janky extension cords. Miners run hot, and the plan was to put that heat into a hot tub.

The box in the photos, sitting on a rug, is the controller. It's a sealed electrical enclosure with DIN rails (the metal strips electrical parts clip onto), relays, power meters and a Raspberry Pi inside, a 50-amp outlet on the side, and an emergency stop on its own cable.

I wrote the drivers the Pi used to read a water flow sensor and switch the relays. For the hot tub it ran two pumps, one for oil and one for water, and read a thermometer in each.

How the parts talked to each other

I ran an IRC server (old-school internet chat) for the rig, and bots on it traded messages in a format I wrote. Every six seconds the Pi posted its readings, as a message that started with "stats::" and then the numbers.

The control program read those and answered. If the water was below the target, it posted a command, the Pi flipped a relay and the water pump started. If the water was above it, both pumps went off and the miner got a message to stop.

The bots, all written in Python, also pulled stats from the miners over SSH and wrote everything to InfluxDB, a database built for measurements over time. A GraphQL API fed a Next.js dashboard.

The dashboard had one knob, for the water temperature. It went from 60 to 160°F, and the program's default was 104°F. Turning it sent the new target to a small web service, which posted it to the chat like any other message. I borrowed the knob from an air-conditioner demo, so the dashboard's code still had a setting for the fan.

To test it, I joined the chat and typed in fake sensor readings by hand. One of them said the water was 999.2°F, and the program turned off both pumps and told the miner to stop.

My commit messages from that build aren't great. In the controller code, 77 of my 245 commit messages are just the letter d. The driver code has three in a row about the flow sensor, from one morning in March 2022: "hall effect sensor no longer working?", then "i think i had wrong pin num?", then "hall effect working" 51 seconds later.

The last lines of the run log I kept show both pumps on, the miner mining, the target at 98°F and the water at 61.6°F, with the program in its heating phase.

Stack

Languages
Python
Hardware
Raspberry Pi

Text mePaul Mikulskis

(617) 599-0775

If this sounds like your situation, tell me what's going on.

This number usually answers in a minute or two, in my voice, and every conversation comes straight to me.

Text (617) 599-0775
Email me