Ethernet Shield Disconnecting after a while

Here’s the deal: I have an age old projecto of setting a PWS (personal weather station). I’ve decided for an Arduino with an array of sensors. No big deal as far as the sensors goes.

The thing is that, whilst waiting for the other sensors to arrive, I wanted to start working on the web side of the PWS, monitoring temperature and humidity.

The problem: After some random amount of time (it varies from half an hour up to 24+hours). the Arduino becomes unreachable via web (still responds to pings). Sometimes, you can see on the web browser something like this:

/b>resh: 5 Temperatura: 30.91C / Heat Index: 36.85C / Humedad: 68.27% Uptime: 165 seconds.
b> 30.91C / Heat Index: 36.85C / Humedad: 68.30% Uptime: 122 seconds.
7‹ÑB_ ™8>9’ õ½Ïhe–)eâPá)¡Ò”œ¹92Æ6ÚiBªDù¯ã62ø m¨YÅ…ŒÔÈK¿d%1'¬}AD™•á†5@`:e“¼Z`«Rdá͐7×ÊìX¼ÃbÅ“ÎҁµæÌ6»ƒñASe͵#hž,§LžÇ&ïWãƒ(cÛѾ7ì@G˜üè¥:„Kit‰"’¦®Ìª›HµôôFˆtÇ30.86C / Heat Index: /b>36.75C / Hume seconds.
ecoC / Heat Index: 36.72C / Hum onds. ™¸¡¶V:˜†`FVf7娎*á¦§©Ó‡TE{<7]z”¹&WÐa‹ÏÐ+.ØÓúŒÍ‘øºÒ1xŽ§‰UßÌ|,(°ÜÃ`p5?—‰¡JSCB›‹JH• ÙmHTTP/1.1 200 OK Content-Type: text/html Connection: close Refresh: 5 Temperatura: 30.98C / Heat Index: 37.02C / Humedad: 68.19% Uptime: 32 seconds.

I have to reboot to gain access to it again.

I don’t feel is a hardware issue. I Updated the Ethernet library to this one: GitHub - embeddist/WIZ_Ethernet_Library-IDE1.6.x: support to Arduino Ethernet Shield (W5100/W5200/W5500) and WIZ550io on Arduino IDE 1.6.4

I’ve done programming way a long time ago. I’ve been working over the WebServer sample file. Not a designer either so the web page I’m producing is plain and ugly (mayb that’s why is failing). Here´s the code:

  Web Server

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

 * 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
 modified 15 Jul 2014
 by Soohwan Kim 


#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include "Adafruit_HTU21DF.h"

Adafruit_HTU21DF htu = Adafruit_HTU21DF();
float Tc,Tf,Hm,HI = 0;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
#if defined(WIZ550io_WITH_MACADDRESS) // Use assigned MAC address of WIZ550io
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};

//#define __USE_DHCP__

IPAddress ip(10, 0, 0, 5);
IPAddress gateway(10, 0, 0, 2);
IPAddress subnet(255, 255, 255, 0);
// fill in your Domain Name Server address here:
IPAddress myDns(8, 8, 8, 8); // google puble dns

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

if (!htu.begin()) {
 Serial.println("Couldn't find sensor!");
while (1);   }

  // initialize the ethernet device
#if defined __USE_DHCP__
#if defined(WIZ550io_WITH_MACADDRESS) // Use assigned MAC address of WIZ550io
#if defined(WIZ550io_WITH_MACADDRESS) // Use assigned MAC address of WIZ550io
  Ethernet.begin(ip, myDns, gateway, subnet);
  Ethernet.begin(mac, ip, myDns, gateway, subnet);

  // start the Ethernet connection and the server:
  Serial.print("server is at ");

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 =;
        // 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("<!DOCTYPE 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(" is ");
            Tc = htu.readTemperature();
            Tf = (Tc*9/5)+32; //convertir la temperatura a F
            Hm = htu.readHumidity();
            HI = -42.379 + 2.04901523*Tf  
               + 10.14333127*Hm - 0.22475541*Tf*Hm 
               - 0.00683783*Tf*Tf - 0.05481717*Hm*Hm 
               + 0.00122874*Tf*Tf*Hm + 0.00085282*Tf*Hm*Hm 
               - 0.00000199*Tf*Tf*Hm*Hm; // Calcular el HI en F
            HI = (HI-32)*5/9;            //Convertir el HI a C
            client.print("Temperatura: ");
            client.print("C / Heat Index: ");
            client.print("C / Humedad: ");
            client.print("Uptime: ");
            client.println(" seconds.");
        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
    // close the connection:
    Serial.println("client disconnected");

I just remembered something I read a while back, and after some searching was able to find it here:

As per the warning note, you should never leave an unused SD card on the slot. It will cause odd behavior from the ethernet shield. I removed the card, and it have been working flawlessly for over half an ahour now...