Pages: 1 ... 5 6 [7]   Go Down
Author Topic: Arduino Controller android app  (Read 46628 times)
0 Members and 1 Guest are viewing this topic.
Ontario, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

RichieC,
I noticed that in case 9 where you switch everything on , you don't have a  ;break:

case 9: digitalWrite(GasBoiler, HIGH);digitalWrite(HeatPump, HIGH);digitalWrite(UndFlor, HIGH);
/* Basically a call for all Heating on */

Should it be:
case 9: digitalWrite(GasBoiler, HIGH);digitalWrite(HeatPump, HIGH);digitalWrite(UndFlor, HIGH);break;
/* Basically a call for all Heating on */

Just wondering if things may hang after a case 9 is issued ?
Bob
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Marque.

Any chance of a sketch for a wifi connection?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks I'll change this today and see if it helps.

Thanks

Rich
Logged

Offline Offline
Jr. Member
**
Karma: 4
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Marque

 I still using your app to control my heating but I'm having trouble. The server side of my program doesn't run for very long before stopping. The main part of my program still contuines to run but my devices won't connect to the Arduino Board.

I have attached my code for you to see if there is anything obvious.

Thanks

Richard

At the end of the sketch i see a strange part. maybe it is causing the trouble.

Code:
x=0;
if (x == 0)
 {
  client.println(" ");
 }
}

In my own programs i try to contact google.com every hour. When it fails, the arduino resets itself.
Logged


Offline Offline
Jr. Member
**
Karma: 4
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Here are examples of what I see in the serial monitor no matter what buttons I press on the Android app:
Droid 4:
*CLOS**OPEN*GET /?1 HTTP/1.1
Host: 192.168.43.38:2000
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
X-Requested-With: com.marquesoft.ArduinoControllerPro
User-Agent: Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; DROID4 Build/9.8.2O-72_VZW-18) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Accept-Encoding: gzip,deflate
Accept-Language: en-US
Accept-Charset: utf-8, iso-8859-1, utf-16, *;q=0.7

Acer A500:
*CLOS**OPEN*GET /?1 HTTP/1.1
Host: 192.168.43.85:2000
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; A500 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
Accept-Encoding: gzip,deflate
Accept-Language: en-US
Accept-Charset: utf-8, iso-8859-1, utf-16, *;q=0.7
x-wap-profile: http://support.acer.com/UAprofile/Acer_A500_Profile.xml



The "OPEN*GET /?1 HTTP/1.1" part looks Ok. The 1 after the ? should change for each button you programmed.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks I'll check my code


Quote
in my own programs every hour I try to contact google if it fails the arduino resets itself

How do you do that? Could you paste the code here please?

Thanks

Rich
Logged

Offline Offline
Jr. Member
**
Karma: 4
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


How do you do that? Could you paste the code here please?

Thanks

Rich

Use rtc or millis to execute a networkcheck(); every hour.

Declare:
Code:
IPAddress ServerToCheck (74,125,228,32 );         //IP adress of google
char dnsServerToCheck[] = "google.com";             // set the name of the server to check
boolean networkonline = false;
boolean DNS = false;

Code:
void networkcheck()
{
 Serial.println ("Network check");
  if (client.connect(dnsServerToCheck, 80))
  {
    delay(300);
    Serial.print("connected to ");
    Serial.println(dnsServerToCheck);
    client.println("GET / HTTP/1.1");
    client.println();
    while (client.connected())
    {
      if (client.available())
      {
        char c = client.read();
        if (readString.length() < 20)
          Serial.print(c);
        {
          readString.concat(c);
        }
        if (c == '\n')
        {
          client.stop();
          Serial.println();
         Serial.println("DNS OK");
          DNS = true;
          networkonline = true;
          readString="";
        }
      }
      if (!client.connected())
      {
        client.stop();
        readString="";
      }
    }
  }
  if (!DNS)
  {
     Serial.println("DNS Error");
    Serial.println("Check for IP");
    if (client.connect(ServerToCheck, 80))
    {
      delay(300);
       Serial.print("connected to ");
       Serial.println(ServerToCheck);
      client.println("GET / HTTP/1.1");
      client.println();
      while (client.connected())
      {
        if (client.available())
        {
          char c = client.read();
          if (readString.length() < 20)
             Serial.print(c);
          {
            readString.concat(c);
          }
          if (c == '\n')
          {
            client.stop();
           Serial.println();
            Serial.println("IP lookup OK");
            Serial.println("DNS not available");
            networkonline = true;
            readString="";
          }
        }
        if (!client.connected())
        {
           Serial.println("Disconnecting");
          client.stop();
          readString="";
        }
      }
    }
    else
    {
      Serial.println("Network Error");
    resetFunc();
    }
  }
}
void(* resetFunc) (void) = 0; //declare reset function @ address 0
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi will this be able to work with a WIFI shield instead of an Ethernet shield?
Logged

Offline Offline
Jr. Member
**
Karma: 4
Posts: 86
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi will this be able to work with a WIFI shield instead of an Ethernet shield?

Can you give me a example of a wifiserver code so i can modify it to work with the controller app.
Logged


Pages: 1 ... 5 6 [7]   Go Up
Jump to: