/raspitherm

Raspberry pi controlled hot water / central heating

Primary LanguagePython

This repository is for Python 2 only and is deprecated. The Python 3 repository is here: Raspitherm3

Raspitherm - Python 2

Raspberry Pi controlled hot water / central heating

Raspitherm Web Interface

What is this?

Raspitherm is a Python based controller for heating programmers. It allows you to turn your hot water and central heating on and off, via a very easy to use touch-friendly web interface.

  • Turn on and off your hot water
  • Turn on and off your central heating

Requirements

  1. Python & this repository
  2. A network capable Raspberry Pi or Pi Zero W
  3. A heating programmer with status LEDs you can tap, and manual override buttons you can emulate the press of. e.g. Danfoss FP715
  4. 2 x MOSFETs 3.3v logic compatible. I suggest IRLZ34N
  5. 4 x optoisolator gates
  6. Prototyping matrix board / PCBs
  7. 5V DC power supply to drive the Raspberry Pi
  8. Pigpio to provide you with software pulse width modulation
  9. 2 x 100R (one hundred ohm) current limiting resistors for input channel optoisolator LEDs
  10. 2 x 500R (five hundred ohm) current limiting resistors for output channel optoisolators
  11. 4 x 47k pull-down resistors

Hardware circuitry

Here's the circuit I used to connect to my Danfoss FP715S controller:

Raspitherm Interface Circuit

Broadly speaking you have two input channels, and two output channels, each operating via an optoisolator to keep the Raspberry Pi and heating programmer separate.

Each input channel is monitoring the voltage across an indicator LED on the programmer. It drives an optoisolator which puts 3.3V into an input pin in the Raspberry Pi. One channel for hot water, the other for central heating. Each output channel is emulating a button press. It switches an optoisolator on which shorts one side of the manual override button to its other side (thus emulating a button press).

Therefore you need a heating programmer that has indicator LEDs, and manual on/off toggle buttons. You need to tap the programmer's PCB.

Software Installation

  1. Get Raspian or Ubuntu running on your Raspberry Pi, with network connectivity working, and install essential packages:
sudo apt-get install build-essential unzip wget git
  1. Install pigpio (see http://abyz.me.uk/rpi/pigpio/download.html)
wget https://github.com/joan2937/pigpio/archive/master.zip
unzip master.zip
cd pigpio-master
make
sudo make install
  1. Download this Raspitherm repo to your Raspberry Pi
  2. SSH into your Raspberry Pi. Change to the directory where you saved this repo
  3. Install python virtual environments
sudo apt-get install python-pip 
sudo pip install virtualenv
  1. Create a virtual environment to run Raspiled in, and activate it
virtualenv ./
source ./bin/activate
  1. Install this repo's dependencies (may take 1- mins on a Raspberry Pi
pip install -r ./src/requirements.txt
  1. Find out your Raspberry Pi's IP address:
ifconfig
  1. Modify ./src/raspitherm.conf: change the constants for the Pins match which pins are you inputs and outputs for the hot water and central heating. PI_PORT should be left as 8888 as this is what Pigpiod is configured to use. If the file isn't present, run python ./raspitherm_listener.py to generate it.
  2. Run the Pigpiod daemon:
sudo pigpiod
  1. Run the Raspitherm server:
python ./src/raspitherm_listener.py
  1. On your smartphone / another computer on the same local network, open your web browser and head to: http://<your.raspberry.pi.ip>:9090 e.g. http://192.168.0.233:9090 in my case
Optional stuff

If you want the Raspberry Pi to boot up and automatically run Raspitherm, you can add this command to /etc/rc.local:

/path/to/your/virtualenv/python /path/to/your/raspiled/src/raspitherm_listener.py

e.g. assuming you installed it in the /opt directory

/opt/raspitherm/env/bin/python /opt/raspitherm/src/raspitherm_listener.py

Web Interface

http://<your.raspberry.pi.ip>:9090

Practically idiot-proof! Click the radiator switch to turn the central heating on and off. Click the tap (faucet) switch to turn the hot water heating on and off.

That's it!

Feel free to download the code, dick about with it, make something awesome. I am trying to create a home automation empire out of Raspberry Pis. You are very welcome to contribute.

Here are some ideas for improvements:

  • Time based controls: You could set your programmer to have no on/off signals at all, then have the Raspberry Pi control it all (might need realtime clock if precision is your thing or the ntp daemon isn't working)
  • Antipatory heating: The Raspberry Pi could download a weather forecast and fire up the heating only on the days when you are at home and it's likely to be cold
  • Smart thermostat: Use a digital thermometer input to measure the temperature in the house, and use this to drive the Raspberry Pi's heating control
  • IFTTT bindings: need to be careful about auth here, but you could have "if my phone location says I'm leaving work, turn on my hot water"
  • Alarm linkage: When you're at home and have an alarm set, ensure the hot water + central heating goes 30 mins before your alarm is due to sound. Great for shift workers / erratic schedules!!

With thanks to