Close
0%
0%

ThermPi

A Raspberry Pi thermostat for my heat pump, with presence detection

Similar projects worth following
I'm building a smart thermostat for my heat pump using a RasPi. I plan to have a web interface, temp/humidity/runtime/mode logging via SNMP and Cacti, and presence detection to save energy when nobody's home.

Definitely still a work in progress. I'm still working on the power supply and physical connections for now. I spent some time experimenting with the software aspects, triggering the relays, reading values from the temp/humidity sensor, and in general learning how the RPi works. I also set up several SNMP capabilities: read adult presence served up from my firewall, read outside temp/humidity, send indoor temp/humidity to my Cacti server.

I plan to use the heat pump's own 24VAC thermostat transformer to power the Pi through the rectifier, filter cap, and voltage regulator. The 24VAC transformer I bought from Radio Shack to test and tune the regulator circuit (before hooking up to the heat pump) seems to be bad, though.

It will determine whether my wife and I are present using our smartphones. If we are both gone, the tstat will switch to a lower-energy mode, keeping the house above the pipe-freezing level in winter, and below 90degF in summer. It will also provide information to Cacti allowing me to correlate indoor and outdoor temps and humidity, as well as see operation modes and runtimes. It'll also have a schedule interface.

The heat pump is fairly standard: single-stage cool, single-stage heat with aux and emergency heat. Thermostat hooks up via 7-wire interface (2 power @ 24VAC + 5 triggers: fan, compressor, refrigerant reverse, aux heat, emergency heat). I'm kinda hoping I can add an 8th wire to get status back from the indoor unit (which I think simply indicates when the blower is running, but I don't know); it will help with triggering things at the right time and with tracking energy usage. The fan tends to run for a few minutes even after all relays are opened.

That's the basic plan for this project. Now I just need to find time and fix my AC transformer.

  • 2 × Raspberry Pi 3 B+
  • 6 × SainSmart Solid-State Relay 1x Quad & 1x Dual
  • 1 × SenseHAT Used for temp/humidity/barometer, and maybe the LEDs as an alert signal
  • 1 × PiFace Digital 2 To interface the SSRs to the Pi attached to the heatpump. I may also use one of the digital inputs to track when the condensation drainage pump runs, and may also add leakage detection.

  • Things that make me see (node) red...

    Nelson Butterworth05/10/2017 at 05:38 0 comments

    As I've worked on this project over the last 3 weeks or so, I have made several attempts at 2 different features:

    1. compressor inhibit timer, and
    2. refresh fan timer

    You'd think these would be simple to implement, but they've been kicking my butt. I finally built a workable solution for #1, but #2 remains elusive at this time.

    Most compressor-driven refrigerant systems require a minimim cycle time in order to prevent premature compressor failure. For some heat pumps and air conditioner units, 5 minutes is recommended as the minimum time for the compressor to be on before turning back off, or the minimum shut-down time before another cycle turns the compressor back on.

    Node-RED has 2 built-in timer type nodes; a delay, and a trigger. The delay takes an input message, and delays it for the set amount of time before passing it to the next node in the execution path. The trigger node emits a message upon receiving an input, then waits for a set amount of time before sending a second message. This sequence could start by emitting a true, then waiting for a few minutes before emitting a false, for instance.

    The compressor cycle timer needs to allow the compressor to switch from stop to run, or run to stop, then wait for the set amount of time before allowing another run change; i.e. if stopped, let it start, then wait at least 5 minutes before letting it stop again. My first attempts quickly showed that I could not directly insert the timer directly into the execution path between other logic and the compressor's GPIO pin; for instance, every time any signal passed through the path to the pin, it would trigger the delay, even if the logic were sending a run command to an already running compressor.

    So I realized that I needed to loop the timer's output back into the logic function node and flip an inhibit flag there. After several attempts, I have a solution that seems to work well enough. I've also effectively dampened most sources of repeated triggers to the various GPIO outputs, which were causing some other issues throughout the thermostat logic.

    As for feature #2, the refresh timer, I've given up on it for the time being. The idea is to run the fan periodically to recirculate stale air and rebalance temperatures in all the rooms, without running the compressor. In fact, the refresh cycle shouldn't run at all until at least an hour has passed without any other heat pump cycles running. I've tried a few arrangements of doubled-up delays and triggers, but none of them have worked. I think I'll have to add some code here, as well, just like the compressor cycle timer required. However, it's not a critical feature, so I'll just leave it alone for now.

  • It's been a long, long time...

    Nelson Butterworth05/10/2017 at 04:13 0 comments

    ...but I've finally made significant progress on my smart heatpump thermostat. I got my hands on several RasPi 3's, and I'm using 2 of them for this project. I might later reduce that to the single unit I originally intended to use, but for now 2 is the ticket. I have been working with Node-RED and MQTT (using mosquitto) for most of the last 3 weeks or so, and the results are pretty nice so far.

    Here's where I am now, after more than a year of nothing:

    1. One RasPi 3 will be connected to the heatpump via a half-dozen solid-state relays. I plan to use a PiFace Digital 2 to bridge the GPIO header to the SSRs. A Node-RED flow runs here to toggle the relays and interface with the main thermostat logic.
    2. The second RasPi 3 will be placed in the location of my current digital thermostat. This one will connect to a temperature sensor (planning on a SenseHAT for the time being, as well as a touchscreen LCD. A Node-RED flow runs here to send the SenseHAT environmental data out to the rest of the system, with an additional flow for testing behavior across different temperature ranges. The SenseHAT includes an 8x8 array of RGB LEDs, which I might use as an additional signal for alerts (an actual "red alert"!).
    3. Ubuntu 16.04 Server machine running Node-RED and mosquitto server. The main Node-RED flows run here: main thermostat logic, display UI using Node-RED dashboard, processes to retrive current weather conditions and any weather alerts for my area, display statistical graphs, and initialize some parameters. Using Node-RED dashboard, I have developed several pages to display weather conditions, 3-day forecast, some statistical graphs, and the main thermostat controls, which I can display on any browser on my network. Mosquitto/MQTT is used to coordinate data communications between the 3 component systems.

    Current feature set:

    • Display current weather conditions, including barometer, solar radiation and UV, 3-day forecast, solar and lunar cycles, and wind speed and direction. This data comes from the WeatherUnderground API, updated 4 times per hour.
    • Display indoor temperature and humidity.
    • Display temperature setpoint and heatpump operating status.
    • Display an alert to change the air filter. Buttons to set reminders for 30- and 90-day filters.
    • Display a modal dialog upon receipt of any weather alerts provided by WUnderground, push an alert via PushBullet, and speak the text audibly.
    • Set the desired temperature, enable/disable the entire system, set/unset away mode, manually engage the fan or emergency heat mode.
    • Automatically switch between heat and cool modes based on the season.
    • Automatically engage auxilliary heat if the interior temperature falls too quickly for the first stage to keep up, or if the outside temperature drops below 40° F, as heatpumps are not effective below that temperature.
    • Away mode: switch to a lower-energy operating mode. Engage cooling when interior temp reaches 80° or heat when interior drops to 55°.

    Some features still to come:

    • Scheduling interface (though this may not be necessary with presence detection)
    • Presence detection: Automatically switch away mode on and off based on presence determined by smartphones.
    • Refresh mode: if the system has been completely idle for at least an hour, run the fan for up to 20 minutes to equalize room temperatures and recirculate stuffy air.
    • Track operating time each month, display when each mode is used and correlate to indoor and outdoor temperatures.
    • Voice activation via Alexa or others.

    I'm also working on the display screen. I have an old 17" Dell LCD that runs 1280x1024 resolution. I hope to upgrade it to use LED backlighting and replace the existing VGA-only with an HDMI interface capable of playing audio. Then I can mount it as a single unit on the wall in the hallway where the current thermostat is.

    I'll throw some screenshots of the web dashboard and some of the Node-RED flows into the project gallery.

  • Long gaps and short diversions

    Nelson Butterworth03/14/2016 at 16:28 0 comments

    The tstat project is currently on indefinite hold, merely because life and stuff got in the way. The Pi is currently set up with Raspbian Jessie and a Python script that allows it to use Amazon's Alexa Voice Service. This is mainly an educational diversion to show to the students in the computer class I teach, but since the AVS ToC requires any non-Amazon device to use a physical button to trigger the service rather than a voice wakeup, it is of limited usefulness. I hope that during Spring Break, which is in about 2 weeks, I will be able to restart the ThermPi project, though I still need a 24VAC transformer to build the power supply. Now that Radio Shack is bust, I'll have to head into a nearby city for one of the local electronic supply shops.

    I will be making one change to the presence checking. Instead of reporting who is present, my SNMP setup will simply report whether anyone is present. Later revisions might enable different rules based on who is home, but out of the gate, overall presence detection is more important than identifying people and preferences.

  • State of the Stat Address

    Nelson Butterworth01/20/2015 at 18:10 0 comments

    Thus far I have no real project logs. I have acquired most of the hardware components I'll need, and I've experimented with the RPi to learn how to interface with the SSRs and the temperature sensor. When I am able to spend more time on building circuits or writing code, I'll add more log entries.

    I purchased a switchable 18/24VAC wall-wart transformer so that I could begin building my power supply, but apparently I got a dud. And of course I can't take it back because I clipped off the interchangeable tip socket instead of getting the tip with bare leads. So I'll have to open it up and try to fix it.

View all 4 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates