Introduction: Control Lights With the Pebble Smartwatch and the Arduino

The Pebble smartwatch is ... well, smart! Recent updates on a third party iOS app has allowed for sending HTTP request, which is great for controlling many home automation systems.

In this tutorial I will show how to set up a webserver on an Arduino, connect it to an ssr relay board that can be controlled from a browser on you computer, phone, etc. or by a HTTP request from the Pebble watch.

In this tutorial the Pebble needs to be connected to an iOS device (via bluetooth) and have the Smartwatch Pro app installed (found in the itunes store for 2.99 $ - worth it!)

Let's get started!

What you will need for this tutorial:

Arduino UNO (other arduinos will also do the job)
Arduino ethernet shield with micro SD slot
microSD card

Instead of using either of above I'm using an arduino ethernet board. It won't be much of a difference.

SSR relay (I'm using the sainsmart 8 Channel 5V any relay that takes power that the arduino can output is fine and you can get them fairly cheap (down to 4$ for non-solid state 2 channel relays)

Pebble smarwatch
An iOS device - iPhone

Step 1: The Arduino Sketch & Ajax Webserver

First visit this website, and read what's on - it's awesome!
If you have time I strongly recommend that you read the whole series.

All credits for the webserver and how to set it up goes to starting electronics!!

-- > Go to the Source Code and download

-- > extract the zip file and navigate to the arduino sketch.

-- > Open the sketch and navigate to IPAddress IP(x,x,x,x) and write the IP you want to give your arduino web server. It should be the same as the router but ending with a different number. Choosing a high number will in most cases ensure that it doesn't conflict with other devices. You may also want to replace the mac address - it is not necessary but it is important that it is not shared with any other devices. If you want to change navigate to byte mac[] and change the mac address.

-- > Upload the sketch to your arduino.

-- > Then, mount your micro sd card in your computer and upload the index.htm file that you have downloaded.
This is a webpage that your arduino will run as a server.

-- >  Take your arduino ethernet shield, insert the micro sd card with the index.htm file. Now mount the ethernet shield on your arduino. Plug in an ethernet cable that is connected to your router and power up your arduino.

  You now have a running server! - awesome!

-- > write the ip that you choose in your browser and you will now see the ajax web server running!

Now, it is time to connect the relay that will allow for controlling your light source.

Step 2: The Arduino-relay Connection

The relay will function as a switch that can connect a wire when getting a signal from the arduino.
The relay will require 5 volts!

Connect the arduino to the relay as shown on the picture.

Basically what happens is that when the digital pin 8 output is HIGH then it supplies 5 volts to the input 1 that activates switch 1. The blue wire (on the right) will then be "connected". - I have more wires connected as I control multiple light sources.

Other outputs on the arduino can be used but you'll have to modify the arduino sketch.

Step 3: The Relay

Ok, now you can turn on the relay by pressing buttons on your webpage! Next we are gonna talk about how to connect the light source.
In a normal power cable you have two wires. You will want to connect them  as shown on the picture:

Step 4: HTTP Request and Pebble + Smartwatch Pro

Your light source is now controlled by your web server - if you set up everything correctly.
When you push a button on your web servers webpage, then you basically send a HTTP request that your arduino receives. It either receives an on HTTP request or an off HTTP request.

This HTTP request can come from anywhere! - I use my iPhone, my computer or my Pebble watch to send HTTP requests.
First we are gonna find out what the HTTP request is. Open the arduino sketch and scroll down to void SetLEDs(void).

If LED3=1 then pin 8 will be set high if, however, LED3=0, then pin 8 will be set low. Your HTTP will the be:

http://your-server-ip-adress/ajax_inputs&LED3=1 for on and
http://your-server-ip-adress/ajax_inputs&LED3=0 for off.

In my case it would be for off.

Now, download the pebble smartwatch pro app from iTunes store to your iPhone.
Open the app and press the HTTP requests.
Press the plus sign to add a category.
Open your category, I called mine Ceiling light, and press the plus sign again.
Add the two HTTP request addresses and name the on and off.

You are done!!! You should now be able to control your lights with your Pebble watch!



Just be careful when working with electricity :-)

Microcontroller Contest

Participated in the
Microcontroller Contest