View
5
Download
1
Category
Preview:
Citation preview
Monitoring and steering a central heating pumpRaspberry Pi, 433 Mhz transmitter,
temperature sensors and Google Docs
About myself
- Edward van Hazendonk, 43 years- ICT Specialist at I-bridge (a Randstad
company) RHCE, CLP- Hobbies:
- Photography- Electronics (things started to get interesting again
with Raspberry Pi and Arduino availability)- http://van-hazendonk.net- edward@van-hazendonk.net
The problem
- house with central heating which runs under floor heating with allways on pump
- when no heat is requested/provided, pump in floor heating system still keeps running which pushes cold water through the pipes, which cools down the floor
- pump of central heating is no way near feeder of hot pipe
- causes cold feet, I hate cold feet
The workaround
- Raspberry Pi- 433 Mhz transmitter / receiver- pilight to the rescue- Rev/Ritter (klikaan/klikuit) mains switch- 2 temperature sensors, onewire- google docs (spreadsheet) as monitoring- Python script and a bit less cold feed- PiCobbler- bits and pieces joint together from Internet
The parts
- Raspberry Pi- Running Raspian (Debian Wheezy with Raspberry
addons) http://www.raspbian.org/- pilight http://www.pilight.org/- gspread https://github.com/burnash/gspread- SDcard
The sensors
- DS18B20- TO-92 housing- low cost- simple design- pull-up resistor 4k7 gpio
4 and 3v3- gpio 4 to pin 2 (TWI on
RPi)- multiple connected to
same wires, easy setup
The transmitter
- cheap ASK 433Mhz transmitter/receiver- handmade antenna gets good results http:
//www.elektor.nl/Uploads/Forum/Posts/How-to-make-a-Air-Cooled-433MHz-antenna.pdf
- pilight makes it work the easy way
Transmitter and receiver on RPi- 5 V for range- gpio 17 transmit- gpio 18 receive
- gpio 4 TWi for DS18B20
The receiver
- Rev Ritter 433Mhz (klikaan/uit clone)- comes with own remote (needed for sniffing
the code)
The code 1-wire# modprobe w1-gpio
# modprobe w1-therm
$ ls /sys/bus/w1/devices
10-00080201e1e3 10-00080201eed0 w1_bus_master1
$ cat /sys/bus/w1/devices/10-00080201eed0/w1_slave
25 00 4b 46 ff ff 05 10 5d : crc=5d YES
25 00 4b 46 ff ff 05 10 5d t=18437
“temperature is 18.4 degrees Celsius”- Used two sensors connected to the warm
and cold water pipes running through my house
pilight setupFor info: http://www.pilight.org/getting-started/settings/cat /etc/pilight/settings.json
{
# important parts (if I remember correctly)
"mode": "server",
"send-repeats": 10,
"receive-repeats": 1,
"gpio-sender": 1,
"gpio-receiver": 0,
"hw-mode": "gpio",
The code pilightGot raw code via pilight-debug command and clicking on remote http://wiki.pilight.org/doku.php/pdebug# 3 aan
sudo /usr/local/sbin/pilight-send -p raw -c "169 507 169 507 169 676 169 507 169 507 507 169 169 507 507 169 169 676 507 169 169 507 507 169 169 676 507 169 507 169 507 169 169 676 169 676 169 507 169 676 169 676 169 507 507 169 507 169 169 5746"
# 3 uit
sudo /usr/local/sbin/pilight-send -p raw -c "169 507 169 507 169 507 169 507 169 507 507 169 169 507 507 169 169 507 507 169 169 507 507 169 169 507 507 169 507 169 507 169 169 507 169 507 169 676 169 507 507 169 507 169 169 676 169 507 169 5746"
Monitoring
The code, WiP#!/usr/bin/python
import os, glob, time, gspread, sys, datetime
#Google account details
email = '@gmail.com'
password = ''
spreadsheet = 'Temperature' #the name of the spreadsheet already created
#attempt to log in to your google account
try:
gc = gspread.login(email,password)
except:
print('fail')
sys.exit()
onderwaarde = 24
bovenwaarde = 50
#open the spreadsheet
worksheet = gc.open(spreadsheet).sheet1
#initiate the temperature sensor
os.system('/usr/bin/sudo /sbin/modprobe w1-gpio')
os.system('/usr/bin/sudo /sbin/modprobe w1-therm')
#set up the location of the sensor in the system
device_folder = glob.glob('/sys/bus/w1/devices/10*')
device_file = [device_folder[0] + '/w1_slave', device_folder[1] + '/w1_slave']
def read_temp_raw(): #a function that grabs the raw temperature data from the sensor
f_1 = open(device_file[0], 'r')
lines_1 = f_1.readlines()
f_1.close()
f_2 = open(device_file[1], 'r')
lines_2 = f_2.readlines()
f_2.close()
return lines_1 + lines_2
def read_temp(): #a function that checks that the connection was good and strips out the temperature
lines = read_temp_raw()
while lines[0].strip()[-3:] != 'YES' or lines[2].strip()[-3:] != 'YES':
time.sleep(0.2)
lines = read_temp_raw()
equals_pos = lines[1].find('t='), lines[3].find('t=')
temp = float(lines[1][equals_pos[0]+2:])/1000, float(lines[3][equals_pos[1]+2:])/1000
return temp
tijd = time.localtime()
rij = (((tijd[3] * 60 + tijd[4] ) / 5) + 10)
acell1 = "A" + str(int(rij))
acell2 = "B" + str(int(rij))
acell3 = "C" + str(int(rij))
acell4 = "D" + str(int(rij))
temp = read_temp() #get the temp
if temp[0] > onderwaarde and temp[0] < bovenwaarde:
pomp = "aan"
os.system('/home/pi/pompaan.sh')
else:
pomp = "uit"
os.system('/home/pi/pompuit.sh')
worksheet.update_acell('A2', datetime.datetime.now())
worksheet.update_acell('B2', temp[0])
worksheet.update_acell('C2', temp[1])
worksheet.update_acell('D2', pomp)
worksheet.update_acell(acell1, datetime.datetime.now())
worksheet.update_acell(acell2, temp[0])
worksheet.update_acell(acell3, temp[1])
worksheet.update_acell(acell4, pomp)
Security
- Google docs two factor authentication- API password still covers whole account and
rights to all Google services- sudo for pilight commands- use a cronjob for switching your pump on
and off for 5..10 minutes every day to keep it from locking up in summer time
- protect pump for water which is too hot
Todo
- calibrate better (room thermostat temperature and floor aren’t connected) how to combine under floor and plate heating
- exchange pump for lower energy consumption from 75W to 5..12W
- figure out how to connect to a modulating central heating thermostat to Raspberry Pi
- better graphs/code
References
- great selfbuild lowcost antenna design for 433 Mhz http://www.elektor.nl/Uploads/Forum/Posts/How-to-make-a-Air-Cooled-433MHz-antenna.pdf
- https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing
- http://www.pilight.org/- http://www.raspbian.org/- https://github.com/burnash/gspread- http://www.instructables.com/id/Python-and-Raspberry-
Pi-Temperature-Sensor
Solved issues
- broken antenna in wire isolation caused some split hairs and rebuild of circuits :(
Questions ???
Recommended