Skip to content

Raspitherm - Raspberry Pi based heating controlled, in Python 3

Notifications You must be signed in to change notification settings

michaeljtbrooks/raspitherm3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspitherm

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

Optional requirements

  1. DHT11 or DHT22 sensor
  2. A third 3.3v compatible MOSFET if you want to be able to reset the temperature / humidity sensor
  3. A fifth 47k resistor as a hardware pull-up if you want to be able to reset the temperature / humidity sensor
  4. A 100nf (0.1µF) capacitor to remove any noise that gets onto the temperature sensor power line

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.

You should specify the GPIO pins you are using in the config.py file.

Update Dec 2022:

I've added an optional temperature and humidity sensor. The code works with DHT11 and DHT22 sensors. The sensor needs its own GPIO input pin to read the data line of the chip.

DHT11 and DHT22 sensors are notorious for locking up after several hours, which is why I've also included a bit of circuitry and code to reset the sensor if it starts timing out. You will need another GPIO pin set up as output, which switches another MOSFET on to provide power to the temperature sensor. When the code detects a misbehaving sensor, it will cut the power to the temperature for 20 seconds, forcing the sensor to reset. It will then be readable again until the next lockup.

Software Installation - automatic

  1. Become root
sudo su
  1. Run the install.sh server script
chmod +x ./server_scripts/install.sh
./server_scripts/install.sh

Software Installation - manual

  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 python-setuptools python3-setuptools
  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-pip3
sudo pip3 install virtualenv
  1. Create a virtual environment to run Raspiled in, and activate it
python3 -m venv ./env
source ./env/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.

If you have a temperature sensor attached, you'll see the last known temperature and humidity with each page refresh.

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:

  • Interfacing to Homeassistant
  • 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

About

Raspitherm - Raspberry Pi based heating controlled, in Python 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published