KalbeAbbasRachel Vorster
Published © MIT

Instant Control of Appliances with XinaBox and Blynk

Learn how to automate your home with XinaBox and Blynk with a simple demonstration of turning lights ON and OFF using the Blynk app button.

AdvancedFull instructions provided1 hour236
Instant Control of Appliances with XinaBox and Blynk

Things used in this project

Hardware components

CW01
XinaBox CW01
×1
IP01
XinaBox IP01
×1
OC03
XinaBox OC03
×1
XC10
XinaBox XC10
×1
5V Power Supply
×1
5V Relay module (SRD-05DC-SL-C)
A 5V SRD-05DC-SL-C relay is used in this tutorial, but any 3.3V or 5V relay module can be used with changes in the code and connections.
×1
Light bulb
An 11-W Fluorescent light bulb is used in this tutorial. However, any light bulb can be used.
×1
Light bulb socket
×1

Software apps and online services

Blynk
Blynk

Hand tools and fabrication machines

Screw driver

Story

Read more

Code

Blynk Button Control

C/C++
*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define DELAY_TIME 1000


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <xOC03.h> // https://github.com/xinabox/arduino-OC03
#include <xCore.h> 

xOC03 OC03;

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin V5
BLYNK_WRITE(V5)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable

  if(pinValue==1)
  {
    Serial.println("Lights turned on");
    OC03.write(HIGH);
  }else if(pinValue==0){
    Serial.println("Lights turned off");
    OC03.write(LOW);;
  }
  
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  #ifdef ESP8266
    Wire.pins(2,14);
  #endif
    
  // Start the I2C Communication
  Wire.begin();
  
  // Start the OC03 port expander
  OC03.begin();

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
  Blynk.run();
}

Credits

KalbeAbbas

KalbeAbbas

2 projects • 4 followers
An enthusiastic and dedicated Electronic engineer graduated from SSUET Karachi, Pakistan. Loves to discover Embedded electronics projects.
Rachel Vorster

Rachel Vorster

0 projects • 2 followers
Thanks to XinaBox.

Comments

Add projectSign up / Login