Go Down

Topic: Arduino Uno Web page host problem (Read 2020 times) previous topic - next topic


Hey guys I have a strange problem I can't figure out with my arduino webpage...

I am running a Uno (R2) with an Ethernet shield. The code is below.

The program creates a webserver that allows me to control my X10 lights via a web browser.
It works great and is totally awesome.

The problem is that when I switch from Wifi to Verizon on my phone (Samsung Galaxy S3) the webpage will not completely load the buttons. I have tried various browsers to no avail. It works great on Wifi inside or outside of my network.

However on my wifes phone and friends phones (S4 Active, some type of windows phone) it loads fine. They are both on ATT.

So it would apear that the problem is related to Verizon since it works on ATT.


Thanks, Alex


 Web Server with X10 Firecracker control
 No need for a app, or a program on the PC, this simple arduino program allows web based html button control of the arduino from any browser, on a PC, IPAD, IPOD, smart phone.  
 A Waltsailing Production

* Ethernet shield attached to pins 10, 11, 12, 13
*  x10 Firecracker attaches to pins 8 and 9


#include <SPI.h>
#include <Ethernet.h>
#include <X10Firecracker.h>
#include <WString.h>
#include <utility/w5100.h>

#define RTS_PIN     8                   // RTS line for C17A - DB9 pin 7
#define DTR_PIN     9                   // DTR line for C17A - DB9 pin 4
#define BIT_DELAY   1                   // mS delay between bits (1 mS OK)

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:

byte mac[] = {
 //90xDE, A2xAD, DAxBE, 0ExEF, C8xFE, 40xED };
   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,10,52);

String s = String(30); //string for fetching data from address
String cmd = "/X" ; //X is an example of the command that will come after the ethernet address in the GET...

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
// Open serial communications and wait for port to open:
  while (!Serial) {
   ; // wait for serial port to connect. Needed for Leonardo only
 Serial.print("Pgm started  ");

 // start the Ethernet connection and the server:
 Ethernet.begin(mac, ip);
 Serial.print("server is at ");



void loop() {
 // listen for incoming clients
 EthernetClient client = server.available();
 if (client) {
   Serial.println("new client");
   // an http request ends with a blank line
   boolean currentLineIsBlank = true;
   boolean DoPage=true;
   while (client.connected()) {
       if (client.available()) {
              char c = client.read();
              if (s.length() < 7) { s.concat(c); }   // build up a short string to parse
              if(s.substring(0,3) == "GET" & DoPage){    // check for the GET from the web page
                    cmd=s.substring(4,6);        // get the 2 letters in the string out and call this the CMD,  /A, or /B or /H etc, these come in after the GET
                    // Serial.println("CMD=");
                    // Got a GET so, compare the received command to the specific command and then do something
                    if (cmd == "/A" && DoPage) {
                               Serial.println(F("Found A Front Porch Light on "));      
                               X10.sendCmd( hcA, 16, cmdOn );
                              DoPage = false;
                    if (cmd == "/B" && DoPage) {
                               Serial.println(F(" Light Dim"));
                               X10.sendCmd( hcA, 14, cmdDim );
                              DoPage = false;
                    if (cmd == "/H" && DoPage) {
                               Serial.println(F(" Light Bright"));
                               X10.sendCmd( hcA, 14, cmdBright );
                              DoPage = false;
                    if (cmd == "/C" && DoPage) {
                               Serial.println(F("Found C Front Porch Light Off"));
                               X10.sendCmd( hcA, 16, cmdOff );
                              DoPage = false;
                    if (cmd == "/S" && DoPage) {
                               Serial.println(F("Found S  Back Porch Light on"));
                               X10.sendCmd( hcA, 14, cmdOn );
                              DoPage = false;
                    if (cmd =="/R" && DoPage) {
                               Serial.println(F("Found R Back Porch Light Off"));
                               X10.sendCmd( hcA, 14, cmdOff );
                              DoPage = false;
                    if (cmd == "/U" && DoPage) {
                               Serial.println(F("Found U Master Bed room Light on"));
                               X10.sendCmd( hcA, 13, cmdOn );
                             DoPage = false;
                    if (cmd =="/W" && DoPage) {
                               Serial.println(F("Found W Master Bed room lamp Off"));
                               X10.sendCmd( hcA, 13, cmdOff );
                              DoPage = false;
             // if you've gotten to the end of the line (received a newline
             // character) and the line is blank, the http request has ended,
             // so you can send a reply
             if (c == '\n' && currentLineIsBlank) {
             // send a standard http response header
                     client.println(F("HTTP/1.1 200 OK"));
                     client.println(F("Content-Type: text/html"));
                     client.println(F("Connnection: close"));
                     client.println("Refresh: 5");
                     client.println(F("<!DOCTYPE HTML>"));
                     client.println(F("<meta content='text/html; charset=ISO-8859-1'http-equiv='content-type'>"));
                     client.println(F("<title>X10 Control"));
                     // the next line sets the background color to something nice like blue
                     client.println(F("<body style='background-color: rgb(0, 0, 153); color: rgb(255, 255, 0);'alink='#cc6600' link='#cc0000' vlink='#993300'>"));
                     //  load in a background .jpg for the web page.
                     //client.println(F("<BODY BACKGROUND='http://home.comcast.net/%7EWaltschn1/Waltschn1/la_dolce_vita_near_dock_2s.jpg' style='width: 481px; height: 690px;'></span><br>"));
                     //  set up some HTML that has buttons with specific actions that link back to the arduino at the address of the arduino and have a specific string
                     client.println(F("<FORM METHOD='LINK' ACTION='http://(ip left blank intentionally)/A\r'><INPUT TYPE='submit' VALUE='Front Porch Light On '></FORM>  "));                  
                     client.println(F("<FORM METHOD='LINK' ACTION='http://(ip left blank intentionally)/C\r'><INPUT TYPE='submit' VALUE='Front Porch Light Off '></FORM>  "));      
                     client.println(F("<FORM METHOD='LINK' ACTION='http://(ip left blank intentionally)/S\r'><INPUT TYPE='submit' VALUE='Back Porch Light On  '></FORM>  "));
                     client.println(F("<FORM METHOD='LINK' ACTION='http://(ip left blank intentionally)/R\r'><INPUT TYPE='submit' VALUE='Back Porch Light Off '></FORM>  "));
                     client.println(F("<FORM METHOD='LINK' ACTION='http://(ip left blank intentionally)/U\r'><INPUT TYPE='submit' VALUE='Master Bed room Light on '></FORM>  "));
                     client.println(F("<FORM METHOD='LINK' ACTION='http://(ip left blank intentionally)/W\r'><INPUT TYPE='submit' VALUE='Master Bed room Light Off'></FORM>  "));  
                     //client.println(F("<FORM METHOD='LINK' ACTION='http://(ip left blank intentionally)/B\r'><INPUT TYPE='submit' VALUE='Light Dim'></FORM>  "));
                     //client.println(F("<FORM METHOD='LINK' ACTION='http://(ip left blank intentionally)/H\r'><INPUT TYPE='submit' VALUE='Light Brighten'></FORM>  "));
                     //client.println(F("<FORM METHOD='LINK' ACTION='http://(ip left blank intentionally)/H\r'><INPUT TYPE='submit' VALUE='Taco'></FORM>  "));
                     // Clear out the received string
               if (c == '\n') {
                     currentLineIsBlank = true;
               else if (c != '\r') {
                     currentLineIsBlank = false;
   Serial.println("client disonnected");
}  // end


Nothing to do with your issue, but read #7 below on posting code.

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


I have the same problem. It has to do with timing. The Ethernet library is not capable to handle devices with slow timing. A slow wireless device on my local network can not request the webpage from the Arduino. It is a big problem for me, but I have not yet found the problem.
Just like you I tried changing the browser, but that did not help either.


Code: [Select]
String s = String(30); //string for fetching data from address
rather than
Code: [Select]
String s = "30";

That's what the code is doing. Why?
The art of getting good answers lies in asking good questions.

Go Up