Home automation is a big word in today’s times because everyone wants to make their life easier. Controlling lightning, music, alarm systems or the air conditioning automatically transforms your home in a real smart home. Accessing all these functions over the internet gives you a very comfortable feeling when you are away. In the following, I will explain how I set up my own little smart home by using the Raspberry Pi as the main home automation system.
What inspired me to turn my home into a smart home?
Since I was a child, I was fascinated by movies like Star Trek or Iron man, which use a computer to perform a bunch of tasks. Moreover, coming home and having the lights turn on immediately seems to be a nice idea, or using your smartphone to make sure that everything is turned off at home when you are on a trip gives you a safe feeling.
When you search online for smart home equipment, you will find a variety of different products from different companies. However, here is the problem. Every company has its own tech and there is no international standard yet that makes it possible to connect all these different systems to each other. For this reason, I wanted to develop my own system, which allows me to control different things (light, fan, entertainment system) at home by using a touch screen, my phone or my voice.
In the following, I will show you in three simple steps, how you can create your first simple smart home.
Step 1: How to control your devices with a Raspberry Pi?
You need three things to start:
Connecting the 433 MHz sender to the Raspberry Pi
You need three jumper cables to connect the 433 MHz sender to the Raspberry Pi (see figure below). Connect VCC from the sender to pin 2 (5V) on the Raspberry Pi. Furthermore, connect GND to pin 6 and DATA to pin 11 (GPIO 17). To increase the range of the 433 MHz sender, you can attach a wire to the sender (ANT). The optimal length of this wire is 17 cm.
Installing the software
You need two software packages to control your wireless sockets with the Raspberry Pi. The first one is called WiringPi, which is important for programming and setting up the GPIO pins. To install this package, just follow the instructions here.
The second one is named Raspberry-Remote and allows you to turn your wireless sockets on and off by a simple terminal command. To install it, you just need to execute the following commands:
git clone git://github.com/xkonni/raspberry-remote.git
Controlling the wireless sockets with a simple terminal command
First, you have to figure out which channel your wireless socket is receiving signals on. On the back of the wirless socket is a little cover that you can open to see how the DIP switches are set. The first five DIP switches (A,B,C,D,E) set the main code. The next four (1,2,3,4) set the channel. For example, if the seetings are 10111 0001, it means that your main code is ACDE and the channel is 4. To turn this specific power outlet on, just execute the following command:
sudo ./send 10111 4 1
To turn it off, use:
sudo ./send 10111 4 0
That’s it! Now you know how to control your power outlets and connected devices (lights, fan, entertainment system) with your Raspberry Pi!
Step 2: Controlling your devices with a touchscreen interface
To give you an example of how to use a touchscreen as an interface for the Raspberry Pi, I chose the Raspberry Pi Touchscreen. A helpful tutorial about setting up the touchscreen is given here. A good start is the two button example, which I used in the video above. Just click on the following link to download my Python code.
Step 3: Using an Amazon Echo to control your devices
The most comfortable way to control your devices is by using your voice. This can be done simply by using the Amazon Echo, as shown in the video above. However, there are different ways to make this possible. One way is to write your own Alexa Skill with the disadvantage being that you need a trigger word to activate the skill before you can turn your devices on or off.
A much easier way is described by FabricatelO. His solution works without any trigger word. The trick is that a server runs on your Raspberry Pi, which pretends to be a WeMo device. That allows you to execute any command on the Raspberry Pi just by linking it to a device name. And then you can execute this command (e.g. turning on a wireless socket by using the command:
sudo ./send 10111 4 1) by just saying „Alexa, device on“. This works very well and is fast! Setting it up is surprisingly easy, just follow the introduction here.
Thanks for reading!