Sharing data via web server

Hey, I’m new to arduino world and I don’t know much yet about how things work so I wanted to combine example code with readings from DHT11 temp and humidity sensors with simple web server (I have ethernet shield on my arduino uno r3).

Exaple code for dht11 works like a charm, same for simple web server but together they just won’t load. After i put the server addres in my browser it tries to load for a minute or two and then throws timeout error, after i remove reading functions from web server it works without problems.

/*
  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 <Ethernet.h>
#include <idDHT11.h>

int idDHT11pin = 2; //Digital pin for comunications
int idDHT11intNumber = 0; //interrupt number (must be the one that use the previus defined pin (see table above)


//declaration
void dht11_wrapper(); // must be declared before the lib initialization

// Lib instantiate
idDHT11 DHT11(idDHT11pin,idDHT11intNumber,dht11_wrapper);


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);

dht11 = DHT11;

#define nSensores 3
int puertos[nSensores];
float fHumedades[nSensores];
float fTemperaturas[nSensores];

int iNVisitas=0;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xEE, 0xEE };
byte ip[] = { 192,168,1, 177 };

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
Server server(666);
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 dht11_wrapper() {
  DHT11.isrCallback();
}

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  
  DHT11.acquire();
  while (DHT11.acquiring());
  int result = DHT11.getStatus();
  switch (result)
  {
  case IDDHTLIB_OK: 
    break;
  case IDDHTLIB_ERROR_CHECKSUM: 
    Serial.println("Error\n\r\tChecksum error"); 
    break;
  case IDDHTLIB_ERROR_TIMEOUT: 
    Serial.println("Error\n\r\tTime out error"); 
    break;
  case IDDHTLIB_ERROR_ACQUIRING: 
    Serial.println("Error\n\r\tAcquiring"); 
    break;
  case IDDHTLIB_ERROR_DELTA: 
    Serial.println("Error\n\r\tDelta time to small"); 
    break;
  case IDDHTLIB_ERROR_NOTSTARTED: 
    Serial.println("Error\n\r\tNot started"); 
    break;
  default: 
    Serial.println("Unknown error"); 
    break;
  }
 
  
  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(DHT11.getHumidity(),2);
          client.println(DHT11.getCelsius(),2);
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 disonnected");
  }
}

when i remove these lines

DHT11.acquire();
while (DHT11.acquiring());
int result = DHT11.getStatus();
switch (result){(…)}

page loads without problems but with them, just wont do anything

The sticky at the top of this section tells you how to post code correctly.

"They just won't load" doesn't mean a thing. Some real error messages or some real facts are often more useful.

By this I mean page wont load after i try to type arduino network addres in my browser, It just shows timeout after some time.

could anyone just run my code and see if it is working or not?

It looks to me, then, like getting the temperature is not happening. You’ll need add Serial.print() statements before and after each line, to see what is(n’t) happening.

slevinx:
when i remove these lines

DHT11.acquire();
while (DHT11.acquiring());
int result = DHT11.getStatus();
switch (result){(...)}

You seem to have narrowed the problem down to four lines, which is a good start. I suggest you continue your investigation and see which one of those statements causes the problem.