When my wife and I had our first child last winter, we got an electric space heater to keep the area immediately around our baby girl nice and warm. As we moved from room to room, we brought the heater with us, all the while thinking we were being super efficient having point-of-use climate control. A month later we get an electricity bill twice our normal amount and realize it would have been cheaper to just heat the whole house with the gas furnace around the clock.
Winter is upon us again, so this time I upgraded to a WiFi thermostat so I can turn on the heater while I'm downstairs or warmly tucked under the covers. This is much more convenient, but we're still heating the whole house even though most of the time we're all in one part of the house.
Looking at our motion sensor logs that control our lighting, it's pretty obvious that we spend 4-5 hours downstairs as a family after work, and then go upstairs to our bedrooms around 9pm where we sleep until we leave the next morning for work. Weekends are a little different, but Monday through Friday works like clockwork (especially with a 10 month old on a strict sleep schedule).
I've looked at HVAC systems that have multi zone temperature monitoring and wirelessly controllable duct baffles, but the hardware is very expensive and all the software looks like it was an afterthought (with little support or updates as technology gets better). I already have some WiFi enabled temperature sensors in my house for point of use AC unit controllers and have been itching for a reason to use some small servos in a project. All I need are WiFi connected servos that can open/close duct vents in my HVAC system...should be easy enough.
MediaTek's new LinkIt Smart 7688 Duo HDK is a WiFi connected microprocessor running OpenWRT with an onboard arduino-compatible microcontroller. It's perfect for this project since it has all the I/O pins needed for multiple sensors and servo motors plus WiFi capability to communicate with my existing temperature sensors. Also, since it already has OpenWRT installed with uHTTPd, I can run the WebApp directly on the LinkIt Smart 7688 HDK for a completely self contained package.
This is my first time using a board that has built in WiFi, so I was preparing for a steep learning curve. Fortunately, setup is literally 3 steps:
- Power up the Linkit Smart 7688 and connect to its WiFi access point from your computer
- Log in to the web interface and enter the settings for your WiFi access point
- Add the "LinkIt Smart 7688 Duo" board in the Arduino IDE
That's it! When you select the "LinkIt Smart 7688 Duo" board in the Arduino IDE you can either push your sketch via serial like every other board, or you can upload over WiFi (this will come in very handy later). The Linkit Smart 7688 getting started guide and developers guide may be helpful for you as well.
If you want to allow the microcontroller to use the WiFi directly in your arduino sketch (which we will be doing), you just ssh into the HDK and flip a bit to enable the Arduino Yun library compatibility.
You can just copy/paste the lines from here:
uci set yunbridge.config.disabled='0'
Since this has built in compatibility with the Yun bridge library and uses the Arduino IDE, it's really easy to adapt existing code. Using the bridge library, I can have the HDK poll the onboard web server for the vent configuration (either upstairs, downstairs, or whole house) and then adjust the two servos accordingly. In the below video I had this running on a Raspberry Pi 2, but I was able to port the WebApp over to the LinkIt Smart 7688 to make it even more efficient (code included at the end).
My WebApp runs on php, so I just used opkg package manager to get it installed since it's included in OpenWRT on the LinkIt Smart 7688:
opkg install php5-cgi
I then updated the /etc/config/uhttpd file to interpret php by adding this line:
list interpreter ".php=/usr/bin/php-cgi"
and restarted uHTTPd
I attached the servo horn directly to the vent and fabricated an aluminum bracket to hold the servo in position with some stainless steel standoffs. There is still a little play, so I'll be adding some zip ties to make this a little more permanent.
This build really boils down to three components:
- Temperature sensors around the house send periodic updates to the uHTTPd web server running on the LinkIt Smart 7688.
- A WebApp running on the LinkIt Smart 7688 that shows the current state and allows you to manually reconfigure the vents.
- The MCU on the LinkIt Smart 7688 that controls the vents to direct warm air either upstairs or downstairs depending on the time of day.
The temp sensors are just ATtiny85s or Arduino Nanos connected to a DHT11 or DHT22 and sending that temperature/humidity information to a web server via an ESP8266 over software serial. I have a full writeup on those sensors on here since they were originally designed and developed as phase II of my point-of-use air conditioner project (this part is completely optional, but it will give you additional metrics that can be used to tune the system and eventually automate it).
The LinkIt Smart 7688 HDK itself is in my attic connected directly to the duct vents. On the OpenWRT side a cronjob updates the vent state text file. The MCU side running the arduino sketch checks this text file periodically and adjusts the vents accordingly.
# Open downstairs vent at 3pm on weekdays
0 15 * * 1-5 /bin/echo 1 > /www/vent.txt
# Open both vents at 6pm on weekdays
0 18 * * 1-5 /bin/echo 0 > /www/vent.txt;
# Close downstairs vent at 9pm on weekdays
0 21 * * 1-5 /bin/echo 2 > /www/vent.txt;
# Close upstairs vent at 9am on weekdays
0 9 * * 1-5 /bin/echo 1 > /www/vent.txt;
To check the status of the vents and manually reconfigure them, I created a small WebApp that is hosted directly on the LinkIt Smart 7688. With dyndns and port forwarding I can view and control all of this from outside the house if I need to.
With the nights already getting colder, I needed to get this working ASAP so some concessions were made in the name of rapid deployment. On the hardware side, I'll be 3d printing proper mounts for the servos since my hack-job mounts have a little play. Also, the little RC servo I used in the demo has all plastic gears which I don't expect to last for years, so since I don't want to be climbing back in the attic anytime soon, I'm going to be swapping them out for larger servos with metal gears.
I may one day add additional WiFi connected servos to vents in each room and have them all connect back to the single LinkIt Smart 7688.
Currently the temperature probes are only dumping the readings to a csv file so I can easily track and graph it. It would be nice to kick on the heater early if the house is particularly cold, but my WiFi thermostat doesn't have an API yet. I would also like to tie into my home automation system so the vents automatically adjust based on real time room occupancy derived from motion sensors rather than being entirely based on time of day (especially for weekends because of our dynamic schedules).