Raspberry Pi Home Automation

21,704

143

25

Introduction: Raspberry Pi Home Automation

About: I am a high school student interested in coding and electronics. I am currently trying to teach myself python. As I am in high school I can only make projects once in 2-3 months right now I am working on a n...

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

  1. 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
  2. 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
  3. Jumper Wires :- To connect the relay to the Raspberry Pi. Female to Female Jumper Cables
  4. Power Adapter :- Any micro usb adapter will work as long as it is 5v 1A. 5v 1A Micro Usb Adapter

Total:- 52$

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.

Enjoy!!

2 People Made This Project!

Recommendations

  • Tiny Home Contest

    Tiny Home Contest
  • Creative Misuse Contest

    Creative Misuse Contest
  • Metalworking Contest

    Metalworking Contest

25 Discussions

0
None
MeghV1

3 months ago

When I run python3 mypi_server.pyc

I get the error RuntimeError: Bad magic number in .pyc file

sir does the controller Mypi application need an internet or just a network of a router?

It works on just the network of the router. Through the app you connect to the pi's using its ip address and so it can just work of the router's network.

can i control the relay even if i'm outside of the house? for example when i'm in school can i turn on/off the relay?

That is not integrated right now but you can look forward to that in 2-3 days I am going to update this instructable and add a few more functions like that. You can follow my channel or just check back in few days to see the update.

im gonna wait with the update controller Mypi sir by connecting to wifi internet to be able to turn on/off relay even you are not home...

Can you message me sir? if it is already update for the wifi connection of the controller
Mypi

Final few things and trial is left. Max it will take 2 days and you will see the existing instructable updates.

I apologize for the delay and this has to be further delayed 2-3 days as the test was not very successful. Unfortunately

it keeps telling me i typed in the wrong password

0
None
jduf

9 months ago

Is it evolutive ?

How can I add new controls/commands on the interface and the server ?

Seems that solutions based on nodered are more customizable.