Web Server Problem

Dear, good afternoon.
I write because I have a problem with a web server made in arduino.
The issue is like this: I have to control the temperature of 4 tanks, 4 probes through Dallas. Depending on the type, the delta temperature changes, so I decided to build an LCD panel with buttons to make changes.
To the user has better control of the system, place a webserver and an HTML page that is updated through XML.
The issue is that unexpectedly from time to time, the web server does not receive more requests and to restart Arduino, This occurs when the page is open too long, try to access another computer or send data from the same system pag.
Sometimes it happens that the arduino is restarted only when data is sent from the web to the system. This does not always happen.
I leave a copy of the sketch
The system is an Arduino DUE, with an ETHERNET SHIELD.
You will notice that in the code of WebServer, there are lines to extract data from the WEB. This is so that the user can modify the DELTA temperature from the web, also from the panel.
On the other hand, the values ​​of the probes are stored in 4 different variables, this is because I need to show them with decimals, but when starting the pump need integers.

Any questions let me know

Greetings and thanks in advance.

Dcrux.ino (21.3 KB)

index.txt (22.6 KB)

If the Arduino freezes after running a while, that is normally caused by the w5100 running out of sockets for one reason or another.

Thanks for you quick response.

Can you help me with that?

Maybe. Here is my server code.

Note I use two functions to check the socket status and correct any frozen sockets in the first server example.

#include <utility/w5100.h>
#include <utility/socket.h>

byte socketStat[MAX_SOCK_NUM];

void ShowSockStatus()
  for (int i = 0; i < MAX_SOCK_NUM; i++) {
    uint8_t s = W5100.readSnSR(i);
    socketStat[i] = s;
    Serial.print(F(" "));
    Serial.print(F(" D:"));
    uint8_t dip[4];
    W5100.readSnDIPR(i, dip);
    for (int j=0; j<4; j++) {
      if (j<3) Serial.print(".");

void checkSockStatus()
  unsigned long thisTime = millis();

  for (int i = 0; i < MAX_SOCK_NUM; i++) {
    uint8_t s = W5100.readSnSR(i);

    if((s == 0x17) || (s == 0x1C)) {
        if(thisTime - connectTime[i] > 30000UL) {
          Serial.print(F("\r\nSocket frozen: "));
    else connectTime[i] = thisTime;

    socketStat[i] = W5100.readSnSR(i);

Hi again.
I made some proves, and I arrive a conclusion.
When I test the Web page only with Arduino everything works fine, but, when I connect the Rele shield to Arduino, and Activate any rele, the ethernet traffic is down.
The Arduino is connected to 5v. 1 A power supply and the relé shield to 5v 800 mA independent power supply.

Any idea?

Sounds like you have an EMF or surge problem. If you haven't already, try the relay will no load connected. Is it a Seeedstudio relay shield? It gets its power for the primary coils from the 5V bus. The ethernet shield and the relay shield may put a strain on the 5V bus. Is the relay shield on top of the ethernet shield?

Ok, I will try to activate the relé without load.
The Rele shield has a independent power supply 5v 800 mA to primary coils.
Only Digital pins are connected to Arduino.
One of those relé activates a bomb of 0.5 hp. 220v.

Thanks a lot.

When I drive a relay with a microprocessor, I like to use optocouplers (opto-isolators). It gives better electrical isolation between devices.

I just use a transistor, or on open drain shift register. The extra LED to transistor base of output device seems like overkill to me.

Video clip of 3 daisychained boards controlling 120V LED strings

this is my Shield

Looks like that has transistors driving the control coils. I still prefer optical isolation. Do you have a good ground between the shield and the Arduino?

edit: If that is a SainSmart unit, it supposedly has opto-isolated inputs.

edit2: It isn't the SainSmart unit. It does not have the opto-isolators.

Is the jumper installed?

It is marked sunfounder.

@CrossRoads: You are correct. That is a sunfounder board, and it does not have the opto-isolators, just transistors.

I can remove the JD jumper and connect the power supply to jd-vcc pin.
what do you think?

I can remove the JD jumper and connect the power supply to jd-vcc pin.
what do you think?

I actually thought that is what you were doing. I just wanted to make sure. That is why I asked about the jumper.

edit: Do you have a good ground connection from the module to the Arduino? That is a must.

That board has optoisolators; they're the big four-pin chips. The transistor is tiny to the left of it and above the two resistors.

There should be no jumper between VCC and JD-VCC for optoisolation.

Arduino VCC -> Board VCC
Arduino digital pins -> Board pins (IN1, IN2, IN3, IN4). digitalWrite(pin, LOW) will activate the relay. You're using the pins as "ground" to sink current. There should be no other "GND" connection between the Arduino and the relay board.

Board JD-VCC -> External power supply
Board GND -> External power supply.

@Chagrin: You are probably correct. I couldn't download the schematic for the Sunfounder board, but if it is wired like the SainSmart board (I could get the schematic for it), the connections you suggest are correct.

Excellent writeup on the topic: https://arduino-info.wikispaces.com/RelayIsolation.

I comment what I isolate the ground and I connect the Relay Shield through JD-Vcc Pin, but I notice what the ground is floating. So the system is more stable but keep restarting, but without lost connection.
I will do the discharge of ground connection to physical discharge to ground.
I'll do that and I notice you how is works.
best regards.

PD. the logical connection to Shields has been made through 5v from Arduino.

Here is the technical information on that board showing the opto-isolators and the driver transistors:
Sunfounder 4 channel relay board.