Raspberry-Fritzbox Presence Triggered Heater Controller

by Mopick in Circuits > Raspberry Pi

1710 Views, 15 Favorites, 0 Comments

Raspberry-Fritzbox Presence Triggered Heater Controller

IMG_9028.JPG
IMG_9031.JPG
IMG_9029.JPG

Hello,

with this project I wanted to save energy consumption in my flat. It is big and often nobody's there, and with this stupid-standard-heater-controller I only could insert one timeframe for the day for the heater to stay on, so often the heater would run without anybody being there waisting energy, which I hate.

I wanted presence-detection. And I've figured out how to do it and works so nicely. The heater runs only when someones there and in the night it goes off at a specified time which can be different for each day also.

Presence detection works like this: with the IMAC-number of your smartphone the WLAN-Status can be read out of the fritzbox with the raspberry-pi via WLAN. Depending on the presence status (means: Smartphone is connected to WLAN) which was found, the heater controller triggers a servo, which then puts the heater physically on or off.

You need:

  • raspberrypi with WLAN (and power-source 5V min. 1A)
  • a Fritzbox-router (otherwise I dont now how to get the online-status)
  • a servo, some cables, two LEDs, a Push-button with a suppression-condensator (dont be scared)

This is my first instructable and I hope you can understand it. Im really proud of how well it works. If there are questions I will try to answer them.

Setting Up the Raspberry-pi

Unbenannt.PNG
rcconfig.PNG
anwesenheit_text.PNG
starter.PNG

You should have some basic knowledge on how to programm the raspberry pi. I controlled it finally via my Windows-Laptop over Tight-VNC and I recommend that first of all you get to controll your raspberry pi via WLAN from another machine. THis makes setting up much more comfortable, while the raspberry-pi is near the heater station.

After this, you need to get installed the hm_pdetect of Jens Maus on your raspberry.

HM_Pdetect

This script mainly reads out the online-status of the fritz-box and puts the outcome into a text-file. I took this work to integrate it in my project. So, my Python-program reads out this textfile of hm-pdetect, which has the presence status in it. Everything is in one folder and the files you will have in the folder will look like in the picture.

In hm_pdetect.config you put the MAC-Adresses of the the smartphones you want to detect and also the password and username for accessing the menu of Fritzbox. Each MAC-Adress is coupled with a name. In the presence-text-file (in my case "Anwesenheit1") you can then read the name and the status "present" or "away". The hm_pdetect.sy-File you don't have to touch.

So try to get this running first, so that if you open the presence-text-file you will see the status. I provide the files too, but in any case this doesn't work, please refer to the page of Jens Maus.

After this you should put the file "heizungssteuerung.py" in your folder and try to understand it.

Sure you want to autostart the whole process after each reboot. And you need to have the right time. Raspian is a bit grumpy and doesn't get the right time of the internet just like this. So you have to put somethin in the autorstart menu.

To get acces there: type in the shell:

sudo nano /etc/rc.local

There you have to add the lines I provided in the second picture. This makes gettin the right time and it starts the script "starter.sh" (also in the folder). This starts the hm_pdetect (which then continues to retreive the presence-status) as well as the "heizungssteuerung.py". Also it sets the presence-text-file ("anwesenheit1") in to a read-write-modus (If not you will get an error).

Please check in "heizungssteuerung.py" where to connect the LEDs, the push-button and the servo! (it is written in the beginning).

Connect the Servo and the LEDs and the Push-Button

The servo takes also the 5V of the USB-Powersource. So connect Plus/Minus and the PWM to the right output-channel of the Raspberry (refer to internet instruction for connecting a servo).

LEDs -> please also refer to internet instructions to connect them.

Push-Button -> Should be easy -> please also read how to connect it. DON'T forget the DE-interference-condensator (100µF). In the first-run I didn't have this tiny one and a relais in my home just triggered the GPIO-Pin of the raspberry "wirelessly". It was hard search to find out.

Bould somethin to hold the servo, so that it pushes the button just right.:)