“More than one-third of all homes in New Zealand have mould and damp issues, with homes in the South Island in particular not being heated properly,” a University of Otago professor is reported to have said in a 2008 newspaper article. And earlier this year, in June, the death of a toddler died was linked to living in a cold, damp home.
There are many commercial options for ventilation and heating systems, but most are very expensive and many families can’t afford one.
Our home ventilation system, which was controlled by a desktop computer, had not been working for six years. I would like to get it working on a microcontroller or Raspberry Pi.
In my previous version I used the Arduino microcontroller to run the model, where I ran the model fans on 12V, which is legal, but running it on 240V (how much a real roof fan would have to be run on) wouldn’t be. Installing this system in your house would be illegal and void your insurance. I heard about a WiFi controlled switch which can be controlled by your computer, called the WeMo Switch. It can be controlled by the WeMo phone app and you can also download a program which enables you to run it off your computer through your home WiFi. This would make the wiring legal. The Arduino doesn’t have a built in WiFi connection, so I will have to use the Raspberry Pi.
In this version I will use the Raspberry Pi, the WeMo Switch, with DS18B20 temperature and the DHT22 humidity sensors to control the ventilation system.
Open Source – My Solution
I have decided that my project to make a low cost easy DIY system will be open source and the design and code will be freely available on the internet. My code uses open source libraries and the design follows other designs on the internet.
I want my project to help other people to learn about coding and be a real working system that will help New Zealand homes be drier and warmer, improving peoples living condition for less than $500.
Step 1: Raspberry Pi Set Up
Put a SD card into the Pi. Plug in the network cable (internet). Plug in mouse and monitor. Connect the power (a USB charger).
Once hardware is set up you can set up the software.
Download Raspbian (from https://www.raspberrypi.org/downloads/) and write to a SD card. I used Win32DiskImager (from https://www.raspberrypi.org/downloads/)
Boot & setup
In the initial configuration screen (raspi-config)
· 1) Expand File System
· 3) Enable Boot to Desktop
(for Python Programming)
· 4) Internationalisation Options
I1) Change Locale (optional)
I2) Change Timezone (optional)
I3) Change Keyboard Layout (optional)
· 8) Advanced Options
A6) SPI (needed for LCD)
When you have restarted the Raspberry Pi, at a terminal prompt
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade #optional
sudo rpi-update #optional firmware update
I had trouble with the web browser, so I installed Firefox (called IceWeasel on the Pi). This is optional.
sudo apt-get install iceweasel
Setup the GPIO library. I got instructions from https://learn.adafruit.com/adafruits-raspberry-pi... This is actually not needed anymore because it is included in the new versions of Raspbian.
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio
Step 2: Temperature Sensors (DS18B20)
Test each sensor by wiring into breadboard and connecting it to power. Wire both of the temperature sensors to RJ45 connecters and then into the Home Net in the roof. The sensors need a pull-up resistor (about 4.7k Ohm – only one per bus) between Data and Vcc. The One Wire Bus can have many sensors on the same data line.
On the Pi edit the config.txt
sudo nano /boot/config.txt
and then scroll to the bottom and type there
Then reboot the Raspberry Pi. Download the w1thermsensor library.
sudo apt-get install python-pip
Step 3: Humidity Sensors (DHT22)
The sensors need a pull-up resistor (1k-5k Ohm –one per sensor) between Data and Vcc. These sensors can have one sensor on a data line.
I tested the humidity sensors to find the most consistent, because the first two were very inconsistent and inaccurate. You probably need to test several sensors to find some that are consistent.
I wired up five sensors side by side and ran a program that read all the sensors. There was up to a 10% difference between sensors
This is nowhere close to the 2% accuracy they are supposed to be. I found a website (http://www.kandrsmith.org/RJS/Misc/calib_dht22.html) that showed tests for these sensors. The results were that those sensors were more accurate than mine, but that they could fail after about a year. After running them for a few hours of using them I found that they often give wrong results or no results. I had to write a function to handle these problems.
I think that these sensors are so bad that to make reliable system I would have to find more reliable humidity sensors.
The instructions are from https://learn.adafruit.com/dht-humidity-sensing-o...
sudo apt-get update
sudo apt-get install build-essential python-dev python-openssl
sudo python setup.py install
Step 4: WeMo Switch
Follow the instructions to set up the WeMo. This is necessary to set it up so it will conect to your local network and useful because you can control the fan from your cellphone and it can update the WeMo firmware.
The Wemo library is available from https://github.com/iancmcc/ouimeaux/
At a terminal prompt on the Pi
sudo easy_install ouimeaux
Step 5: LCD Screen (Nokia 5110 With PCD8544 Controller)
LCD Screen (Nokia 5110 with PCD8544 controller)
Plug the screen into the breadboard and wire it to the correct GPIO pins. Check the pin layout on your LCD, as they can vary. Check the instructions at https://learn.adafruit.com/nokia-5110-3310-lcd-python-library
Make sure SPI was enabled in the initial Raspberry Pi setup.
sudo apt-get install python-imaging
sudo apt-get install git
git clone https://github.com/adafruit/Adafruit_Nokia_LCD.git
sudo python setup.py install
Step 6: Home Net
The home net cabling used to wire the sensors to the Raspberry Pi.
My " Home Net" (RJ45 using T568B colours)
1 Orange stripe - Data 3 - DHT22_1
2 Orange - Data 1 - not connected
3 Green Stripe - Vcc - Vcc
4 Blue - Data 0 - DS18B20
5 Blue Stripe - GND - GND
6 Green - GND - GND
7 Brown Stripe - Data 4 - not connected
8 Brown - Data 2 - DHT22_2
Step 7: Installing It in the Roof Space
I went into the roof of my house and plugged the WeMo switch into the power socket in the roof. I then plugged the fan into the WeMo switch. Next I ran a LAN cable under the house and put one end through the floor to plug it into the Raspberry Pi. The other end I ran into the roof and plugged the cable into the Home Net socket. Then I plugged both temperature and humidity sensors into the Home Net socket. I tied the temperature and humidity sensors to a beam near the peak of the roof and put the room temperature and humidity sensor through the wall near the ceiling, into the room with the fan vent.
Step 8: Download My Code From GitHub
Download My Code from GitHub
This code will need to edited especially for your DS18B20 IDs. there are test programs in the test_code directory that will tell you the IDs of your sensors.
Have Fun, feel free to ask questions