home automation with arduino and android

that sound great i have a similar project on the long therm but i'll likely use bt instead of ethernet it's great

for the watt meter...did you use this?
openenergymonitor.org

eres español?

estoy interesado en el envio y recepcion de comandos desde una web al arduino para activar pines.
sobre todo en la parte de php.

estare atento al tema.

really really interesting...
Can you post the android code somewhere? I'm starting with andriod programming and I'm curious about this interaction between arduino and the phone!

P.s: Ottimo lavoro (bella anche l' UI del programma)

Hi guys, attached a short program that handle 2 relays and 1 temperature sensor, just to give you and idea about the stuff works.

By the way I deployed tha app on the android market, just need to search "DomoticHome".

#include <WString.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 10, 15 };                  // ip in lan
byte gateway[] = { 192, 168, 10, 1 };                  // internet access via router
byte subnet[] = { 255, 255, 255, 0 };                   //subnet mask
Server server(80);                                      //server port
byte sampledata=50;            //some sample data - outputs 2 (ascii = 50 DEC)             

String readString = String(30); //string for fetching data from address

int ledLittleGate = 4;  // little gate
int ledMainDoor = 5;  // main door
int ledTemperature = 0; // temperature home
//mcp9700a temperature(ledTemperature);
float tempc = 0; // temperature variables
int samples[8]; // variables to make a better precision

boolean statusLittleGate = false;
boolean statusMainDoor = false;
boolean statusTemperatureHome = false;
boolean whosConnected = false;

void setup(){
//start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
//Set pin 4 to output
  pinMode(ledLittleGate, OUTPUT);  
  pinMode(ledMainDoor, OUTPUT);    
//enable serial datada print  
  Serial.begin(9600);
}
void loop(){
// Create a client connection
Client client = server.available();
  if (client) {
    while (client.connected()) {
   if (client.available()) {
    char c = client.read();
    //read char by char HTTP request
    if (readString.length() < 30) 
      {
        //store characters to string 
        readString.append(c);
      }  
        //output chars to serial port
        Serial.print(c);
        //if HTTP request has ended
        if (c == '\n') {
         // ****************************************************
         // little gate
         if(readString.contains("out=4&status=1"))
         {
             // throw the impulse
             digitalWrite(ledLittleGate, HIGH);    // set the LED on
             delay(300);
             digitalWrite(ledLittleGate, LOW);
             statusLittleGate = true;
          }else{
             statusLittleGate = false;             
          }
         // ****************************************************          
         
         // ****************************************************
         // main door
         if(readString.contains("out=5&status=1"))
         {
             // throw the impulse
             digitalWrite(ledMainDoor, HIGH);
             delay(300);
             digitalWrite(ledMainDoor, LOW);
             statusMainDoor = true;
          }else{
             statusMainDoor = false;             
          }
         // ****************************************************    
         
         // ****************************************************
         // temperature
         if(readString.contains("out=0&status=1"))
         {
             statusTemperatureHome = true;
          }else{
             statusTemperatureHome = false;             
          }
         // ****************************************************           
         
         // ****************************************************    
         // get all the devices connected
         if(readString.contains("out=all")){
            whosConnected = true;
         }else{
           whosConnected = false;
         }
         // ****************************************************             
         
          // now output HTML data starting with standart header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          
          //printing out status
          // little gate
          char buf[12];
          if (statusLittleGate){
              client.print("{\"status\" : \"ok\" , \"out\" : \""); 
              client.print(ledLittleGate);
              client.print("\"}");              
          }
          
          // temperature home
          if (statusTemperatureHome){
              /*int i;
              for(i = 0;i<=7;i++){ // gets 8 samples of temperature
              samples[i] = ( 5.0 * analogRead(ledTemperature) * 100.0) / 1024.0;
              tempc = tempc + samples[i];
              delay(200);
              }
              tempc = tempc/8.0;*/
            
              tempc = (( 5.0 * analogRead(ledTemperature) * 100.0) / 1024.0) * 0.356;            
              client.print("{\"status\" : \"ok\" , \"out\" : \""); 
              client.print(ledTemperature);
              client.print("\", \"value\" : \"");
              client.print(tempc);
              //client.print(temperature.celsius());
              client.print("\"}");   
          }
              
          // main door
          if (statusMainDoor){
              client.print("{\"status\" : \"ok\" , \"out\" : \""); 
              client.print(ledMainDoor);
              client.print("\"}");    
          }              
              
          if (whosConnected){
            client.print("{\"ip\" : \"192.168.10.15\", \"devices\" : [{ \"type\" : \"gate\", \"name\" : \"cancellino ingresso\", \"out\" : \"");           
            client.print(ledLittleGate);
            client.print("\"}");    
            client.print(", {\"type\" : \"door\", \"name\" : \"porta ingresso\", \"out\" : \"");
            client.print(ledMainDoor);
            client.print("\"}");    
            client.print(", {\"type\" : \"temperature\", \"name\" : \"temperatura corridoio\", \"out\" : \"");
            client.print(ledTemperature);
            client.print("\"}");             
            client.print("]}");            
          }
          
          //clearing string for next read
          readString="";
          //stopping client
          client.stop();
            }
          }
        }
      }
 }

Looking good, but nothing on the marked... :-/

What version is it made for?

if i search on the market "domotichome" or "arduino" i catch it, dont you? let me know!

Nothing, tried both domotichome and arduino.

But my phone is running Android 1.5, maybe your app isn't made for it?

Pretty cool, you should add some more features like turning on wall sockets so you can plug other things in (turning them off an on remotely)

@bld you're right I signed the app for android version > 1.5, by the way, if you want you can try to download it here

let me know if it works!

@xMagnax i've already linked a wall socket to arduino through a relay+driver and it works fine!

hehehe, nop... nothing either...

The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved.

Hard to get this program. :sunglasses:

i forgot the rar extension! grrrr!

What should that be opened with, or how to install it? All the other programs I have installed manually all had a file ending on so the apps installer could find them. But inside the rar there are only a "file" no ext

yeah, into the rar there is an .apk file, it's a variant of jar files and it's used for the distribution of android component. To install you need to copy the apk on your sd card and doewnlaod an apk manager from the market, I suggest "ApkInstaller". For more information

No, there are no .apk there.. The file in the rar got no extension, and if I just rename it and put it on the phone, it tells me that the file is broken.

Maybe something happend when you uploaded the file?

Thank you for this great idea!
Can you share android code please?
Regards,
eZar.

Any chance of getting your entire sketch? I have an app inventor program that I would like to use but need to program my arduino correctly to recognize web commands and I think this would work.

ok guys enjoy:

it's my first time on github, hope all work fine, if someone will find bugs (nad I think there are on it) or needs some customizations let me know, of course, forking the project is welcome!

Hey, i like your project :slight_smile:

I have downloaded the android app, but can we have the .pde sktech ? I don't know how to send the JSON reponse with my Arduino

you can find an example at the first page of this thread :slight_smile:

Yeah ! Sorry, i had not seen :slight_smile:

Thanks, and sorry for my english, i'm french .

And good work for this ^^