Introduction: Raspberry Pi Home Automation
Raspberry Pi is a single board computer for 35$ it is very versatile and given its small size it can fit in basically anywhere. I will walk you through the process of making a Home automation system using MyPi app. This app is very simple and is free to download on IOS/Android/Windows.
Step 1: Parts
- Raspberry Pi :- Any Raspberry Pi will do but if you take any other than model 3 then you will have to buy a usb internet adapter or go wired like i had to in my Raspberry Pi 2. This tutorial shows the steps of wireless home automation only. Raspberry Pi Model 3
- Relay Module :- I have used 2 channel relay but you can go upto 8 channel relay as supported by the MyPi app. Any more relays than 8 channel will require another app or a new webpage. 2 Channel Relay Module
- Jumper Wires :- To connect the relay to the Raspberry Pi. Female to Female Jumper Cables
- Power Adapter :- Any micro usb adapter will work as long as it is 5v 1A. 5v 1A Micro Usb Adapter
Step 2: Setting Up Your Raspberry Pi
Connect the Raspberry pi to an internet and assign the pi a static ip address.
Open the terminal in the Raspberry Pi, And type
pi@raspberry :~ $ Sudo apt-get Update (this may take time)
pi@raspberry :~ $ cd /home/pi
pi@raspberry :~ $ ls
pi@raspberry :~ $ wget www.ioslinks.com/mypi/server.zip
pi@raspberry :~ $ ls (check the above server.zip file should be added in the directories)
pi@raspberry :~ $ unzip server.zip (this will unzip the the directory)
pi@raspberry :~ $ python3 mypi_server.pyc
Wire the relays 5v to Pi's 5v
Gnd to Pi's Gnd
Channel 1 to pin 7
Channel 2 to pin 11
Step 3: Setting Up the App
Open your MyPi app and go to settings.
Put your Pi's Ip address and change the port to whichever port the pi is searching devices on (after the last command it should say listen for incoming connections on port and then the port number).
Go ahead and test your system by switching on or off in the app and check if the relay is switching on off.
Do not turn off the Raspberry Pi right now proceed to the next step so that the Pi runs this script every time its powered on.
Step 4: Making This So That It Runs This From the Start
Disconnect from the app by selecting disconnect in the MyPi app.
In the Raspberry Pi type .....
Open your MyPi app and go to settings...........
pi@raspberry :~ $ sudo nano /etc/rc.local
in the directory go between where it is written "fi" and exit 0 and type
python3 /home/pi/mypi_server.pyc &
save and exit the file ( the'&' is in the code not a mistake). After this reboot the Pi by typing
pi@raspberry :~ $ sudo reboot
Step 5: Final Testing
You no longer need to keep your Pi attached to a monitor. After the reboot just open the app and press connect you should be connected to your Pi and be able to control the relays.
Please post your pictures if you made this yourself.
Feel free to ask questions.
2 People Made This Project!
We have a be nice policy.
Please be positive and constructive.