Introduction: Arduino Based Smart Home IOT System

Hello, I am Michalis Vasilakis from Ardumotive.com and in this Instructables guide I will show you how you can easily make your own smart home system based on Arduino uno and an Ethernet module (or shield).

You will be able to use this system from any device (mobile phone, pc, tablet) because the user interface (1st image) is accessible through a browser window. Because of that, it supports all operating systems! You can also control your electrical device from your local area network and (or) from your internet worldwide connection. So, it can be accessible from anywhere! But, this also means that it can be controlled from anyone, so before you make it accessible through your internet connection, consider adding security measures to protect your IOT system.

It supports up to seven +1 outputs for controlling any electrical device in your home. The 8th output can be connected with a photocell to automatically control an outside light (or lamp). These 8 outputs can be expanded to support more output channels. It also has an LED on every output channel and a button to control it manually. Every output channel can be connected with a relay switch or connected to an RF device to control a relay wirelessly. It has a power output (5V up to 1A) for powering up any relay board or other external device.

It can be powered from a 5V up to 1A power adapter, even from your usb 3.0 computer port. If you want to power it up with a different voltage power adapter consider adding a 5V voltage regulator to your circuit.

The hole project cost me less than $40! It's really easy to make it!!!

Please read and agree with license Attribution - NonCommercial - ShareAlike.

Let's get started!

Step 1: What You Will Need

For this project you will need:

  • Arduino uno
  • Ethernet module (or shield) (based on W5100 chip ! important !)*
  • Shift Register IC - 74HC595
  • 8x buttons
  • 8x 220 Ohm, 2x 1K, 2x 2K, 2x 3K, 3x 10K, 1x 100K resistors
  • 1x photocell
  • Breadboard
  • Some breadboard cables
  • 8x screw drivers for outputs, 2x for power output and 2x for photocell

(ONLY) If you want to make your own custom - Arduino based - circuit you will also need:

  • LD1117V33 Voltage regulator (3.3V output)
  • 16Mhz crystal osc
  • 2x 22pF ceramic, 1x 0.1uF electrolytic capacitors
  • 1x 10K resistor
  • On/Off switch
  • DC power jack
  • 1A fuse box (just in case...)

*The code of this project does not support the ENC28J60 chip!


You can buy them from GearBest.com, good prices and free shipping.

Step 2: Shift Register 595 and Outputs

The shift register will give to your Arduino an additional 8 digital outputs, by using only 3 pins on your board!

Here you can find a simple tutorial with the shift register 595 IC and Arduino uno board.

SR 595 and Arduino uno:

  • Pin 8 (GND) to GND
  • Pin 10 (SRCLR') to 5V
  • Pin 11 (SRCLK) to Arduino pin 6
  • Pin 12 (RCLK) to Arduino pin 5
  • Pin 13 (OE') to GND
  • Pin 14 (SER) to Arduino pin 4
  • Pin 16 (Vcc) to 5V

QA is the first output - QH is the 8th output. We will connect each output with one screw driver - terminal and with an LED through a 220 Ohm resistor.

When you are ready, proceed to the next step.

(tip: You can use the QH' - pin 9 to add one more shift register ic and expand your outputs.)

Step 3: Buttons and PhotoCell

We will add 8 buttons, but we will use only 2 Arduino pins.

Find here a tutorial with multiple buttons through only one analog pin of Arduino board.

  • Button BUS line 1 for output 1 to 4 to Arduino analog pin A4
  • Button BUS line 2 for output 5 to 8 to Arduino analog pin A5

Add a photocell to control a light bulb. It can be an outdoor light that will automatically turn on at night!

Find here a tutorial with a photocell (or photoresistor).

Use one screw driver - terminal here to expand the sensor for the main circuit.

Photocell will be connected to Arduino analog pin A3.

You can now proceed to the next step.

Step 4: Ethernet Shield

If you have an Ethernet Shield just attached it on the Arduino uno board.

I am using the Wiznet Wiz550io ethernet module. It uses the same library with official Arduino Ethernet Shield (Ethernet.h), the only difference is that it has a unique MAC address.

Some notes about SPI connection:

  • MOSI - Arduino pin 11
  • MISO - Arduino pin 12
  • SCLK - Arduino pin 13
  • SCSn - Arduino pin 10

Οptionally for Wiz550io

  • RDY - Arduino pin 7
  • RST - Arduino pin reset
  • INT - Arduino pin 2

Note! Wiz550io must be powered from 3.3V output pin of Arduino uno! Do not use the 5V pin with this module!

Step 5: The Code

I also made my circuit in an breadboard first to test it.

Here's the code, embedded using Codebender!

Try downloading the codebender plugin and clicking on the Run on Arduino button to program your Arduino with this sketch. And that's it, you've programmed your Arduino board!

If you want you can make your changes in the sketch below by pressing the "Edit" button. Try for example to change the labels of outputs, for example change "Output1" to "Kitchen Light" (line 164 value=\"Output 1\").

You can also change the network ip addresses to fit your network configuration.

Photo cell value (line 29) is setted to 300, but you can also change it by pressing the Edit button.

If you don't use Codebender you have to manual search and install all additional libraries to your Arduino IDE. Don't ask me about this, search them on the web... or just use Codebender.

Step 6: User Interface

Plug the Ethernet cable to your rooter and turn on the Arduino smart home system (if you have it on an breadboard, just plug in the usb cable to your computer)

You can access the user interface from any device, just open one browser window and navigate to: 192.168.1.192

Press an button to "power on" an output. You will see that the red circle becomes green. That means that your output is setted to HIGH (you can see it also from the output led indicator). Press it again to turned it off. It's not just a changeable image from html page, but an answer from your Arduino! If an output fails to turned one, the output state indicator will remain red!

Outside local network - WAN

This page (192.168.1.192) can be access from any device in your local network. If you want to access your smart home system through internet you can simply add a rule in your rooter by opening a port (search the web like routers_name port forwarding). Remember that anyone can access your IOT device! You will also need a static ip or an dynamic DNS service to access your device anytime form anywhere. But it will also worked with your wan ip, until the next rooters restart (just search the web "find my ip"). Use this (wan) ip address to any device that is outside from your local network (important).

Step 7: Outputs

You can connect the outputs with 8 channel relay board or a single one, or tiger an RF module to control a relay module wirelessly. It is important to know what you are doing! One side of relay will be connected with high voltage (home) circuit, that means risk of electrocution!

  • Connect each output with input signal of relay module.

Step 8: Finally

Now you can make your own - Arduino based - customized circuit and close it in a small box. I made my own box by customizing one din rail box.

For more Arduino tutorials and cool projects you can visit our web page: www.ardumotive.com
I would like to see photos of your IOT home systems!

I hope you liked this, let me know in the comments below!

Hope to vote this guide at IOT contest :)))

Comments

author
craighissett (author)2017-04-18

This is great!

I've got a few DIN Rail enclosures kicking about; may have to try something similar :-)

author
RubineR (author)2017-03-29

hi,it is a nice project but i would like to know more about this project cause im using bluetooth hc 05....plz email to me cause i need some help as soon as possible

author
Andsetinn (author)2016-09-25

Hi, nice project. Thank you for sharing.

I am wondering why you are using shift register to get 8 outputs when the UNO has 14 IO pins.

author
D6equj5 (author)2016-07-27

Hi, thanks for showing this project. It is a very useful basis for my own. Keep up the good work.

author
TùngN35 (author)2016-07-23

Thanks for excellent project. How to make a password for web page. Thank you, again.

author
sny2ksa (author)2016-06-17

:) Today I tested it at home and its working.

Thanks a lot

author
sny2ksa (author)2016-06-16

Ethernet shield i tested it with other codes its working well and yes its based on W5100. The network setting are ok.

Today i will try again and inform you the results

author
sny2ksa (author)2016-06-15

try a lot but failed, program the uno using codbender without error then plug the Ethernet cable but unable to open the page 192.168.1.192. i am using clone ethernet shield with original uno board. Can you help me to diagnose the problem.

author
Ardumotive_com (author)sny2ksa2016-06-16

Check your network settings and info in your local network (pc, router).

Also it's possible the clone ethernet shield that your have is not supported from this code and ethernet libraries. Can you confirm that it has the W5100 IC on it?

author
sny2ksa (author)2016-06-02

get error ShiftRegister74HC595.h not found

from where i will search.

author
Ardumotive_com (author)sny2ksa2016-06-15

Hi, I just import the library in my project code.

(Library can be downloaded from here: https://github.com/Simsso/Shift-Register-74HC595-A... )

Thank you for your comment!!

author
JetMechanic (author)2016-05-04

What's the gray box with the green buttons. I wasted my time going over and over the instructable to find out what it is and how it fits into the picture, or where it may have been introduced to me (the reader)... and found nothing. Very confusing.

author
Mjtrinihobby (author)JetMechanic2016-05-12

Dude you need to get a job. As in earn money instead of trolling the instructables community and harassing this hard work author.

author
RudyD1 (author)JetMechanic2016-05-08

Search "din rail enclosure" or "din rail box".
I also wonder where the fuse is used? I assume to power custom arduino, that might be of interest to at least point to a tutorial. Not that I can't Google it, but it's on the bill of materials and I'm curious how you connect it to main or some other power supply. Thanks!

author
Ardumotive_com (author)RudyD12016-05-09

Hi! The fuse is 1A and you have to connect it at your power in - positive pin (5V). +1 for the "din rail enclosure" or "din rail box"

author

I just bought and customized a small plastic box. For example, I used a drill to put the buttons on it.

author

Okay thanks. Maybe make a note of that in your instructable? Overall, your instructable is going to be very useful for me.

author
JohnE12 (author)2016-05-09

What an excellent project - thank you very much; it gave me a useful spin on a similar project upon which i am working - I never considered using a shift register! Thank you.

author
Ardumotive_com (author)JohnE122016-05-09

Thank you for your comment! I'm glad I was able to help.

author
Ruben Marc Speybrouck (author)2016-05-09

Why did you not use wifi, ESP8266's are cheaper than the arduino ethernet shield u used?

author

Hello, I used it because this device can be near the rooter, so it's not a problem if you will use an ethernet cable.

One other reason is that it will worked on any rooter, what I mean? Every time that you will need to change your wifi password (or name - SSID) you will need to reprogram the wifi module with new network parameters. The same think if your will need to change it (buy a new rooter).

It will be more easy with ethernet solution for someone that want to just plug it on the rooter and start using it.

And of course I prefer the "cable" solution than wireless for other - proper operation reasons.

Hope that you can understand what I want to say... Sorry for my not so good English..

author
AndrésG62 (author)2016-05-08

Hi Michalis:

Do you think this code will work for a NodeMCU ESP8266 board?

author

Hello, no... it will not work... :/

author
pmshah (author)2016-05-08

There are similar ready made devices available on line ranging in price from about € 60 to € 100 for 4 to 12 outputs. Energenie EG-PMS2-LAN by Gembird in Netherlands is one example.

The problems I have had with these devices is the fact that the control button on the interface is a toggle and not very useful for automation through application like Aut\oi-It.

What I would like to suggest though is a small change in the web interface. Why not provide 2 distinctly separated buttons for each output so that you have very precise unattended control of the output regardless of its previous state. That would go a long way to automate the whole process through Auto-It.

What would be really nice would be to have an application running on Windows platform that can control the output from command line.

author
Ardumotive_com (author)pmshah2016-05-08

On mine system the toggle for the Auto light system (output 8) is only working when you don't using the "auto" function. So, if "auto" is disabled, you can turn on or off the light-device. If its enabled, you can't control it. Because it's setted to "auto". But of course you can change this behavior in the code ;)

As for windows application I think that you can make a simple one with visual basic or processing. But I preferred the "browser" and online html/php - web based application because you can control your device from any device and any OS. (windows,linux,mac, ios, android)

author
pmshah (author)Ardumotive_com2016-05-08

I am fine with browser interface. No problem there. Only suggestion is to have separate buttons for switching ON and OFF. With Autoit script I can open a browser window with specified URL, resize the window, move the mouse to exact location on the screen and left click the mouse. I can run this script from a command line. Essentially I could very precisely switch any output on or off regardless of its status, automatically. Toggle would simply change the state which may or may not be what one wants.

author
DrewP15 (author)2016-05-08

Ummmm well I guess this is a smart home something. Looked up your site and its in English with French or something videos. hmmm I don't no. Not a lot of really life info in here. Just a tone of random info :(

author
Ardumotive_com (author)DrewP152016-05-08

P.S. the secondary language is Greek. Thank you for your comment.

author
Ardumotive_com (author)DrewP152016-05-08

My website is based on English language. Witch part you didn't understand form the above guide so I can help you?

author
Eric Brouwer (author)2016-05-03

Excellent Instructable. I will definitely play around with your code.

author

Thank you!! That's sounds great! :D

About This Instructable

47,533views

617favorites

License:

More by Ardumotive_com:MIKE - Arduino Line Following Robot for Beginners "GRECO" - Arduino Object Avoiding Robotfor BeginnersArduino 3D Printed Digital Thermometer With DHT-22 Sensor
Add instructable to: