Ethernet 2 Shield - Reliability

Hi Guys,
I need some help as the reliability issues I am facing at the moment is causing myself a lot of pain.
I have a genuine Mega 2560 and Ethernet 2 Shield with POE (w5500).

It doesn’t matter if I use my sketch or the example around 50% of the HTTP calls I make result in en error or malformed content.

This is an example from a terminal using CURL.

Other than placing the shield on top and putting in the MAC address, what am I doing wrong?

I need this to be reliable.

a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
?@m?"r?????<???w?p?DG?*{????r?
                              ?????r?S?߲???A?⹲H6??ƨ?)?9č????4??p?>o?#l^?7?2?^?[?\<1???f?o?)???K\????)?
??S?????QCG7b?h?????wze???z??r?????F?BZ???ӳ??/C$??k??5?ڨ?u??4?}sw?Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
oRelay 1 Of
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
curl: (52) Empty reply from server
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay1off
Relay 1 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay2off
Relay 2 Off
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay2on
Relay 2 On
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay2on
curl: (52) Empty reply from server
a45e60c1ace3:KeyPairs balshane$ curl http://10.0.50/?relay2on
Relay 2 On

I either get no reply back, what I expect or jibberish.

Thoughts???

Are you using the correct library for the w5500? The standard library included with the IDE is for the w5100. You must install the Ethernet2 library and use it.

Sure have SurferTim. Nothing works with the W5100 library.

Any other thoughts?

10.0.50 is not a valid IP address. Put the IP address of the Ethernet2 shield.

http://10.0.50/?relay1off

You lost me there gdsports, 10.0.0.50 is a valid IP for my subnet and that is what the shield is binding to.

What should I change it to?

My mistake there, even with the missing 0, it still doesnt work reliably.

What happens when you ping the IP address?

I get my usual ICMP responses just fine.

Just HTTP GET (acting as a server) and my POSTS (to update another PLC) are un-reliable. Even if use a built in sketch from the Library it just doesnt seem to work reliably.

Does this shield work reliably with the Mega2560?

I have not used the W5500 very much. Do you have more than 1 Arduino Ethernet shield on the network. They must have unique hardware MAC addresses. Duplicate MAC addresses will cause problems.

I only have one running. Here is a video of what I am seeing. Its driving me nuts here.

This is a standard Ethernet2 sketch, I have some python which is just returning the HTTP output. Nothing special. https://baldacchino-public.s3-ap-southeast-2.amazonaws.com/ArduinoMalformedOutput.mov?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIOOST6S4AY5F66SQ/20180115/ap-southeast-2/s3/aws4_request&X-Amz-Date=20180115T090116Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=3cc6f3bb34fe823c8d444c12d79756ee5faa285e364d4edd8d4d021a5ef9548b

Getting quite desperate here so any help is appreciated

Post the Arduino code that does this.

After years of participating in this forum, I have found there is no such thing as "standard" Ethernet code for any shield.

Thanks SurferTim for the reply. What I am pasting here is a standard sketch as part of the examples, the only thing that has changed is the IP address. My more complex sketch exhibits the exact same behaviour. Just pasting a standard sketch in as its simplier and hopefully more familar to everyone.

Looking for any help as its driving me nuts. I am using 1.04 of the Ethernet library and have tried 1.03 without any luck. I am far from an Arduino expert but it really feels library related here. It doesnt matter if I use a browser (FF/Chrome/etc), CURL or Python to invoke HTTP I get the same random reliability :frowning:

Here is the code from the standard webserver sketch

/*
  Web Server

  A simple web server that shows the value of the analog input pins.
  using an Arduino Wiznet Ethernet shield.

  Circuit:
   Ethernet shield attached to pins 10, 11, 12, 13
   Analog inputs attached to pins A0 through A5 (optional)

  created 18 Dec 2009
  by David A. Mellis
  modified 9 Apr 2012
  by Tom Igoe

*/

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0XD0, 0x66 };
byte gateway[] = { 10, 0, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };
IPAddress ip(10, 0, 0, 50 );

// 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:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


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


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;
    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) {
          // 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();
          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");
  }
}

baldacchino: I am using 1.04 of the Ethernet library and have tried 1.03 without any luck.

What do you mean by 1.04 and 1.03? How did you find that? Is that the IDE version?

Hi SurferTim,
Version 1.04 and 1.03 are the versions of the Ethernet2 Library from within the Arduino IDE under “Manage Libraries”.

1.04 is the latest version. It can also be downloaded from GitHub at GitHub - adafruit/Ethernet2: WIZ5500 based Ethernet Shield library

Do you think it kind of like an UART / Baud rate setting where there is a timing mismatch. I just dont get why it doesnt reliably work.

Hey, appreciate the replies here SurferTim.

  • Shane

I haven't had a problem with the libraries except when I have a SD card in the shield's slot. I have v1.04, but I no longer have my w5500 to test it with.

I assume you have seen my movie?

I have nothing in the SD card slot Tim.

Any idea or thoughts for me here? What should I be doing?

Is it possible I have an issue with the shield?

It currently has been an $80 AUD pain in the butt.

Tim - Still reading on this - very similar to http://forum.arduino.cc/index.php?topic=100335.15 to which you participated in.

My symptoms are very very similar.

Do you think its just not compatible with my 2560 v3?

I don't know what to tell you. There have been reports of ethernet shields assembled with bad solder joints (bridges) and incorrect resistor values. Either could cause a problem.

How do you return such items (it was bought from RS Components), my clone 5100 without POE works, its just this W5500 genuine Arduino that is killing me here.