I'd like to present my recent project of using a Pi 3 to realize an automated humidity controlled ventilation system for my cellar. The basic idea is to measure temperature and relative humidity both inside the cellar and outside, calculate absolute humidity from these values, and then turn on the ventilation if absolute humidity outside is lower than inside.
Since I'm not much of a hardware tinkerer and didn't want to drill holes into my outer wall, I opted for ready made parts for the sensing and controlling work. Measurements are made by two wireless sensors ASH 2200
by german electronics company ELV:
The Pi gets the sensor readings through a USB receiver WDE1-2
(ELV as well). Two fans (intake and exhaust) are then controlled via a USB power strip Energenie EG-PMS2
I've also gotten a Tontec case with 3.5" touchscreen
for the Pi (first of my Pis to ever have some kind of display attached, the two others are headless). This is what the setup looks like on our cellar shelf (USB receiver at the top):
The software is mainly a collection of scripts (bash and python). A shell script checkrecsensors.sh is started via cron @reboot. This calls a python script recsensors.py which in turn reads temperature and relative humidity via USB, calculates absolute humidity and dew point (formulas taken from http://www.wetterochs.de/wetter/feuchte.html
) and stores all values in RRD databases. If recsensors.py terminates for any reason, checkrecsensors.sh logs the return code and then starts it again in an endless loop.
The core of the system is another python script, fanctl.py, which understands the following commands:
on,off - to turn the fans on or off
lock [on|off] <duration in seconds|"inf"> - to lock the fans to the given state temporarily or permanently
unlock - to remove a previously set lock
cron - the script is called with this command every 3 minutes via cron. It then gets the last values from the RRD database, checks the fans' lock status and turns them on or off accordingly. It also produces some charts and a small HTML snippet showing the current readings and fan status - these are stored on a tmpfs RAM disk to save the SD card from wear.
A small Tkinter GUI is running on the touch display that shows the current values and fan state, a small graphical display of the last 24 hours, and allows manual switching/locking and unlocking of the fans:
(Keller - cellar, Aussen - outside, TP (Taupunkt) - dew point, RF/AF (Relative/Absolute Feuchte) - relative/absolute humidity, Lüfter - fan, An/Aus - on/off)
(Lüfter einschalten für? - Turn on fan for?, Minuten - minutes, Stunden - hours, Tage - days, Wochen - weeks, entsperren - unlock, Abbrechen - Cancel)
Some larger graphs, for longer periods and including daily and monthly averages, minima and maxima, are displayed via a simple web site served by nginx. The site allows the same controls as the interface on the device:
(Further translations on demand, I think the screens are pretty self-explanatory.)
The system's been running for upwards of a month now and has proven quite reliable. Unfortunately, ventilation is not as effective as I hoped for so I'll probably have to think of some other measures as well, but it's a start.
What's still lacking is some kind of monitoring of the system. I'll possibly look into Icinga for that when I get around to it. For now, regular eye ball monitoring will have to do.
The complete code is available on Bitbucket:
If anybody wants to adapt it to their needs or wants to realize something similar, I'll be happy to help.