Introduction: Smart Home With Arduino

Picture of Smart Home With Arduino

Hello.

I will show you how to build your own smart home. It shows the temperature both inside and outside, if the window is open or closed, shows when it rains and make alarm when the PIR sensor senses move. I made the application on the android to display all the data (you can also watch it on browser). You can see temperature in your home and other information from all over the world! Application is translated to english and polish. I built it because I wanted to make my own smart home and control it. If you want, you can make your own smart home, all you need is parts (listed below) and a lot of desire. So let's get started.

Explanation of acronyms for beginner:

GND - ground

VCC - power

PIR - move sensor

Step 1: Parts

Picture of Parts

All the parts cost me $90

-arduino

-ethernet module ENC28J60

-thermometer DS18B20 x2

-microphone module

-rain sensor

-PIR sensor

-reed switch

-relay

-resistor 4,7k Ω

-twisted-pair cable

-ethernet cable

-tools (soldering, screwdriver)

Step 2: Connection

Picture of Connection

Above I added picture from fritzing with connection. If you have a problem with it leave a comment.

Step 3: Program

First you need to do is download, extract and import this library to arduino IDE. And download 1Wire library from here, Dallas temperature from here and import them to arduino IDE too. You can upload this program to your arduino. In the comment is an explanation of the code.

Step 4: How It Works?

Picture of How It Works?

When you click refresh in your app or in browser Arduino sends data to smartphone/browser. Application gets source code from each page ( /tempin, /tempout, /rain, /window, /alarm) and displays it on your phone.

Step 5: Appliaction for Android.

Picture of Appliaction for Android.

To instal app on your android phone you need to make this (you can see it on the picture above):

1. the firs first step is download smartHome.apk file

2.Send apk file to your phone

3.Open file manager and locate smarthHome.apk file

4.Click on it and click install (if you have enabled the option to install applications outside the google play you need to turn it on)

5.You have finished the installation, you can enable the application



Application is translated to english and polish. In browser you can turn on and off light but in app not because I can't do that, sorry.

Step 6: Application Configuration

Picture of Application Configuration

I'll explain how the application works. It's shows all data from your home. You can click on settings icon to edit your IP address and turn on or off alarm. When you turn on alarm, app get data from PIR sensor in service and if it's detected move in your home it's make a notification. App retrieves the data from the motion sensor every minute. In IP field you must enter your IP address. You can check it here.

Step 7: Browser

Picture of Browser

Type in your browser your ip / all. There you can see all the data and turn on and off light.

You can use this instead of the application on android.

Step 8: Port Forwarding

Picture of Port Forwarding

You need to open port on your router. Open your router configuration and set arduino ip and open port 80. You can see it on image above.

Step 9: NO IP (optional)

Picture of NO IP (optional)

You can set up an account at no ip but this is not necessary. In the picture above you can see how to configure it.

Step 10: Test It!

If you want to see the data on your computer you can do this by typing into your browser yourip / all (e.g. 12.345.678.901/all) or use android application.

Remember to leave a comment and click favourite if you like my project :)

Step 11: EDIT: Android App Source Code

Because many people asked me about android source code I add it below.

Comments

sahilg45 (author)2017-05-07

i am getting server timed out error while connecting thorugh browser also the relay is continuously connecting disconnecting. please help

mnichrudolf (author)2017-01-13

Hello,

I still have an error in the compilation. Someone has an idea what to change?

Arduino:1.6.12 (Windows 10), Płytka:"Arduino/Genuino Uno"

In file included from C:\Program Files (x86)\Arduino\libraries\etherShield/etherShield.h:25:0,

from C:\Users\admin\AppData\Local\Temp\untitled921585978.tmp\sketch_jan13a\sketch_jan13a.ino:16:

C:\Program Files (x86)\Arduino\libraries\etherShield/ip_arp_udp_tcp.h:32:66: error: 'prog_char' does not name a type

extern uint16_t fill_tcp_data_p(uint8_t *buf,uint16_t pos, const prog_char *progmem_s);

^

In file included from C:\Users\admin\AppData\Local\Temp\untitled921585978.tmp\sketch_jan13a\sketch_jan13a.ino:16:0:

C:\Program Files (x86)\Arduino\libraries\etherShield/etherShield.h:34:65: error: 'prog_char' does not name a type

uint16_t ES_fill_tcp_data_p(uint8_t *buf,uint16_t pos, const prog_char *progmem_s);

GeeksTipsDotCom (author)2016-12-27

Interesting but this is not smart ... its just playing with Arduino cheap modules. Also you could use a ESP8266 Arduino WiFi module instead of ENC28J60. You can find here more about what smart house should be. Thank you for your work!

ShyamM11 (author)2016-10-30

can you send the video of your prototype

hasmilazlan (author)2016-09-10

can i know the block of this app in appinventor?

AndrewJ110 (author)2016-08-05

CAn i know the code for this project on the W5100 shield?

TarekM2 made it! (author)2016-07-17

G.T

pallaviaris (author)2016-05-26

Please can u tell spesifically which changes u have in code for the w5100 shield?

AckapT (author)2016-05-12

if (strcmp(params,"all")==0) /// what this parameter "all" ????

Halil SelimG (author)2016-05-03

How can I send to the measure value of soil moisture to android phone with ethernet module (enc28j60)?

Is it possible?

Halil SelimG (author)2016-05-03

I need your arduino code which You already write on ardunio ide

ZulR (author)2016-04-28

Thanks for the instructions. I made it but, I used different Ethernet shield which is W5100. It doesnt need special library, just use the libraries provided by Arduino IDE. Just need to make over the code. Fortunately, it works like a charm!

Nikus (author)ZulR2016-04-28

Great!

ahmedsaad.zizou (author)2014-12-22

We are in the process done an excellent project and thank you and hope to stay in touch with us

Thank you thank you thank you thank you Nikus

hello brother Ahmed.
am doing this same project but am stuck in ethernet module.
can u plz share the details of it. currently am using arduino mega and Ethernet shield module W5100,so if u have the sketch and connections ..plz share it ..thank u ...!
my email : mirzzz21@gmail.com

yasserm9 (author)mirza19942016-03-11

please if you find solution i need it , the same proplem ,

yassermunther2003@yahoo.com

KemalB1 (author)2016-02-04

Thank you for your sharing. I want to ask somethings:
after use "no ip" are we need to adjust port setting on router or not? For example if my dynamic "no ip" adress is "127.253.252.80" and can we use directly in our arduino code as like this ?
static char myip[127,253,252,80] ;
And second question about forwarding:
for example my arduino adress is "192.168.0.200" and after that in my router to setting this adress like this "192.168.0.200:8080 or :8181. So can ı use this adress outside of my network? For example ı want to check one of sensor situation in my home when ı am out side of home. Than ı write this 192.168.0.200:8080. Can ı see to sensor position?

stanisławb (author)2016-01-22

Hi

I've got some problems with code. Can you help me please, because I'am new in arduino.

C:\Users\biale\Downloads\smart_home\smart_home.ino:146:30: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

ethernet.print("</center>");

--> a lot of problems how this.

C:\Program Files (x86)\Arduino\libraries\etherShield/ip_arp_udp_tcp.h:32:77: error: ISO C++ forbids declaration of 'progmem_s' with no type [-fpermissive]

extern uint16_t fill_tcp_data_p(uint8_t *buf,uint16_t pos, const prog_char *progmem_s);

--> this,

C:\Program Files (x86)\Arduino\libraries\etherShield/ip_arp_udp_tcp.h:32:66: error: 'prog_char' does not name a type

extern uint16_t fill_tcp_data_p(uint8_t *buf,uint16_t pos, const prog_char *progmem_s);

--> this

In file included from C:\Program Files (x86)\Arduino\libraries\etherShield/etherShield.h:25:0,

from C:\Users\biale\Downloads\smart_home\smart_home.ino:16:

--> and this.

AbdulW7 (author)2015-11-26

Hi ther. I am stuck at ethershield library. I have tried 100s new downloads. the new ethercard works. can anyone tell how can i mod to the code to ethercard library?

AbdulW7 (author)2015-11-21

Hi can anybody help me with a strange problem. I am using all the same equipment. the code doesnt give any error but the module doesn't take IP from the router, I have tried 3 different routers, IPs and ports. It just happens when I am using the "ethershield" library. when i use ether card library or the UIP library the modules takes the IP and example sketches work. now I have two options.

Ether I change the code to newer "ethercard" liberary or I fix the problem. I have been struggling for weeks. any help will be much appreciated

Nikus (author)AbdulW72015-11-21

Which arduino do you use?

AbdulW7 (author)Nikus2015-11-21

I m using leonardo.

karimsw (author)2015-03-24

hi, nikus. the library problem has been fixed, now i have problem with the app source code, can you tell me which the source code in arduino IDE to declare between arduino and app? how to connect it? thanks

Nikus (author)karimsw2015-03-24

You not need to change app code, install it on your phone only. Go to the android app click settings (on the top on right) and here in edit text write your ip address where your arduino is connected. Click save and now it will probably work. If not try to make connect by browser if still not working try to open ports on your router.

karimsw (author)Nikus2015-03-24

ok, i will try it. i replaced ethernet module ENC28J60 with arduino ethernet shield W5100 because ENC28J60 can't ping when i used local network, but arduino ethernet shield W5100 successful. source code from you can work with arduino ethernet shield W5100, isn't it? and can it work if i use local network or usb modem? thanks

Nikus (author)karimsw2015-03-31

No, this code is rather not compatible with your ethenet controller. Sorry for delay but I hadn't time because I work on my next project.

karimsw (author)Nikus2015-04-01

are you serious? it can work if use ENC28J60 only?

ok, no problem. sorry if i disturbing you :)

Nikus (author)karimsw2015-04-03

I don't say no. I do not have W5100 so you need to check it. Maybe you need to change a little this code. I don't know it but I hope it can work. No problem you not disturbing me. Good luck

karimsw (author)Nikus2015-04-03

ok. i have W5100 and ENC28J60, but ENC28J60 always error with library. where the code will be change? Arduino IDE or App?
ok thank you nikus :)

mirza1994 (author)karimsw2015-11-14

heloo brother,

am currently doing this project. and i bought Ethernet shield W5100.
jst want to confirm with u. is that works with this shield? if yes, please tell where to change in the coding part. would be helpful if u share ur experience.
my email : mirzzz21@gmail.com

joury (author)Nikus2015-04-08

Hi Nikus, I have final project about smart house by motoring the doors, widows, lights, electricity,etc. and control them by using mobile interface and contect them by using wifi network. So, please If you have any idea about this help me. Thanks.

UğurA3 (author)karimsw2015-10-15

how did u solve library problem?

VegardO (author)2015-11-11

Hello!

Is it possible to make changes to the application file? Would be nice to change the text to something more specific in my project. For example, change from "Window" to "Door". If so, how do I do this?

Best Regards

AbdulW7 (author)2015-10-30

Hi, Can any one tell me whats that connection between VCC(5V) and pin 7 of Arduino? what is that thing the light greenish colur?

Nikus (author)AbdulW72015-10-30

This is reed switch for detecting if window is open or closed.

Massythegreat (author)2015-10-26

Hello, most of the information on this guide is how to handle the software and the programming. So I'm wondering what kind of hardware you use, what kind of voltage? Do you use a seperate power supply and relays controlled by the output signals from the arduino? Could you explain that more in detail please.

AKANIMOU (author)2015-07-21

Mr NIKUS, please can you guide me on how to implement this same project using GSM network instead of internet. MY MAIL IS: akdiamond4excellence@gmail.com. THANKS

abubakerj (author)AKANIMOU2015-08-11

Brother...I am also interested in implementing the same project using GSM network...If you have the guide for that, it would be nice if you send it to me...
Thank you

AKANIMOU (author)2015-07-21

This project is uniquely relevant. More power to your elbow author

dhafer.hannaoui (author)2015-07-13

dhafer.hannaoui (author)2015-07-13

EmanueleS (author)2015-06-23

Hi! I am having some difficulties with the sketch and the libraries... Could you send me the hardware configuration (for Arduino Uno and Mega 2560), the right libraries and the sketches for these boards? Please contact me at my e-mail address: signorettae@gmail.com Thanks a lot

СеверинО (author)2015-06-17

I'm curious as built file (program code) smartHome.apk

can you send me program code?

СеверинО (author)2015-06-17

Very good project!!!can you send me code of android app?

My e-mail: nevox14@o2.pl

Nikus (author)СеверинО2015-06-17

Thanks! Look at last step :)

damian.gorzelanczyk (author)2015-06-14

Cześć Nikodem! Całkiem fajny projekt. Myślałeś nad rozbudową tego systemu?

Cześć!
Wielkie dzięki! Tak, myślałem nad jego rozbudową i najprawdopodobniej podejmę się tego ciągu najbliższych kilku miesięcy (aktualnie rozpocząłem pracę nad nieco innym projektem ale również związanym z smart home). Zastanawiam się również nad zrobieniem następnej wersji inteligentnego domu nie w arduino a w czystym C na AVR. Być może zrobię to tak aby można było uruchomić kod napisany w C jak i w arduino. Jeszcze zobaczę. W następnym systemie będzie zdecydowanie więcej opcji, planuję również napisanie zdecydowanie bardziej funkcjinalnej i lepiej wyglądającej aplikacji a w ostatnim czasie jeśli chodzi o programowanie androida dość dużo się nauczyłem. Więc jeśli jesteś zainteresowany następną wersją inteligentnego domu sprawdzaj co jakiś czas mój profil lub odwiedź moją stronę na której piszę po Polsku: arduinopolska.cba.pl

Pozdrawiam

dumipunchi (author)2015-06-08

Can you tell me how can i log via browser to ardiuno using DDNS

DavidN16 (author)2015-05-21

I can't include dalas library!

DavidN16 (author)2015-05-21

HI guy!

About This Instructable

192,578views

1,453favorites

License:

Bio: Hi, my name is Nikodem Bartnik. I live in Poland, I'm 18 years old. I like to program and create robots, devices and things ... More »
More by Nikus:Bluetooth Voice Controlled Moving LampIce Fidget Spinner MoldDIY LED Panel
Add instructable to: