loading

Being able to blink an LED and press a button is great, but what if you want to go further? The LinkIt One board has a lot of functionality that we have yet to tap into.

For this tutorial we are going to set up a simple web server that connects to your home WiFi and allows you to control an LED remotely via a web browser.

Step 1: Materials Required

LinkIt One
WiFi antenna (the LinkIt one box has one in there)
WiFi router (hopefully you have one for your internet)
Your router's WiFi SSID and password (don't tell us this, we're all 1337 round here!)Web browser (you're using one to read this!)
Micro USB cable (will the other half just buy their own!?)
Arduino software
(optional) LED and resistor connected to pin D13

Step 2: Connecting the Antenna to the Board

This step requires very fine positioning of a delicate part. Please treat the antenna connector with the highest care and be gentle.

Remove the WiFi antenna from the packaging. The WiFi antenna is the long thin one. Just for information the larger thin one is the 3G (telecommunications) antenna, the bulky square one is the GPS antenna.

Turn the LinkIt One board over and near the large CE and FCC sign you will see three identical tiny round parts.

The WiFi antenna connects with the centre socket, marked "WIFI/BT ANT".

To connect it, hold the side the board that is furthest away from the sockets using your finger and thumb of your less dominant hand (ie left if right handed and vice versa).
With your main hand, place your index finger under the centre connector to support it while lining up the antenna connector to the board connector.
When you have the two aligned push down gently but firmly with your thumb. You should immediately feel it click gently into place.

Do not press too firmly or you risk breaking the connector on the board or antenna.

Step 3: Programming the Board

Connect the board to your computer using the Micro USB cable then start the Arduino IDE.

Ensure the port and board are both correctly identified as in my previous tutorials.

This time I am going to go a little more sharply - we are going to insert the contents of the program ourselves instead of using one of the examples.

Open the file WifiLEDControl.ino.txt (click on it and it will open in a new browser tab).

Copy all the contents (press Ctrl-A (select all) then Ctrl-C (copy) on Windows).

Switch to your Arduino IDE and press Ctrl-A (select all) again then press Ctrl-V (paste)

There are three minor changes you will need to do to your own code - you will need to change the SSID, password and encryption type to suit your own router.

You can change the LED pin that is controlled, I will leave that to you to work out.

To save the program we just wrote, click on File, Save and give it a name such as MyLEDWifiWebServer.

When you first start the program running the LED will do 2 quick flashes, a long pause (0.6 seconds) and repeat that sequence.
This is the period where the program is trying to connect to the WiFi with the credentials provided.

If the device successfully connects the LED will do one single quick flash after the long pause and then turn off awaiting your input.

If you monitor the serial port it will provide information such as the current connection status, signal level and IP address.

Step 4: Controlling the LED Using Your Browser

To control the LED with your browser, locate the IP address (it was displayed on the serial monitor in the previous step) and type it into the browser window followed by either /on or /off

example
You have been given the IP address 192.168.0.36
http://192.168.0.36/on
will turn the LED on (or leave it on if it was already on)

http://192.168.0.36/off
will turn the LED off (or leave it on if it was already off)

Step 5: Next Steps

You have seen how easy it is to create a web server that can control an LED.
How would you alter the program to toggle any pin rather than a single one?
hint: /13/on
How about putting in an Easter Egg known only to you?

There are a number of devices on board - GPS, GSM, SD card, audio out.
Consider what you could do with those from what you have learned in this tutorial.

Feel free to leave a message about your ideas in the comment section below.

<p>Many thanks, it worked perfectly on my Link it ONE.</p>
Glad to have helped :)
<p>I get this error when I run the code (IDE version 1.5.7 Beta - This is because the SDK installer says I cant install with any version new than that):</p><p>C:\Program Files (x86)\Arduino\hardware\arduino\mtk\libraries\LWiFi\LWiFi.cpp: In constructor 'LWiFiLoginInfo::LWiFiLoginInfo()':</p><p>C:\Program Files (x86)\Arduino\hardware\arduino\mtk\libraries\LWiFi\LWiFi.cpp:24:18: warning: passing NULL to non-pointer argument 1 of 'String::String(int, unsigned char)' [-Wconversion-null]</p><p> m_password(NULL)</p><p> ^</p>
I am running Arduino 1.6.5 so can't help with beta versions.<br>However, doing a google search for the important part of the error message gives me this result:<br>http://www.seeedstudio.com/forum/viewtopic.php?f=42&amp;t=5750<br>Just edit the code linkIt One in the library<br>... \arduino\arduino-1.5.8beta\hardware\arduino\mtk\libraries\LWiFi\LWiFi.cpp<br>to<br>LWiFiLoginInfo::LWiFiLoginInfo():<br>m_enc(LWIFI_OPEN),<br>m_password(&quot;&quot;)<br>{<br>}<br><br>and the problem goes away.
<p>Thanks, the error is gone now. But how do I find my LinkIt One's IP? The Serial Monitor closes when I upload the code.</p>
<p>Click on Serial Monitor (there is a button) again as soon as you see &quot;Done uploading&quot; to open the serial monitor window.</p>
<p>I'm not receiving any response in the serial monitor. Nor is there any new device in the connected devices list on my router's menu (Which is 10.0.0.1 for me - xfinity/comcast)</p>
<p>Check that you have got the SSID, password and encryption type correct.</p><p>One of the biggest pains on this board is the USB serial port. Do you perchance have access to a FTDI cable?</p>

About This Instructable

3,064views

8favorites

License:

Bio: Focussing currently on supplying open source software to the masses. I supply linux CDs and DVDs across Europe, as well as mirror various open source ... More »
More by gregoryfenton:LinkIt One Tutorials - #14 Traffic lights LinkIt One Tutorial #13 - Send a tweet LinkIt One tutorials - #0 Fix that pesky Serial port! 
Add instructable to: