Posts with «pyserial» label

HAL is Duct Tape for Home Automation

When it comes to home automation, there are a lot of different products out there that all do different things. Many of them are made by different companies, and they don’t often play very well together. This frustration ultimately led [Daniel] to develop his own Python based middleware solution to get these various components to work as a single cohesive system. What exactly did [Daniel] want to control?

First up was the door lock. [Daniel] lives in an apartment building, so there are actually two locks. First, a visitor must be allowed into the building by pressing a button on the intercom system in the apartment. Second, the apartment door has its own dead bolt lock that needs to be opened and closed. [Daniel] was able to control the building’s front door using just a transistor hooked up to an Arduino to simulate the press of the physical button. The original button remains in tact so [Daniel] can still easily “buzz” in a visitor.

The apartment’s dead bolt was a bit trickier. There are off-the-shelf solutions to control a dead bolt, but they are often expensive. [Daniel] built his own solution using a simple servo motor bolted to the door. The servo is controlled by the Arduino which is in turn controlled via two broken intercom buttons that already existed within the apartment. The buttons were originally used to either speak to or listen to a visitor before buzzing them into the building. They had never worked for [Daniel] so he re-purposed them for his own project. The whole DIY door locker is enclosed in a custom-made laser cut wooden box.

Click past the break for the rest of [Daniel's] story.

When it comes to lighting, [Daniel] has a couple of different brands of automated light bulbs in his apartment. One brand has bulbs that are controlled by a radio frequency signal. That brand comes with a converter box that can accept lighting commands via WiFi. It also uses a simple API that allowed [Daniel] to easily control all of the bulbs from his Python code. The second brand of light bulb did not have a simple API. After some searching around, [Daniel] found an open source project called ouimeaux. Ouimeaux is a Python library that allows you to control this particular brand of automated light bulbs. This was perfect for [Daniel] since he was already using Python in his project. With this library it was trivial for him to control the lights from his web interface.

As a proof of concept, [Daniel] also built a custom WiFi enabled power outlet using a SparkCore module. He has an entire separate post dedicated to that project.

For the brain of the system, [Daniel] chose to use a Raspberry Pi. The Pi runs a web server with a Flask based back-end system. Flask allows him to code the website in Python, which meant he could easily write a website that can interact with the various automation components. The Pi can directly communicate with all of the off-the-shelf components using the various Python libraries. For the door lock, the Pi communicates with the Arduino via pySerial. [Daniel] also used Flask OAuth to limit access to the system to only authorized users. Now whenever [Daniel] wants to turn the lights on or unlock the door for a visitor, all he has to do is press a button on a web page.

[via Reddit]


Filed under: home hacks