Go Down

Topic: Wifi shield pinging but not serving page (Read 10068 times) previous topic - next topic

jbpkruppa

Hi, folks.
Yesterday I received my wifi board (original italian one) and tried the simple server example to test it. After setting my wifi parameters, the board get an ip (shown in serial output) but when I try to access via browser, it can't connect. I've already tried to update its firmware, but seems it is still unable to connect. I am using it whith a freeduino uno r3 board, but also tried with duemilenouve using a jumper on 3.3v pin.
I tried also to power it with 1A adapter besides using usb, but the problem persists.

What can be done in this case?

Thanks in advance.

StanleyAudio

I also have the same problem. I use Mega 2560. I tried to ping to the given IP address and got response, but the browser access is not, really anxious to get any feedback also. Thanks
Stan.

Ludgy

Good morning guys.

I experienced the same problem and after much searching, I came across a thread somewhere that suggested rolling back to version 1.0.3 of the IDE and that fixed the problem for me.

Seems there's a bug in 1.0.5

Ludgy

Ok...
I've finally figured out the problem.

Turns out you have to update the Wi-fi shield's firmware for it to work properly with version 1.0.5 of the IDE.

If you need help doing to upgrade, please let me know.
The tutorial found here http://arduino.cc/en/Hacking/WiFiShieldFirmwareUpgrading is quite confusing.

Cheers

o2drink

I wish I could say the same.   I've put in way too many hours to get my wifi shield to work ( http://forum.arduino.cc/index.php?topic=128424.15 ) [reply28].     I posted the files I'm using for the firmware updates there along with my sketch.   If you have time, I'd love to get your take on it.    I also tried the 1.0.3 IDE with these firmwares, but still no luck.   The serial reports that that there is a 'new client' and 'client disconnected' but nothing is served to the browsers  (IE and Firefox).

Ludgy

#5
Aug 16, 2013, 12:18 pm Last Edit: Aug 16, 2013, 12:21 pm by Ludgy Reason: 1
Right.
With some of these things, it's probably best to start at the beginning so let's do this :)

Please download the 2 firmware files I've attached and save them to the root of your C drive.

I assume you have already downloaded the FLIP package from the Atmel page here: http://www.atmel.com/tools/FLIP.aspx

Next, unplug the Wifi shield from the Arduino and short out the jumper on the Wifi board to put it into programming mode.
Connect the shield to your PC via USB and then start up a command prompt.

In the command prompt, change directories to the path where you've installed the FLIP package (i.e. cd C:\Program Files (x86)\Atmel\Flip 3.4.7\bin) and execute the following command:
Code: [Select]

batchisp.exe -device AT32UC3A1256 -hardware usb -operation erase f memory flash blankcheck loadbuffer c:\wifi_dnld.elf program verify start reset 0


Check if all jobs have passed. If not, post the output here.

If all jobs have passed, reset your shield by pressing it's reset button and then continue to the next command :
Code: [Select]

batchisp.exe -device AT32UC3A1256 -hardware usb -operation erase f memory flash blankcheck loadbuffer c:\wifiHD.elf program verify start reset 0



Check if all jobs have passed. If not, post the output here.

You're done with the update.
Re-connect your shield to the Arduino and plug in to PC via USB.

Upload the following sketch making sure you change the SSID and insert your password to fit your wireless network settings.
I've quoted out the IPAddress for now so your router can assign an IP address for you. (make sure DHCP is enabled on your router)
If you'd like to assign your own IP, feel free to unquote the "//IPAddress ip(190, 160, 0, 50);" and "//WiFi.config(ip);" lines respectively.

Code: [Select]

/*
 WiFi Web Server LED Blink

A simple web server that lets you blink an LED via the web.
This sketch will print the IP address of your WiFi Shield (once connected)
to the Serial monitor. From there, you can open that address in a web browser
to turn on and off the LED on the selected pin.

If the IP address of your shield is yourAddress:
http://yourAddress/H turns the LED on
http://yourAddress/L turns it off

This example is written for a network using WPA encryption. For
WEP or WPA, change the Wifi.begin() call accordingly.

Circuit:
* WiFi shield attached
* LED attached to a pin

created 25 Nov 2012
by Tom Igoe
*/
#include <SPI.h>
#include <WiFi.h>
const int ledPin = 4;         //Pin where LED is connected

char ssid[] = "your netword SSID here";
char pass[] = "your password here";


int keyIndex = 0;                  // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
//IPAddress ip(190, 160, 0, 50);
WiFiServer server(80);

void setup() {
 Serial.begin(9600);      // initialize serial communication
 pinMode(ledPin, OUTPUT);      // set the LED pin mode

 // check for the presence of the shield:
 if (WiFi.status() == WL_NO_SHIELD) {
   Serial.println("WiFi shield not present");
   while(true);        // don't continue
 }
 
 //WiFi.config(ip); //used if you want to assign a static IP
 
 // attempt to connect to Wifi network:
 while ( status != WL_CONNECTED) {
   Serial.print("Attempting to connect to Network named: ");
   Serial.println(ssid);                   // print the network name (SSID);

   // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
   status = WiFi.begin(ssid, pass);
   // wait 10 seconds for connection:
   delay(10000);
 }
 server.begin();                           // start the web server on port 80
 printWifiStatus();                        // you're connected now, so print out the status
}

void loop() {
 WiFiClient client = server.available();   // listen for incoming clients

 if (client) {                             // if you get a client,
   Serial.println("new client");           // print a message out the serial port
   String currentLine = "";                // make a String to hold incoming data from the client
   while (client.connected()) {            // loop while the client's connected
     if (client.available()) {             // if there's bytes to read from the client,
       char c = client.read();             // read a byte, then
       Serial.write(c);                    // print it out the serial monitor
       if (c == '\n') {                    // if the byte is a newline character

         // if the current line is blank, you got two newline characters in a row.
         // that's the end of the client HTTP request, so send a response:
         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();

           // the content of the HTTP response follows the header:
           client.print("Click <a href=\"/H\">here</a> to turn Ludgy's light ON<br>");
           client.print("Click <a href=\"/L\">here</a> to turn Ludgy's light OFF<br>");

           // The HTTP response ends with another blank line:
           client.println();
           // break out of the while loop:
           break;        
         }
         else {      // if you got a newline, then clear currentLine:
           currentLine = "";
         }
       }    
       else if (c != '\r') {    // if you got anything else but a carriage return character,
         currentLine += c;      // add it to the end of the currentLine
       }

       // Check to see if the client request was "GET /H" or "GET /L":
       if (currentLine.endsWith("GET /H")) {
         digitalWrite(ledPin, HIGH);               // GET /H turns the LED on
       }
       if (currentLine.endsWith("GET /L")) {
         digitalWrite(ledPin, LOW);                // GET /L turns the LED off
       }
     }
   }
   // close the connection:
   client.stop();
   Serial.println("client disonnected");
 }
}

void printWifiStatus() {
 // print the SSID of the network you're attached to:
 Serial.print("SSID: ");
 Serial.println(WiFi.SSID());

 // print your WiFi shield's IP address:
 IPAddress ip = WiFi.localIP();
 Serial.print("IP Address: ");
 Serial.println(ip);

 // print the received signal strength:
 long rssi = WiFi.RSSI();
 Serial.print("signal strength (RSSI):");
 Serial.print(rssi);
 Serial.println(" dBm");
 // print where to go in a browser:
 Serial.print("To see this page in action, open a browser to http://");
 Serial.println(ip);
}


Post the Serial output here once you're done.

o2drink

Thank you very much for your reply.   I followed your steps with the replacement files and found the same results; client connects however the browser does not get anything.   I then wiped out my ver of 1.0.5 ide and re-extracted.   I got the same results as before.    Below are my captures.   The first is flashing the files you provided and the second is the serial output from the sketch you provided.   If you have any more ideas, I'm all ears (eyes).   Thanks again for the response.

Code: [Select]
C:\Program Files (x86)\Atmel\Flip 3.4.7\bin>batchisp.exe -device AT32UC3A1512 -h
ardware usb -operation erase f memory flash blankcheck loadbuffer C:\Users\<omitted>\Do
cuments\School\Devry\arduino-1.0-windows\arduino-1.0.5-windows\arduino-1.0.5\har
dware\arduino\firmwares\wifishield\binary\wifi_dnld.elf program verify start res
et 0
Running batchisp 1.2.5 on Fri Aug 16 18:43:26 2013



AT32UC3A1512 - USB - USB/DFU


Device selection....................... PASS
Hardware selection..................... PASS
Opening port........................... PASS
Reading Bootloader version............. PASS    1.0.2
Erasing................................ PASS
Selecting FLASH........................ PASS
Blank checking......................... PASS    0x00000 0x7ffff
Parsing ELF file....................... PASS    C:\Users\<omitted>\Documents\School\Dev
ry\arduino-1.0-windows\arduino-1.0.5-windows\arduino-1.0.5\hardware\arduino\firm
wares\wifishield\binary\wifi_dnld.elf
WARNING: The user program and the bootloader overlap!
Programming memory..................... PASS    0x00000 0x2902b
Verifying memory....................... PASS    0x00000 0x2902b
Starting Application................... PASS    RESET   0

Summary:  Total 11   Passed 11   Failed 0

C:\Program Files (x86)\Atmel\Flip 3.4.7\bin>batchisp.exe -device AT32UC3A1512 -h
ardware usb -operation erase f memory flash blankcheck loadbuffer C:\Users\<omitted>\Do
cuments\School\Devry\arduino-1.0-windows\arduino-1.0.5-windows\arduino-1.0.5\har
dware\arduino\firmwares\wifishield\binary\wifiHD.elf program verify start reset
0
Running batchisp 1.2.5 on Fri Aug 16 18:44:35 2013



AT32UC3A1512 - USB - USB/DFU


Device selection....................... PASS
Hardware selection..................... PASS
Opening port........................... PASS
Reading Bootloader version............. PASS    1.0.2
Erasing................................ PASS
Selecting FLASH........................ PASS
Blank checking......................... PASS    0x00000 0x7ffff
Parsing ELF file....................... PASS    C:\Users\<omited>\Documents\School\Dev
ry\arduino-1.0-windows\arduino-1.0.5-windows\arduino-1.0.5\hardware\arduino\firm
wares\wifishield\binary\wifiHD.elf
WARNING: The user program and the bootloader overlap!
Programming memory..................... PASS    0x00000 0x3fe2b
Verifying memory....................... PASS    0x00000 0x3fe2b
Starting Application................... PASS    RESET   0

Summary:  Total 11   Passed 11   Failed 0

C:\Program Files (x86)\Atmel\Flip 3.4.7\bin>



Code: [Select]

Attempting to connect to Network named: Home
SSID: Home
IP Address: 192.168.1.199
signal strength (RSSI):-65 dBm
To see this page in action, open a browser to http://192.168.1.199
new client
client disonnected

Ludgy

:0 Sorry to hear that.
Have you tried another browser?

SurferTim

#8
Aug 17, 2013, 10:55 am Last Edit: Aug 17, 2013, 11:54 am by SurferTim Reason: 1
Try this as a test. Anything display on your browser?
Code: [Select]
           Serial.println("Sending response");

           // 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\r\n");

           // the content of the HTTP response follows the header:
           client.println("<html><body>TEST<br>");
           client.print("Click <a href=\"/H\">here</a> to turn Ludgy's light ON<br>");
           client.print("Click <a href=\"/L\">here</a> to turn Ludgy's light OFF<br>");
           client.println("</body></html>");

           // The HTTP response ends with client.stop()

edit: Added serial print to response for error checking. Do you see that on the serial monitor?

oric_dan

Tim, I've been wrestling with my own ethernet issues for quite a few days now. I notice that some lines in the code say client.print() and others say client.println().

I understand what these do mechanistically, but not why one is used in one case and other other in another case, as in your code in the previous msg. In my own programs, it seems to matter little, either way.

Also, I notice that, in some case, people use the following symbol to close an HTML directive, namely " />", but don't understand why the '/' is in there. I do understand things like </TR>, where it's obvious what it does.

Sorry, but these things are so basic, it's difficult to track them down. Any help is appreciated, :-).

o2drink

I'm not sure why adding the one serial response line worked, but it all works now.   I'm completely dumbfounded after two solid months of trying everything.   Maybe there was a special char in the copy/pasting that was overwritten?   I am at a loss but completely grateful to both of you.   Thank you!   (And to answer the previous post, I had been using Firefox and IE for testing.)  Also, I just tested with the combo on it's own power and it works wonderfully!

Code: [Select]
Attempting to connect to Network named: Home
SSID: Home
IP Address: 192.168.1.199
signal strength (RSSI):-66 dBm
To see this page in action, open a browser to http://192.168.1.199
new client
GET / HTTP/1.1
Host: 192.168.1.199
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US
Accept-Encoding: gzip, deflate
Connection: keep-alive

Sending response
client disonnected
new client
GET /favicon.ico HTTP/1.1
Host: 192.168.1.199
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US
Accept-Encoding: gzip, deflate
Connection: keep-alive

Sending response
client disonnected
new client
GET /H HTTP/1.1
Host: 192.168.1.199
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US
Accept-Encoding: gzip, deflate
Referer: http://192.168.1.199/
Connection: keep-alive

Sending response
client disonnected
new client
GET /L HTTP/1.1
Host: 192.168.1.199
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US
Accept-Encoding: gzip, deflate
Referer: http://192.168.1.199/H
Connection: keep-alive

Sending response
client disonnected


o2drink

So here is the happy sketch, in case I'm not seeing the subtle html code variations that the previous post had refered to.

Code: [Select]
/*
  WiFi Web Server LED Blink

A simple web server that lets you blink an LED via the web.
This sketch will print the IP address of your WiFi Shield (once connected)
to the Serial monitor. From there, you can open that address in a web browser
to turn on and off the LED on the selected pin.

If the IP address of your shield is yourAddress:
http://yourAddress/H turns the LED on
http://yourAddress/L turns it off

This example is written for a network using WPA encryption. For
WEP or WPA, change the Wifi.begin() call accordingly.

Circuit:
* WiFi shield attached
* LED attached to a pin

created 25 Nov 2012
by Tom Igoe
*/
#include <SPI.h>
#include <WiFi.h>
const int ledPin = 4;         //Pin where LED is connected

char ssid[] = "******";
char pass[] = "******";


int keyIndex = 0;                  // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
//IPAddress ip(190, 160, 0, 50);
WiFiServer server(80);

void setup() {
  Serial.begin(9600);      // initialize serial communication
  pinMode(ledPin, OUTPUT);      // set the LED pin mode

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    while(true);        // don't continue
  }
 
  //WiFi.config(ip); //used if you want to assign a static IP
 
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);                   // print the network name (SSID);

    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:   
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
    delay(10000);
  }
  server.begin();                           // start the web server on port 80
  printWifiStatus();                        // you're connected now, so print out the status
}

void loop() {
  WiFiClient client = server.available();   // listen for incoming clients

  if (client) {                             // if you get a client,
    Serial.println("new client");           // print a message out the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        if (c == '\n') {                    // if the byte is a newline character

          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) { 
            Serial.println("Sending response");

            // 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\r\n");

            // the content of the HTTP response follows the header:
            client.println("<html><body>TEST<br>");
            client.print("Click <a href=\"/H\">here</a> to turn Ludgy's light ON<br>");
            client.print("Click <a href=\"/L\">here</a> to turn Ludgy's light OFF<br>");
            client.println("</body></html>");

            // The HTTP response ends with client.stop()
            client.println();
            // break out of the while loop:
            break;         
          }
          else {      // if you got a newline, then clear currentLine:
            currentLine = "";
          }
        }     
        else if (c != '\r') {    // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }

        // Check to see if the client request was "GET /H" or "GET /L":
        if (currentLine.endsWith("GET /H")) {
          digitalWrite(ledPin, HIGH);               // GET /H turns the LED on
        }
        if (currentLine.endsWith("GET /L")) {
          digitalWrite(ledPin, LOW);                // GET /L turns the LED off
        }
      }
    }
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
  // print where to go in a browser:
  Serial.print("To see this page in action, open a browser to http://");
  Serial.println(ip);

oric_dan

Quote
I'm not sure why adding the one serial response line worked, but it all works now.

For the benefit of those of us who didn't follow everything, which exact point in your sketch is the fix? --> "adding the one serial response line"

zoomkat

Quote
I've been wrestling with my own ethernet issues for quite a few days now. I notice that some lines in the code say client.print() and others say client.println().


The client.println() adds a carriage return and line feed to what is sent, which the browser may or may not use. These are required in the header returned to the browser so the browser knows what to do. In the actual html returned to the browser, the carriage return and line feed do not appear to be used or needed, and may actually slow the return of the data to the browser. The below code is tweaked a bit to save arduino memory space using the F() macro, and \r\n\ to reduce the client.print statements used.


Code: [Select]

          //now output HTML data header

          //client.println("HTTP/1.1 200 OK");
          //client.println("Content-Type: text/html");
          //client.println();
         
          client.print(F("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));

          client.println(F("<HTML><HEAD><TITLE>Arduino GET test page</TITLE>"
            "</HEAD><BODY><H1>Zoomkat's simple Arduino button</H1>"
            "<a href='/?on'>ON</a>&nbsp;<a href='/?off'>OFF</a></BODY></HTML>"));
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

oric_dan

Thanks, zk. So why isn't this one client.println()?
Quote
client.print(F("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));

Sheesh, it never ends [slaps, then bangs, forehead], LOL.

Go Up