By   February 13, 2015

My journey had several goals. One of these was to learn Python. I’ve been able to do all the programming I’ve ever needed using “C” and Assembly language with a bit of shell scripting on the side. None of these languages was going to suit me well for this project. I liked the speed with which a person can prototype an idea in a higher level language. My friend Kurt is a huge proponent of Python and also a lot more up on current intarwebs technologies than I. So I dove into Python. Kurt thinks of me as a quaint old man so his assistance comes with a small amount of mocking and irreverance. No matter. I know how to code, but I occasionally need realignment as to which direction is correct when it comes to REST, object oriented design, etc.

After some prototyping, and some prototype AVR based hardware from Jeff, I was able to read from an I2C temperature/humidity sensor, turn relays on/off, and read from an SPI Thermocouple amplifier. Already this had many potential applications! A person could conceivably smoke meat on a BBQ with a motorized vent, or roast coffee in a repurposed breadmaker. It was certainly possible to write Arduino code to do these things but it was quicker and easier to just drag&drop some logic elements from Snap! and quickly debug the process. Here’s a simple Snap! program to control a linear motor hooked up to a BBQ with a thermocouple to sense the temperature inside the bbq as well as a thermocouple to sense the meat temperature.

One of the reasons I chose Snap! over something like Blockly was that Snap! logic blocks run in the browser. One of the nice side effects of this is that you can interactively debug your code and even click on an input or output and have an action occur immediately. For example, I can click on the icon of one of my temperature sensors and read the temperature interactively:


Now came the next step. There is some hardware that is just easier to buy than it is to build:

The Etherrain has a rain sensor and 8 valve outputs:


The TR60 thermostat has lots of goodies:


I can see what the indoor temperature is, outdoor temperature, how long the furnace has run in the last 5 minutes, what the current setpoint is, whether the fan is on, and I can set the current temperature setpoint (for either heat or cool).

Since my cottage is out in the woods, cellphone reception is not always awesome. Since I have an amateur radio license, I can legally transmit APRS packets. So I have an APRS transceiver connected to my server as well. I wrote a plugin for that as well, so I can send/receive messages from Snap!:


With the above, I am able to do some interesting things fairly simply:



There are two logic blocks there. The upper one collects the humidity and temperature from a piece of Jeff’s hardware that lives in the Office out at the cottage. It also queries the TR60 thermostat for various bits of information and builds a string that is sent out as an APRS packet to the APRS-IS network where I can monitor it remotely. The lower logic block queries the TR60 thermostat to see what the current setpoint is and takes some action depending on whether the temperature is set to warm or cold. I am using the thermostat as a sort of occupancy sensor. When we set the temperature to 70F, I also want to have the hot-water recirculation pump turned on.