World of Cheese

k 14 április 2020

Improving HomeHeating

Posted by Andy in Tech   

Its been several years since our house's heating has been controlled by my python heating system. It has been modified over the years and now consists of 3 rpi

  1. Thermostat controller with temperature problem (Gen 1 RPi)
  2. Temperature probe and IR video (RPi Zero)
  3. Schedule server, a service running the on rpi3 server

It works 90% of the time but there is a problem where the thermostat keep falling off the network. The only problem was that it could happen at any time of the day/night. Definitely not a winter experiment! So, now is the time to find the problem

First changes

The wifi option on gen1 Rpi

The RPi zero seems to be indestructible and manages an uptime of weeks using its dodgey onboard wifi. The Thermostat pi has been using a usb dongle, which I suspect is dropping connections and not playing nicely with power manangement. I've now swapped this out for a TP nano router which the pi talks with via ethernet. It is slightly more energy expensive but I'm hoping this will improve the uptime.

Moving Gunicorn/nginx to use sockets.

I was lazy and just used ports to connect gunicorn to nginx on the Schedule server. However, this worked fine for testing but upon system restarts, the gunicorn/nginx systemd startup order was out of sync. This would require a manual resetting of both services in a particular order in order to get the webpage interface up again. I've moved to using sockets just so that reboots are less painful.

Next step

The next steps are to port the remote services to go/gRPC. This will provide motivation for using/learning new language/features. Python and go are gRPC friendly so I can deploy a service in go and read it in python. This means I don't need to rewrite the whole scheduler code in go but just add gRPC functionality The new remote systems should use lower system resources as currently the remote services lazily using flask/gunicorn/nginx to provide a very simple REST response service. I'll then publish my new code on github.

Current Strategy

  1. Construct/install Mage structure. This is the all singing dancing go build package (think make but nice1) which would enable building RPi binaries from windows/Linux. In my experiences of projects, it is always better to start the way you intend to finish. I hope my go skills will improve but this structure should help me write better from the start
  2. Make simple go service which reads temperature/turns on/off Thermostat
  3. Integrate the gRPC service into the current python app.

    
 
 

Comments