Domotichome

Tutorial

How to turn on/off a led

Posted by mattia at 2011-03-25 13:34:58 UTC

This is the first milestone even if it can't be so tricky and unuseful but it's the concept behind all the process, so please pay attention, I get tons of emails with questions like:

in this tutorial we'are going to answer at those question starting from scratch.

Shopping list


That's all.

We created DomoticHome web app to give at all the people that are not familiary with C/C++ an handly interface to generate the arduino code, in this way you just need to copy it and paste into the arduino IDE, compile and load into arduino. This is a pretty basic process so take a look here
http://www.arduino.cc/en/Guide/Environment
if you have any doubts.

So, register in DomoticHome and login on it, you should see some new voice into the menu bar:

Create Master

Before to start you have to know some parameters concerned your home network like:

beacuse, as we told before, arduino need to communicate with your mobile and to  perform this it must to be connected at yout router, in this way you can handle arduino by your mobile via WiFi.

Click on "Master" and then "Create a new master" you'll see this screen

Fill up the following fields:

Add Device

Click on the button "Add device", in this way we are going to add the support for our led and the system will generate the code for us. You should see a template like this

Name: this name will be show on our android device
Pin out: the arduino pin where the led will be linked
Device Type: select "light" so we will inform to show the "light" icon on the android device
Chibi Support: not used
Chibi address node: not used

Push the button "Create" and we will see a resume about the master and the devices created, as you can see there is link called "click to show the code", click on it and here is where the magic happens, copy the code, paste into the android IDE, compile and load on arduino.

Wiring

Now that the code has been loaded mount your ethernet shield on arduino and connect the led anod to the pin that you entred into the device configuration and katod  to ground.

After this connect arduino to your router via RJ45 cable.

Sync

STEP 1
Before to grab your android device we need to be sure that arduino is corretly linked to our router, so try to ping it. Open a shell and digit this:
ping yourarduinoip

if arduino correctly response at your ping go forward otherwise check your network configuration by pinging your router and control the arduino network configuration on master page by editing the ip,subnet and so on, reload the code on arduino and try again.

STEP 2
Open your browser and go to this url:
http://yourarduinoip/?out=all
you should see a JSON string as response like this:

{"ip" : "192.168.10.23", "devices" : [{ "type" : "light", "name" : "led", "out" : "5"}]}

it rapresents the list of devices configured on arduino, the same HTTP GET will be triggered during the sync process on your android device, after this the device will store the lists of devices and masters in its internale sqlite database.

STEP 3
Everything should be correctly configured so grab your android device set the correct ip in settings (menu->settings) page and then sync the device with arduino (menu->sync).
The device list will appear.

Jump into the detailed page

and there are 2 buttons, one for turn on the light and another one to turn off the light.
Done.

blog comments powered by Disqus

Sponsors

Categories