Honey, I Made a Thermostat
Thermestra
For the past couple of years I’ve been working on a personal project that involves developing a small wifi-connected thermostat solution for the baseboards in our house. They are based on a small wifi-capable SoC called the esp8266 that sits on a custom PCB I designed with Circuit Maker and had printed by https://jlcpcb.com/. $25 gets you 10 small pcbs, and it only takes a week or two to print and arrive from China! It’s been quite a learning process to reconnect with some of my electrical engineering background, piecing together tutorials, information from the esp8266 and Arduino community, and sometimes plain old guess work to create something that (mostly) works.
Why make something like this and not use one of the other popular smart thermostats on the market? Mostly because baseboards are line voltage (240V) and the smart thermostats like Nest, etc are designed to operate on the 24V that HVAC (ie, ducts and central) heating uses to turn the heater on and off and control ventilation/fan relays. There’s one other line level smart thermostat on the market (Mysa) but it involves running the baseboard line to the thermostat. It’s also not cheap. I’ve probably spent more on developing this, but have learned a lot more and had much more fun doing so. 😀 My project (which I call Thermestra for no real reason other than it just needs a name) uses a buck converter to take the 240VAC down to 5V DC to power the thermostat with a much smaller gauge wire external to the wall. It’s not as pretty, but I don’t have to fish wire or otherwise do drywall stuff to put the thermostat at a distance from the baseboard. The cable that carries the power and ground to the thermostat from the baseboard has a third wire that the thermostat uses to signal the relay to turn the baseboard on. I took the guts of the thermostat that came with the baseboards out and put the converter and relay in the baseboard housing itself, and the line powers the the step-down converter and the baseboard itself. The relay module is also powered from the 5v from the converter.
Each thermostat is discovered on my home LAN via multicast dns and runs a PID controller, and the temperature each baseboard is set to is controlled via a server I wrote running on the PC on our LAN. It runs as a Windows service. It has a web frontend viewable on any browser (eg, my phone), and external to the LAN (eg, on the internet) from which schedules for temperatures can be set, and historical data (actual room temp, setpoint, outdoor temperature) can be viewed in graphs. The web interface was written using Nancy, a lightweight web app framework. It’s no longer maintained, but it does what I need to do, and as per its own description, it’s very low ceremony and was easy to get up and running. The frontend communicates with my service backend via websockets to make a reactive web app.
It’s been a fun project, as it’s really touched every part of development – hardware, software, C, C++, C#, websockets, css/html, Javascript, SQLite (for backend storage), 3d printing (for enclosures and such) and more.
Obviously based on the last time I published, I’m terrible at adding content to my website here, but I wanted to capture a high level summary of the project for reference. I may do a more deep dive into specific aspects of the project at a future point. Or probably not, knowing me.
Non-exhaustive list of things I used while developing this are:
- ardunio PID library
- Visual Micro (arduino development for visual studio)
- Nancy
- MetricsGraphics.js for graphing in webapp
- SQLite
- Vue.js (reactive js framework)
- V-Calendar
- SSD1306 for the small ui framework used on the thermostat display
- mouser.ca, digikey.ca for ic components and aliexpress for step-down converter, nodemcu esp8266s and oled displays
- The MCU: https://www.aliexpress.com/item/32810410131.html
- The relay: https://www.seeedstudio.com/Grove-SPDT-Relay-30A.html
- The voltage stepdown converter: https://www.aliexpress.com/item/32396325166.html
- The screen: https://www.aliexpress.com/item/32780054633.html
- The temp sensor (some variant of this): https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf