Arduino MEGA 2560 + Arduino WiFi Shield issue [SOLVED]

Hello,

My name is Craig, and I'm new to the forums and Arduino development. I'm a EE major at Texas A&M, and my Senior Design Project involves being able to control the Arduino via a webserver over a wireless router. I decided to start learning using the example codes provided in the WiFi Library, however, I'm running into an issue I don't thoroughly understand and was hoping someone could help. I apologize in advance if this question is not in the proper forum.

When using the SimpleWebServerWifi.ino example, it states that navigating to the page's local IP address will allow me to see text with a link to control an LED attached to the Arduino on digital pin 9. After replacing the variables for the SSID and router password, verifying the code, and uploading it to the board, the code compiles fine, and when I open the Serial Monitor, it shows that the board connects just fine to the router.

When I navigate to the local IP page on my laptop though (connected to the same router) I am not presented with any of the text on the page that the code is showing should be there. If I manually navigate to http://192.168.1.9/H, however, it does toggle the LED, so I know the function is working in the code, but am not sure why the text is not displaying on the page.

I ran the other example in the WiFi library, WiFiWebServer, that spits out the values of Analog pins 0-5, and that text displays fine. I am not sure why the code for SimpleWebServerWifi isn't working.

Any assistance from the community would be most welcome. If I am needed to post my slight edits to the code (which only consist me changing the SSID and password to match my router) let me know and I will provide it.

Thanks,
Craig

When I navigate to the local IP page on my laptop though (connected to the same router) I am not presented with any of the text on the page that the code is showing should be there.

With what browser on what operating system?

If you right click on the "blank" page, what does the page source look like?

Tested on Windows XP and Windows 8 using Google Chrome as my primary browser.
Checked again using Internet Explorer and Firefox and no dice.

Right clicking and showing page source just shows up as blank running this example.

If I do the same thing for the other example (WiFiWebServer), I see the page source information just fine.

The Simple example is missing some probably essential stuff, like:

          client.println("<html>");
          client.println("</html>");

Neither example produces a very good web page.

You are correct, they are pretty poor web pages, but I was just following the examples for a basic setup. I was hoping to add some of my own webcode later after seeing how it is handled in Arduino.

Adding the tags did not work for me.. It seems to be skipping the calls.
From the SimpleWebServerWifi file:

if (currentLine.length() == 0) {  
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:    
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connnection: close");
            client.println();
            client.println("<!DOCTYPE HTML>");
            client.println("<html>");
            // the content of the HTTP response follows the header:
            client.print("Click <a href=\"/H\">here</a> turn the LED on pin 9 on
");
        
            client.print("Click <a href=\"/L\">here</a> turn the LED on pin 9 off
");

            // The HTTP response ends with another blank line:
            client.println();
            client.println("</html>");
            // break out of the while loop:
            break;         
          }

I am now seeing stuff in my Show Page Source, but those lines with the link calls are omitted.

[EDIT] Problem fixed. The issue with the a href calls was that they were incorrectly defined for calling a local page. Adding a . before /H and ./L fixed the issue.

            client.print("Click <a href=\"./H\">here</a> turn the LED on pin 9 on
");
            client.print("Click <a href=\"./L\">here</a> turn the LED on pin 9 off
");

Thanks for all the help, even if I found it on my own, your comment on "not a very good web page" helped me look harder at what was wrong.

Could you add a post on the Website and Forum, referencing this one, that describes the issue with the example? That part of the forum is the only one that the Arduino team seems to monitor regularly.