Introduction: Smart Home Automation With Android + Ethernet Internet + Arduino
Home automation becomes more and more popular, affordable and fascinates people. Internet offers such possibilities as never before. Impress your friends showing on Smartphone that you can switch on/off lamp in your apartment miles away and simultaneously see it through a webcam, opening doors. Very cool!
// --------------------------------------------------------
Step 1: Materials
Smart Home Automation with Android + Ethernet Internet + Arduino
01 - Smartphone with Android 2.3+
01 - Wire Ethernet + Router (My Model is TP-Link (TL-WR740N)
01 - Arduino Mega 2560 ou Arduino Uno + Shield W5100 (Ethernet)
01 - Led IR (Optional)
// --------------------------------------------------------
Step 2: App Inventor (application That Control the Arduino Via the Internet)
First you need create an app android, in this case I use an app inventor 2 link: http://ai2.appinventor.mit.edu/
Reference: https://www.youtube.com/watch?v=rwsKzyEpgoE
(Tutorial: AppEthernet - App inventor 2 / Channel: Android e Arduino)
Download .aia to my project, if you need change this application to English, because I created in Portuguese
http://www.mediafire.com/download/pbcepmryegczdpb/SmartHouseApp.aia (Project .aia)
Download App to install in Android:
http://www.mediafire.com/download/v2yk79xk91eaw57/SmartHouseApp.apk
//------------------------------------------------------------------------------------
Step 3: Sketch to Arduino Mega - Code Link Download
Download link in the end code:
You need change:
byte ip[] = { 192, 168, 0, 00 }; // IP the arduino
EthernetServer server(80); // Port acess
Obs:
01 - You need a version IDE 1.0.5 - the code does not work in IDE 1.0.6 because of IRremote library
02 - Every 4 seconds the page automatically updates, if you need change: client.println('<'MET A HTTP-EQUIV='refresh' CONTENT='4; URL=http://seudominio.no-ip.org/'>");
03 - In application "SmartHomeAPP" you need change to a URL=http://seudominio.no-ip.org/'
04 - Change the LED IR code to turn on or turn off your TV or Stereo
Lindo Download Sketch Arduino INO
http://www.mediafire.com/view/v2y3ztk5uhex2ij/APP_ETHERNET_INVENTOR_WAKE.ino
How can you creating a http://seudominio.no-ip.org/
Acess the link: https://www.youtube.com/watch?v=1FWGt5gnnYs or https://www.youtube.com/watch?v=ZPvvoEDjSww
//---------------------------------------------------------------
Step 4: Understanding the Code and Main Features
The methods "Get" send the variable for arduino, you can see in the piece of code:
if (c == '\n') {
if (readString.indexOf("lampada1") > 0) {
digitalWrite(lampada1,!digitalRead(lampada1)); }
//--------- send the page a variable "lampada1"
then the Arduino reads the full page and returns a method "Get" you can see in the piece of code:
//botao lampada1
if(digitalRead(lampada1)){ statusLed = "Ligada"; }
else { statusLed = "Desligada"; } client.println("
");
//--------- in this piece you can see "+statusLed+", it returns to the relay this on or off on page
//-------------------------------------------------------------------------