Chip W5500 and Arduino UNO doesn't read incoming byte from server (Web Client)

Hello.

I have an Arduino UNO and W5500 (not Ethernet Shield).

I run the webserver example of the Arduino IDE 1.6.6 use WIZ Ethernet Library IDE1.6.x from GitHub and its works

but, when I run the webclient example. Serial monitor tells that the network has been connected but doesn't read and print incoming byte available from the server.

I tried with Arduino IDE from 1.0x until 1.6.x with another WIZ ethernet library from GitHub and it happens same.

Anyone can share with me if you have solution in this problem..

Thank You

Hello,

I have similar problem. Server instance runs, but as soon as there is client.println it hangs.

Have you found solution?

@vyoscan: Are you running server or client code? You should post your code that is failing.

Hello :),

I use the WebServer example, but with WebClient I see the similar issue.

Whenever it tries to do client.print(something) it hangs. If I put break; just after the response all works repeatedly. I mean I can see the incoming http request in serial window.

Sometime if I move the break after the first client.print(something) it works for randomly for up to 5 times. Then it hangs.

I have used both Ethernet2 or WizNet libaries from GitHub. They act the same.

#include <SPI.h>
#include <Ethernet2.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(10, 10, 10, 200);
IPAddress gateway(10, 10, 10, 254);
IPAddress subnet(255, 255, 255, 0);

EthernetServer server(80);

void setup() {
pinMode(4, OUTPUT); 
digitalWrite(4, HIGH);
  
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.print(client);
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // 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) {
          break;                                                 <--- all works up to here
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("
");
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

I use the Wiznet library from Github with my w5100 and that library works fine.

Which ethernet shield are you using? Can you post a link to it?

edit: Don't know if this is causing your problem, but your code is missing a client.println() call that separates the header from the html doc.

          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
// missing client.println(); here
          client.println("<!DOCTYPE HTML>");

I'm testing my w5100 web server today if you want to see how my server code works, click here.
Here is the code I'm using.
http://playground.arduino.cc/Code/WebServerST

I have tried WizNet library (GitHub - Wiznet/WIZ_Ethernet_Library: WIZnet Ethernet Library) and Ethernet2 from Adafruit. They are intended for W5500 chips. Same symptoms with both.

I have had the client.println(); you mention, good eye, but no difference.

I'm using my own created board with W5500 on it (http://openhomesecurity.blogspot.cz/). So I don't know where to start, as this look to me as software problem. Because the SPI is working, it gets address and server instance works. Ethernet part is working, ping is OK, I can see data from connected web browser. ... I should probably look around how to debug W5500 register setting and communication.

BTW, nice server and reasonably fast.

I've worked with other users of the w5500 with my code and the Github library, and they had no problems. I seriously doubt it is a software problem, but you could be right.

Are there any other w5500 users out there who can verify this one way or the other?

edit: DFRobot is notorious for putting the PWRDN and RESET lines on the I/O. Are you certain neither of those lines are floating?

Good question, I don't know where to start. This is somehow guessing what might be not right. I have not found PWRDN on W5500, but RESET is connected to atmega reset. And it pull down both when pressed.

As this is my first board with W5500, I was using W5200 before, and I'm getting it now alive, no there is none to compare.

I'm just puzzled by the behavior.

Don't know what to tell you. The Power Down mode is now selected in a register in the w5500, not an IC pin like the w5200. You should be ok there.