Tony ZHANG
Published © MIT

Yun Light

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

AdvancedFull instructions provided10 hours10,495
Yun Light

Things used in this project

Hardware components

Arduino Yun
Arduino Yun
×1
433Mhz RF link kit
×1
433 MHZ Remote Controller
×1

Software apps and online services

Blynk
Blynk
DO Button
WeChat 微信
Yeelink

Story

Read more

Schematics

433 MHz with arduino yun

Code

Untitled file

Arduino
/*
 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 file

C/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

Yun Light on GitHub

The Main Function for Yun Light

Credits

Tony ZHANG

Tony ZHANG

16 projects • 117 followers
I'm an Embedded Software Engineer who like DIY electronic. linkedin.com/in/faweiz

Comments