Arduino Yun: Light Control

This is a proof of concept for setting up the newly released arduino Yun as light controller. A web server was setup on arduino Yun with support of MySQL and PHP. Light status is controlled with MySQL queries and even when a button is pressed triggers an SQL query, this is the advantage  of Arduino Yun’s Bridge, you can interact between the ATmega 32U4 (Arduino side) and the Linino AR9331(Linux side). Below are some pictures of the setup and also a demo video.

DSC_0053 DSC_0055 home_automation_bb 

Before proceeding with the setup I have to mention that at the moment I bypassed the security aspect of this project.

Use it at your own risk. If this is going to be in public you are exposed and vulnerable in attacks.

Setup of the Linino (Linux) side of arduino:

Download all necessary files from the below link:

https://www.dropbox.com/s/2b8edx2nmomto49/light_control.rar

  • Install LAMP stack following the below website:

http://wiki.openwrt.org/doc/howto/lamp

  • Download the below file and put then in the desired folder of the webserver running on Arduino (skip downloading if you already downloaded the files from the first step):

Web Interface

I created the homeautomation database and the LEDstatus and webstatus tables as below :

LEDstatus table:

 Field  Type  Null  Key  Default  Extra
 id  int(2)  NO  PRI  NULL  auto_increment
 name  varchar(15)  YES  NULL
 LEDstatus  varchar(5)  YES  NULL
 pin  int(2)  YES  NULL
 pinOut  int(2)  YES  NULL

..and added two entries in the LEDstatus table:

 id  name  LEDstatus  pin  pinOut
1  LED1 -1 2 8
2  LED2 -1 3 9
    webstatus table:
 Field  Type  Null  Key  Default  Extra
 status  int(1)  YES  NULL
  • Create some bash scripts for different mysql queries and place them in the root folder  (skip downloading if you already downloaded the files from the first step) :

Scripts

  • Download the arduino sketch  (skip downloading if you already downloaded the files from the first step):

Arduino sketch

Many thanks to the below:

http://arduino.cc/en/Tutorial/Switch

http://wiki.openwrt.org/doc/howto/lamp

Advertisements