Pages: [1]   Go Down
Author Topic: ethernet pings but webclient is not responding  (Read 289 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm developing a software with Delphi that get's a web page from one of my arduinos.

This one, is geting values from 3 sensors (DHT, SR04 and TSAL 251) and then it will show results with webserver as solicited.

The problem I'm experience is that after several correct readings from arduino it stops responding to the webclient but it still respond to a normal Ping in Dos window... (I used as web client my Delphi App or Any Browser with same result).

I imagine that it could be my arduino software that hangs but it after the "solution" I have found I don't think so....

I have made a batch file that ping's once my arduino every 10/12 seconds and: "problem solved!". From this point I never get errors geting my pages in my app or web with any browser. I can even ping from any computer in my network to "solve" the problem.

It seems that we need to keep arduino UP every 10/12 seconds or it goes DOWN... is it possíble?

I need to find a solution because it is not a good option to ping every 10/12 seconds all my arduinos  smiley

Thanks

José Mendinhos
Logged

Scotland
Online Online
Edison Member
*
Karma: 24
Posts: 1242
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah - its that fault in line 254 again, just replace the $ with a ' . . . .  Oh wait 'THERE IS NO CODE' !!!!
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah - its that fault in line 254 again, just replace the $ with a ' . . . .  Oh wait 'THERE IS NO CODE' !!!!

OPPSSS. You're correct.

Here is the code.

 José Mendinhos

* Web_server (8.85 KB - downloaded 7 times.)
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 140
Posts: 5869
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is this the last thing displayed on the serial monitor when it stops responding?
Quote
Pedido de HTML / Consulta

Networking would have been a better place to post this thread.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes. That's the last signal I get...
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 140
Posts: 5869
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, try these additions to your code. Also you might want to use the F() function to reduce your SRAM requirement. I added the F() function to the first few serial and client prints as examples, but I recommend using that on all your static strings.
Code:
void listenForEthernetClients()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client)
  {
    Serial.println(F("Pedido de HTML / Consulta"));   
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected())
    {     
      if (client.available())
      {
        char c = client.read();
        // 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) {
            // Envio da resposta           

// Add this. If you don't see this, then you are not getting a blank line from the client
              Serial.println(F("Sending response"));

              client.println(F("HTTP/1.1 200 OK"));
              client.println(F("Content-Type: text/html"));
              client.println();
              // meta tag -> Faz refresh ao browser de 20 em 20 segundos
              // client.println(F("<meta http-equiv=\"refresh\" content=\"120\">"));
              // print the current readings, in HTML format:
             
              client.print("<table align=center width=100%><tr><td>Identificacao do sistema </td><td>Brimarel-001</td><td>");
              client.print( "  Ciclo : </td><td>" );
              client.print( String(ciclo) );
              client.print("</td></tr></table>");
              client.print("<table border=1 align=center width=100%><tr><td>Temperatura(TE)</td><td>Humidade(HU)");
              client.print("</td><td>Luminosidade(LU)");
              client.print("</td><td>Nivel do Tanque(NT)</td></tr><tr><td><div id='TE'>");                   
              client.print( String(Temperatura));
              client.print("</div></td><td><div id='HU'>");
              client.print( String(Humidade) );
              client.print("</div></td><td><div id='LU'>");
              client.print(String(Luminosidad));
              client.print("</div></td><td><div id='NT'>");
              client.print(String(NivelTanque));
              client.print("</div>");                                 
              // Informação de controlo             
              /*
              client.print(" Distancia : ");
              client.print(String(distancia));
              client.print(" - Pin ");
              client.print(String(Pin_sai));
              client.print(" ligado a : ");
              client.print(String(Pin_out));
              client.print(" Stibs");
              */             
              // Informação de Controlo             
              client.print("</td></tr></table>");                   
         // Fim da resposta
          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(20);
    // close the connection:
    client.stop();

// Add this. If you don't see this, then you are not finishing the response send to the client
    Serial.println(F("disconnected"));
  }
}
Then run the sketch again and post the last message on the serial monitor when the server quits responding.
Logged

Pages: [1]   Go Up
Jump to: