Raspberry Pi Home Automation

50,169

190

30

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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!!

Raspberry Pi Contest 2017

Participated in the
Raspberry Pi Contest 2017

Wireless Contest

Participated in the
Wireless Contest

4 People Made This Project!

Recommendations

  • Finish It Already Speed Challenge

    Finish It Already Speed Challenge
  • Arduino Contest 2020

    Arduino Contest 2020
  • First Time Author Contest

    First Time Author Contest

30 Discussions

0
MihaiL8
MihaiL8

Question 8 months ago

for more butons in app mypi

0
MihaiL8
MihaiL8

Question 8 months ago on Step 5

for more butons in app

0
galgamar
galgamar

Question 1 year ago on Step 5

I made It!!
please help me to Make online when I'm out my network
tanks

0
JosephineM15
JosephineM15

Question 1 year ago on Step 3

I got the "authentication failed, wrong password" error alot and if I restart Pi and app it works....Now have another problem, after connecting, it will not send commands to Pi - I get an error "you are using old version of MyPi server, please update to the latest version"
the link above only has this one version

Screenshot_2018-10-27-16-58-08-43.png
0
MeghV1
MeghV1

2 years ago

When I run python3 mypi_server.pyc

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

0
AldwindarwinM
AldwindarwinM

2 years ago

Hi sir does the MyPi Application runnable for Android OS?

0
DivyanshJ2
DivyanshJ2

Reply 2 years ago

Yes

0
aldwindarwin
aldwindarwin

Reply 2 years ago

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

0
DivyanshJ2
DivyanshJ2

Reply 2 years ago

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.

0
aldwindarwin
aldwindarwin

Reply 2 years ago

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?

0
DivyanshJ2
DivyanshJ2

Reply 2 years ago

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.

0
aldwindarwin
aldwindarwin

Reply 2 years ago

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...

0
DivyanshJ2
DivyanshJ2

Reply 2 years ago

That will be great...

0
aldwindarwin
aldwindarwin

Reply 2 years ago

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

0
DivyanshJ2
DivyanshJ2

Reply 2 years ago

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

0
aldwindarwin
aldwindarwin

Reply 2 years ago

thank you sir :)

0
aldwindarwin
aldwindarwin

Reply 2 years ago

Hi sir what's the update of your Mypi application?

0
DivyanshJ2
DivyanshJ2

Reply 2 years ago

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

0
aldwindarwin
aldwindarwin

Reply 2 years ago

okay sir i'm still waiting!