jegatheesan
Published © GPL3+

Smart Home With Android App

Use linkit one with Android app to make ur home smart by turn ON and off electronic devices using mobile

AdvancedFull instructions provided3,105
Smart Home With Android App

Things used in this project

Hardware components

LinkIt ONE
MediaTek Labs LinkIt ONE
×1
Relay (generic)
×1
Android device
Android device
×1
12V and 5V Adaptor
×1

Software apps and online services

Arduino IDE
Arduino IDE
Bluetooth Controller App

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Connection diagaram

Relay module to switch board connection diagram
Connection

Code

Smart Home Automation

Arduino
#include <LBT.h>
#include <LBTServer.h>
int readval;

int resultvalue;
int presskey;
int Dstatus[9];

void setup() {
 if(!LBTServer.begin((uint8_t*)"SIVAM_LIO"))
 {
 return;
 }
 Serial.begin(9600);
 
   for(int i=3;i<=13;i++)
  {
    pinMode(i, OUTPUT);    
    digitalWrite(i, LOW);
  }
  
  for(int i=3;i<13;i++)
  {
    Dstatus[i-3]=0;
  }
}
void loop() {
 uint8_t buf[1];
 int bytesRead;
 if(LBTServer.connected())
 {
 while(true)
 {
 bytesRead = LBTServer.readBytes(buf, 1);
 if(!bytesRead)
 break;
 readval = buf[0];
 control(char(readval));
// Serial.println(char(readval));
 }
 delay(100);
 }
 else
 {
 LBTServer.accept(5);
 }
}

void control(char skey)
{
    String keyrec="";
    keyrec += (char)skey;
    presskey=keyrec.toInt();
    if (presskey<4)
    {
      if(Dstatus[presskey]==0)
      {
        Dstatus[presskey]=1;
        digitalWrite(presskey+10, HIGH);
      }
      else
      {
        Dstatus[presskey]=0;              
        digitalWrite(presskey+10, LOW);              
      }      
    }
}

Testing

Arduino
#include <LBT.h>
#include <LBTServer.h>
int readval;

int resultvalue;
int presskey;
int Dstatus[9];

void setup() {
 if(!LBTServer.begin((uint8_t*)"SIVAM_LIO"))
 {
 return;
 }
 Serial.begin(9600);
 
  for(int i=3;i<13;i++)
  {
    pinMode(i, OUTPUT);    
    digitalWrite(i, LOW);
    Dstatus[i-3]=0;
  }
 
}
void loop() {
 uint8_t buf[1];
 int bytesRead;
 if(LBTServer.connected())
 {
 while(true)
 {
 bytesRead = LBTServer.readBytes(buf, 1);
 if(!bytesRead)
 break;
 readval = buf[0];
 control(char(readval));
// Serial.println(char(readval));
 }
 delay(100);
 }
 else
 {
 LBTServer.accept(5);
 }
}

void control(char skey)
{
    String keyrec="";
    keyrec += (char)skey;
    presskey=keyrec.toInt();
    if(Dstatus[presskey]==0)
    {
      Dstatus[presskey]=1;
      digitalWrite(presskey+3, HIGH);
    }
    else
    {
      Dstatus[presskey]=0;              
      digitalWrite(presskey+3, LOW);              
    }
}

Credits

jegatheesan

jegatheesan

16 projects • 40 followers
Simply A Mechatronics Lover.

Comments

Add projectSign up / Login