Introduction: Control Arduino Over Wireless LAN (WLAN)

In this instructable I am going to show you how to control your Arduino over WLAN. I am currently using it to control my room lights. This instructable is similar to my previous one.

I choose to use my WLAN because I want just people connected to my network to be able control my Arduino. It is possible to implement a way to give different control access to people depending on their mac address or their user name through user authentication system (I won't talk about it in this instructable).

The materials I used were:
- 1x Arduino Uno

- 1x Ethernet Shield (w5100)

- 1x Dual Channel Relay (5v)

- 1x Ethernet Cabble

- Jumpercables

I stored my circuit within an topware, since it is going to be in my bedroom and I don't want to take any risks. =)

Step 1: Getting WLAN or LAN Data

In order to run the sketch we need to get some data from your LAN router. I will show how to do it in windows OS:

1. open windows command prompt (search for "cmd" on your windows search bar and hit ENTER)

2. type ipconfig /all (exactly like I wrote it) and hit ENTER

3. some info will be printed, scroll up and look for your Wireless LAN settings (or your LAN settings if your are connect via LAN)

4. take note of your DHCP server ip, it usually looks like something like 192.168.x.x, mine is 192.168.0.1.

Step 2: Download, Change and Upload

You will find the sketch I used attached, it uses an Ethernet Shield (w5100) but you may be able to change the coding to whatever communication your Arduino might have with the internet.

Since I am using a Ethernet Shield, I could store my html in a separated file (.htm) in a microSD card with my css and my javascript file, but I won't be doing that now because I want to show how to do it in the simplest way and I am assuming you might want to use another communication shield or module besides w5100.

1. Download the sketch

2. In line 13, change the gateway to your DHCP IP from step 2, mine is 192.168.0.1

3. in line 12, change the ip based on your DHCP IP from step 2, changing the last number after the last periods. I used 192.168.0.55

4. upload the sketch to Arduino and plug everything in

NOTE: to change the gateway and ip fields use commas and not periods

In this way we will be storing a simple html page within Arduino's Sketch. The html page will use a css file and a javascript file stored on my personal host, you might be able to download then and change if you like, just remember to set the new reference in line 57 and 59 of the sketch.

Further more, I will put my web page online so I can control my room lights from around the world. I will show you how to do this in another instructable.

NOTE: I would like to show my gratitude to W3S for teaching everything I know about html, css, javascript and js mobile. Thank you, lads!

Step 3: Playing Around

Once the sketch is upload and everything is set, you are good to go.

In your smartphone or computer open a web browser and type the Sketch's IP in the navigation bar, in my case it's 192.168.0.55, it will load the web page and you can control your things. In my case I am controlling the lights and the lamp in my room.

The best thing about this method is that another user that opens the web page will load it update, that means if somebody open the page with my lamp turned on it will show the lamp as turned on, that is mainly because the Arduino client.print the control array within the web page as well, which are read by a function on my javascript file that runs on every client.print by the Arduino.

Hope you like it!

Arduino Contest 2016

Participated in the
Arduino Contest 2016

IoT Builders Contest

Participated in the
IoT Builders Contest