Project tutorial
Yun Light

Yun Light © MIT

7 IoT platforms (Yeelink, Wechat, ThingSpeak, Temboo, Blynk, DeviceHub and IFTTT) with Arduino Yun to control home appliance

  • 7,144 views
  • 3 comments
  • 25 respects

Components and supplies

Apps and online services

About this project

What is the Yun Light?

Yun Light is table lamp that can be control from anywhere in the world without to bough the very expensive product in the market such as Belkin WEMO, SmartThing,Wink etc.. I think it's wasting our money on these hundreds of dollar products, when we can build a smart home by our-self with the open hardware already in front of us. So, I decided to use the Arduino Yun to achieve my ideas.

See Yun Light in action

How is the Yun Light work?

OK! First of all, I want to say that I've learned a lots from this project not only to light up a lamp from my hand or smart phone, I'm seeing that the Internet of Things are convenience and increasing efficiency of our life.

The Yun Light can be control from 7 different platform they are Yeelink, Wechat,ThingSpeak,Temboo,Blynk,DeviceHub and IFTTT which use Arduino Yun to commulate with their API. There is a lots of choose in front of us; thus, can use either one of above IoT platforms to control our appliance from anywhere. 

Arduino Yun Set up?

The Yun light set up is as simple as 1-2-3. 

All we need is a Arduino Yun and 433 Mhz RF link kit

The wiring of the components is fairly easy

Receiver:

The GND Pin(-) of the receiver must be connected to the GND Pin(-) of the Arduino. The VCC Pin(+5V) of the receiver must be connected to the+5V Pin of the Arduino. The Data Pin of the receiver must be connected to the Pin2 (Interrupt 0) of the Arduino

Transmitter:

The GND Pin(-) of the transmitter must be connected to the GND Pin(-) of the Arduino. The VCC Pin(+) of the transmitter must be connected to the +9V Pin or Vin of the Arduino. The Data Pin of the transmitter must be connected to the Pin 7 of the Arduino.

Yun Light Set up?

To setup of the Yun Light, we just need to connect the power cord of table light to 433MHz power outlet as show below:

Code/API

OK, Let's talk about the coding and API usage.

For Yeelink,I use the Arduino Yun Bridge library's process method to GET the HTTP request from Yeelink API. In here I just the give the example of how to get the API request from Yeelink, which it follow the same for all other platform. For more detail please view the Code section. 

WeChat 微信

The Yun Light can be also control from the Chinese most popular SMS WeChat. Here it is the tutorial that you need to follow to make this possible: First follow our official WeChat: ECEFan

Then, we need to create a new device to control Yun Light and don't forget to give your new device a name!  

That's it! You've create a new device, now you can start control your new device via our WeChat platform. Try to enter "open" and "close" command in the message bar ^.^

Now it's the time to get to know the API of this service. Thanks the weline.top team make this option available to the public. Here is their API page. When you trying to access their API, don't forget the enter the OpenID of your device.

Temboo

Blynk

Next, I want to control my Yun Light from Blynk, First of all we need to download the Blynk app either from App Store or Google Play. Don't forget to include the Blynk Library : https://github.com/blynkkk/blynk-library

Device Hub/ThingSpeak/ IFTTT

The IFTTT is very awesome to make things connect together. And it's launched a channel for makers. In my project I also use the IFTTT's DO button do control the Yun Light. Here I use two IoT platform to use the IFTTT's maker channel: DeviceHub and ThingSpeak

The first step is to register on these platform and create a Device as a entry point for your data on the cloud.

For the DeviceHub you can do that here: https://dashboard.devicehub.net/register  and follow the wizard there to create your device. Note that every device has a unique ID(UUID) and an associated API key for the project making the Sending/Receiving data secure and reliable.

After you have one device and add an Actuator in it. Now you can set up the IFTTT by using below code and relay the action done with the IFTTT DO button.

1) Go to https://ifttt.com/maker

2) Click "Connect"

3) Click "How to trigger events"

4) Copy the URL under "Make a POST or GET web request to:"

Channel : Maker

URL: https://api.devicehub.net/v2/project/"paste_project_id_here"/device/"paste_device_id_here"/actuator/"paste_actuator_name_here"/state

Method: Post

Content Type: application/json

Post{"state":"TOGGLE", "apiKey":"paste_api_key_here"}

That's how you setup IFTTT and use its DO button app to control the Appliance.

For the ThingSpeak part, it's the same setting as the DeviceHub setup; however, we have need to have two DO button: one is to control the Yun Light 'ON' and other is use to control the Yun Light 'OFF'.

We could also turn on the yun light when current weather condition change. Such as the examples below:

Link: https://ifttt.com/recipes/320578-if-sunset-then-turn-on-yun-light

Link: https://ifttt.com/recipes/320579-if-sunrise-then-turn-off-yun-light

Reference 

For more info about the these platform API please view following pages:

Blynk Supported Hardwarehttp://community.blynk.cc/t/hardware-supported-by-blynk

Blynk Libraryhttps://github.com/blynkkk/blynk-library

DeviceHub APIhttps://devicehub.net/dev

Temboo API : https://temboo.com/arduino/yun

ThingSpeak API (Look specially for "Get Last Entry in a Channel Feed" section)

Wechat APIhttp://www.weline.top/index.php/apidoc/

YeeLink API : http://www.yeelink.net/developer

Any questions are welcome!

Github: https://github.com/faweiz

Portfolium: https://portfolium.com/faweiz

Linkedin: https://www.linkedin.com/in/faweiz

Code

Untitled fileArduino
/*
 Control light or any other applicace from Yeelink, Wechat,Temboo/ThingSpeak/DeviceHub of IFTTT by using arduino yun
 This sketch connects an 415 MHz to control light using the Yeelink (iOS,Andriod app and web), wechat, IFTTT(twitter), Blynk and IFTTTDo Button(DeviceHub)
 // https://github.com/faweiz
 // https://portfolium.com/faweiz
 // https://www.linkedin.com/in/faweiz
 // Project Tutital : https://www.hackster.io/faweiz/arduino_yun_light
 
 Version change log
 V1.0 created 11 May, 2015 to support Yeelink
 V1.1 update  12 May, 2015 to support wechat(weline)微信号:ECEFan
 V1.2 update  13 May, 2015 to support Temboo with twitter to read a tweet trigger by IFTTT when we push a DO button. 
 V1.3 update  14 May, 2015 to support ThingSpeak's App "Tweet Control" to read a tweet trigger by IFTTT when we push a DO button. 
 V1.4 update   3 June, 2015 to support 443 MHz RF module
 V1.5 update  11 June, 2015 to use Arduino Yun Bridge to connect this project to Blynk.
 V1.6 update  20 August, 2015 to support IFTTT DO Button on ios and android device by using devicehub.net api
 
 Designer: Fawei Zhang 
 */

// include all Libraries needed:
#include <Process.h>
#include <Bridge.h>
#include <Temboo.h>              // v1.2 Temboo libray header file
#include <RCSwitch.h>            // v1.4 433 MHz libray header file
#include <BlynkSimpleYun.h>     // v1.5 Blynk's Arduino Yun libray file
#include "password.h" // Contains Yeelink/Weline/Temboo/Thingspeak/Blynk account info

/* Define the 433 MHz RF Remote conttoller demical code */
#define CH1_ON  4478259
#define CH1_OFF 4478268
#define CH2_ON  4478403
#define CH2_OFF 4478412
#define CH3_ON  4478723
#define CH3_OFF 4478732

RCSwitch mySwitch = RCSwitch();
String dataStringTemp = "";

void setup() {
/* start serial port */
  pinMode(13, OUTPUT);
  Bridge.begin();
  Serial.begin(9600);
/* Wait until a Serial Monitor is connected.  */
  while(!Serial);              // wait for Network Serial to open
         Serial.println(F(" 1. Yeelink\n 2. Wechat\n 3. Temboo\n 4. ThinkSpeak\n 5. Blynk\n 6. DeviceHub\n Please Chose Which Plaform You Want To Control From: "));
/* Blynk */
  Blynk.begin(auth);            // Here your Arduino connects to the Blynk Cloud.
  pinMode(5,INPUT);             // Here I used digital 5 as a input button to control the light
/* Main function  */
  void yeelinkData();                  // Get data from Yeelink
  void wechatData();                   // get data from yeelink (ios,android,web, wechat,Temboo,thingSpeak,DeviceHub and IFTTT)
  void TembooData();                   // Get data from Temboo
  void ThinkSpeakData();               // Get data from ThinkSpeak
  void BlynkData();                    // Get data from Blynk
  void DeviceHubData();                // Get data from DeviceHub
/* 433 MHz RF module */ 
  mySwitch.enableTransmit(7);    // Transmitter is connected to Arduino Pin #7 
  mySwitch.setPulseLength(176);  // Optional set pulse length.
}

void loop() { 
   if(Serial.available()>0)
   {
    int num = Serial.read();
       switch(num)
      {
       case '1':
         yeelinkData(num);                  // Get data from Yeelink   
         break;
       case '2':
         wechatData(num);                  // Get data from Yeelink
         break;
       case '3':
         TembooData(num);                  // Get data from Yeelink
         break;
       case '4':  
         ThinkSpeakData(num);                  // Get data from Yeelink
         break;
       case '5':
         BlynkData(num);                  // Get data from Yeelink
         break;
       case '6':
         DeviceHubData(num);                  // Get data from Yeelink
         break;
       }  
    }
}
The API key header fileC/C++
Password.h Change to your API keys
/* Enter your Yeelink account SDK info */
#define APIKEY              "Your yelink api key"          		 // replace your yelink api key here
#define DEVICEID            "Your yelink Device ID"              // Device ID
#define SENSORID            "Your yelink Sensor ID"              // Sensor ID for lightController
#define USERAGENT           "Your yelink project name"           // user agent is the project name

/* Enter your weline (wechat) info */
#define openAPI           	"Your weline openAPI key"            // replace your weline API key here
#define welineDEVICEID      "Your weline DEVICE ID"              // Weline DEVICE ID

/* Enter your Temboo account info */
#define TEMBOO_ACCOUNT       "Your Temboo account name "         // your Temboo account name 
#define TEMBOO_APP_KEY_NAME  "Your Temboo app key name"          // your Temboo app key name
#define TEMBOO_APP_KEY       "Your Temboo app key"         		 // your Temboo app key

/* Enter your ThingSpeak info */
#define thingSpeakAPI        "Your ThingSpeak API key"           // replace your ThingSpeak API key here
#define CHANEELID            "Your ThingSpeak ID"                // ThingSpeak ID

/* Enter Blynk info */
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "Your Blynk Auth";

/* Enter DeviceHub info */
#define DeviceApiKey    "Your DeviceHub API KEY"           		// paste_your_API_KEY_here
#define PROJECT_ID      "Your DeviceHub PROJECT ID"             // paste_your_PROJECT_ID_here
#define ACTUATOR_NAME   "Your DeviceHub ACTUATORNAME"           // paste_your_ACTUATOR_NAME_here
#define DEVICE_UUID     "Your DeviceHub DEVICE UUID"            // paste_your_DEVICE_UUID_here
The Main Function for Yun Light

Schematics

433 MHz with arduino yun
Fritzing

Comments

Similar projects you might like

Controlling LED light intensity using smartphone light senso

Project tutorial by Nikola Travis

  • 1,929 views
  • 0 comments
  • 3 respects

Create Your First Connected Light using Arduino Yun

Project tutorial by andreareginato

  • 1,533 views
  • 0 comments
  • 0 respects

Secure YUN

Project tutorial by Abhishek

  • 1,649 views
  • 1 comment
  • 12 respects

Ultrasonic Map-Maker using an Arduino Yun

Project tutorial by Satyavrat Wagle

  • 51,861 views
  • 37 comments
  • 152 respects

Control your light system with your voice

Project tutorial by Maha Raafat

  • 33,182 views
  • 22 comments
  • 147 respects

Traffic Light Information System

Project tutorial by Pieter Luyten and Joppe Smeets

  • 16,243 views
  • 18 comments
  • 36 respects
Add projectSign up / Login