Smart Home by Raspberry Pi




Introduction: Smart Home by Raspberry Pi

There are already several products out there that makes your flat smarter, but most of them are proprietary solutions. But why do you need an internet connection to switch a light with your smartphone? That was one reason for me to build my own Smart Home solution.

I programmed a server application that runs on a Raspberry Pi. This is a java based open source project that allows you to configure your flat and connect several clients and 'controllable units'. I show a solution that handles rc power supply switches, plays music and video on the Raspberry Pi, shows the status on smart mirror and can be controlled by an android app and two pebble apps. The source is hosted on github

Step 1: Things You Need

To set-up the Smart Home, you need the following 'ingredients'

Additionally, you can extend the Smart Home with more optional clients and units like this

Step 2: Prepare Raspberry Pi for 433 MHz

In the following steps you need access to the command line on the Raspberry Pi. To get the access you can read this instructable

Connect the 433 MHz sender with the Raspberry Pi as shown in the picture above

  • GND (sender) <-> 6 GND (raspi)
  • VCC (sender) <-> 2 +5V (raspi)
  • DATA (sender) <-> 11 GPIO 17 (raspi)

Please also connect a 17cm antenna to the ANT (sender) pin. That increases the signal significant.

Since we need some libraries from other git repositories, we have to install git

sudo apt-get install git-core -y

To set up the Raspberry Pi for 433 MHz communication we need the wiring Pi library for better handling of the GPIOs.

git clone git://
cd wiringPi

Then we need a library that implements typically rc power supply protocols.

git clone git://
cd rcswitch-pi 
cp send /usr/bin/ 

The 'send' executable allows you to send codes to switch most of the available power supplies.

In my Smart Home setup i also have a rc LED strip described by this instructable: To set colors for this LED strip you need another sending executable that allows you to send any Integer value (That encodes the color).

Therefore, compile the sendInt.cpp in the rcswitch-pi repo and move it to /usr/bin/sendInt.

sudo g++ sendInt.cpp -o /usr/bin/sendInt /home/pi/rcswitch-pi/RCSwitch.o -I/home/pi/rcswitch-pi -lwiringPi

Now you should now be able to send rc commands with the two executables /usr/bin/send and /usr/bin/sendInt

Step 3: Setup Smart Home Server

First of all you need to install several packages. The Smart Home application is java based and runs fine with openjdk-11. I am not sure about other java runtime environments. The mplayer is a minimalist command-line music player. The omxplayer uses the Raspberry Pi graphics for video encoding, so this should be used for videos. The program ant is needed to build the java application.

sudo apt-get install mplayer omxplayer openjdk-11-jdk ant -y

Setup directories for the jar file and for logs.

sudo mkdir /opt/neo
sudo chown pi:pi /opt/neo 
mkdir /home/pi/Logs

Configure start script to start the application automatically on boot. Therefore copy the attached smart-home script into the directory /etc/init.d/ I also created a script in /usr/bin/ that pipes commands to the attached script, so i just enter smart-home to the console to execute commands.

sudo cp smart-home /etc/init.d/smart-home
sudo chmod +x /etc/init.d/smart-home
sudo sh -c "echo '#! /bin/bash' > /usr/bin/smart-home"
sudo sh -c "echo '/etc/init.d/smart-home \$1' >> /usr/bin/smart-home"
sudo chmod +x /usr/bin/smart-home
sudo update-rc.d smart-home defaults

Now it is time to checkout the repository and build the application. If you don't want to compile it yourself, you can just download the attached smarthome.jar and move it to /opt/neo/

git clone
ant -f SmartHome/ build_remote
cp SmartHome/* /opt/neo/

Try to start the smart-home and check the log file. To get access for the GPIOs, the application must be started by sudo.

sudo smart-home start
cat Logs/smarthome.log

You should see the error message Configuration file does not exist that points us to the next step. The repository contains a readme that explains the configuration file. You can see this nicely rendered at github:

Copy this xml to /home/pi/controlcenter.xml, then set the location for your media server and change the content as you need it. Once you have finished the configuration and restarted the smart-home (sudo smart-home restart) you should see the following content in the smarthome.log

24.05-08:26 REMOTE INFORMATION by de.neo.smarthome.cronjob.CronJob@15aeb7ab: Schedule cron job
24.05-08:26 REMOTE INFORMATION by [trigger.light]: Wait 79391760 ms for execution
24.05-08:26 RMI INFORMATION by Add web-handler (5061/ledstrip)
24.05-08:26 RMI INFORMATION by Add web-handler (5061/action)
24.05-08:26 RMI INFORMATION by Add web-handler (5061/mediaserver)
24.05-08:26 RMI INFORMATION by Add web-handler (5061/switch)
24.05-08:26 RMI INFORMATION by Add web-handler (5061/controlcenter)
24.05-08:26 RMI INFORMATION by Start webserver with 5 handler (localhost:5061)
24.05-08:26 REMOTE INFORMATION by Controlcenter: Add 1. control unit: MyUnit (xyz)

The web-server is now running :-)

Step 4: Setup Clients

Smartphone Android client

The git repository for the smart-home application also contains the source for the android client, so you can compile it yourself. But I attached the APK for this step, that makes it easier. The first time you start the app, it asks you for a server, like in the first image above. Enter the url of the server and the security token.

That should be it. You now have access to the server and control your flat, playing music and watch videos remotely on your Raspberry Pi. Note that you can add widgets to your homescreen, that makes switches and music-control more accessible.

Smartwatch Pebble client

The source for the two pebble clients is hosted on github. One app shows the current playing music file: This also allows you to pause/play and volume up/down.

The second app triggers three actions: The trigger-names are: mobile.come_home mobile.leaving and mobile.go_to_bed. If you define event-rules for this trigger in your configuration-xml you trigger them by your watch.

It's all open-source, but you don't need to compile it yourself, I also attached the pebble apps. Download the PBW's with your smartphone, your phone should install them on your watch. The pebble apps need configurations to talk to the server. I attached a screenshot how my settings look like.

Smartwatch Garmin client

There is also a client available for Garmin Smartwatches. The app is available in the garmin connect app-store and can be installed here:

Smart Mirror client

I already created an instructable that explains how to create the Smart Mirror, see this .The source code is also hosted on github: software of the Smart Mirror reads the configuration from the file smart_config.js that is not part of the git repository. The content of the configuration file should look like this listing:

var mOpenWeatherKey = 'your-open-wheather-key';
var mSecurity = 'your-security-token';

You also have to adjust the first two lines of the file smart_mirror.js to specify the Smart Home server ip address and the location to get the right weather.

More clients

The server application is a simple web server. This enables you to trigger actions from any client you want to by simple web-calls. In the demo-video i show the android app tasker in combination with AutoVoice. This enables me to trigger events with simple voice commands. For example "ok google, time to sleep" can trigger mobile.go_to_bed. But you can also do web-calls for example from IFTTT. How about a yellow blinking LED strip for email notification?

You can ask the server for possible web-calls like following links (replace ip, port and token by your configuration)






Step 5: Conclusion

There are still some features to implement: Since the server provides just a simple web-api clients do a lot of polling. To reduce the polling I want an MQTT integration for better notification. Also wifi power supplies should perform more reliable than rc power supplies since rc is just a one way communication.

It makes a lot of fun developing for this project. And it is pretty cool to control the flat by several devices, even if the internet connection breaks down.

Power Supply Contest

Participated in the
Power Supply Contest

Internet of Things Contest 2017

Participated in the
Internet of Things Contest 2017

Be the First to Share


    • Big and Small Contest

      Big and Small Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • For the Home Contest

      For the Home Contest


    Shivanng Puri
    Shivanng Puri

    5 years ago

    I saw your instructable and i was like WFT!! Your idea is almost the same as what i was planning for a few months!! And I'm glad i found a help!!


    Reply 5 years ago

    Hey cool, I'm glad to hear


    Reply 2 years ago

    hey can you teach me because it so hard