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..
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 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.
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.