Introduction: Automated Curtain Using Intel Edison & Thethings.IO

Picture of Automated Curtain Using Intel Edison & Thethings.IO

Times goes by and things get old and so, they finally break. Blinds aren’t an exception.

This is one of the reasons why we buy curtains. Not only for aesthetics but also for filtering the amount of light in our room or maintaining our privacy.

But, what if we want to take the maximum advantage of the characteristics mentioned before? Let’s convert a normal curtain into a smart one!

Step 1: Our Automated Curtain Will:

- Open itself at 7 o’clock am: The curtain will roll In order to take profit of the available natural light and to maintain a good temperature inside the room during the day.

- Close itself at 9 o’clock pm: The curtain will unroll in order to provide a good sleeping environment and to prevent curious people from seeing through the window.

+ Due to the lack of a manual mechanism to move the curtain, this should be triggered remotely. In this case we use a Pebble classic smartwatch.

+ Due to the weather may be different everyday, a light sensor will determine whether to roll the curtain or not.

Step 2: Requirements:

Picture of Requirements:

- Intel Edison module + arduino expansion board.

- Arduino base shield.

- 28BY J48 Stepper motor.

- Seedstudio stepper motor driver

- Seedstudio light sensor.

- Micro USB-cable.

- Jumper wires.

- 6x Male to female 0,1” cables.

- 12v Adapter.

Step 3: Hardware Connections:

We connect the 12V adapter to our Edison and the base shield too. The light sensor is connected to the base shield in the A0 connector.

The stepper motor is connected to the driver in just one possible form. The stepper driver is connected to the Edison with the following mapping:

In(1 ->4) -> pins (8 ->11)

GND -> pin GND

Vcc -> pin 5V

Step 4: Mechanical Installation and Adjustments:

Picture of Mechanical Installation and Adjustments:

The curtain is provided with its own gear, but the motor only has a simple flat output.

Because of this, a custom designed, 3D printed gear was made.

After that, both elements were installed in order to fit the curtain’s gear. This was done with a 90o angle steel piece.

Step 5: Edison Development. IDE and Code Used:

Picture of Edison Development. IDE and Code Used:

The intel Edison offers javascript code interpretation. Via the Intel XDK IoT IDE, the Edison pinout can be programmed using javascript.

We will be using some of the functions from the thethings.io node API: https://github.com/theThings/thethingsio-api-node...

After installing and opening the Intel XDK iot Edition, choose a template to work with. In this case, we are going to use the analog read because of the analog light sensor.

The js program consists of:

- An http server that receives POST’s from the pebble smartwatch. Depending on which URL the Edison receives, it rolls (/up) or unrolls (/down) the curtain. Then it writes this information to the thethings.io API. If the curtain is going to be rolled, a 0 is sent. 1 if the curtain is going to be unrolled.

- A function called read_value, reads and converts an analogical voltage from the light sensor to a value (from 0 to 1023). If a certain threshold is passed and the hour matches the previous ones, the curtain is rolled or unrolled. This function is programmed to repeat itself after a certain amount of time (5 min). Each time the function repeats, the current light sensor value is written to thethings.io API.

Feel free to replace our code in your project: https://drive.google.com/file/d/0ByJ4mA2J_L8kMWUxaXVjbnFRbUU/view?usp=sharing

Step 6: Pebble Development. Code Used:

In order to have more control on the code files, we use the pebble SDK directly installed on our computer: https://developer.pebble.com/sdk/

Once you've installed the pebble SDK, open a terminal session and create a new javascript project:

pebble new-project --javascript "name of the project"

A javascript watch app is created for sending HTTP messages to the Edison HTTP server. This application includes a .c file, which provides all the visual interfaces and handles the buttons actions. It communicates with the javascript part using pebble messages.

The javascript part, handles the communication with the Edison HTTP server. If the Up or Down button is pressed, the .c part sends a pebble message to the javascript part and this one sends an HTTP POST to the Edison server (/Up or /Down after the server URL).

In order to install the watch app to the edison, you'll need to enable developer connection inside the pebble time app in the phone (Settings). The type in terminal (inside the project folder):

pebble build

pebble install --phone "your phone ip"

Feel free to replace our code in your project: https://drive.google.com/file/d/0ByJ4mA2J_L8kRWQtYm01aE1ZZmc/view?usp=sharing

Step 7: TheThings.io Dashboard:

Picture of TheThings.io Dashboard:

In order to monitor and take the maximum profit of the connected device, light sensor and manual activations from pebble will be displayed.

Before going to the dashboard, make sure you have an account at thethings.iO. If not, register quick clicking here: https://panel.thethings.io/#/register

Once you have done it, you can start with this Step by Step.

Now let's create a dashboard which you will be able to monitor this data. We're going to create two widgets, one for the manual activations and another one for the light sensor values.

The steps are the following ones:

- Push Add widget.

- Insert a widget name.

- Select Thing resource on Data Source.

- Select your product.

- Select your thing token from the list

- Select the resource you that want to show.

The manual activations are shown as a history, including the date and the action (0 roll, 1 unroll). The values are displayed in a linear graphic, containing (on the x axis) the hour of the sample and (on the y axis) its value.

Step 8: Final Results & Future Improvements:

Picture of Final Results & Future Improvements:

Here is the final image, showing all the structure used for this project.

After building the mechanism and testing it, some considerations should be taken into account for a further revision.

- The stepper motor is a little bit slow due to the limited amount of torque (or “movement power”). A next iteration will have a better stepper motor.

- The driver that was controlling the stepper motor was directly connected to the Edison and it was draining all the possible current electricity for the 5V pin. A better driver should be installed, directly connected to a 5V power supply and capable of supplying more current to the motor.

Comments

DIY Hacks and How Tos (author)2016-02-14

Awesome idea! I love home automation projects like this.

Thank you! Feel free to try our dashboard @ thethings.io

About This Instructable

1,206views

21favorites

Add instructable to: