Problem to a web server with two Sensirion sensors

Hello everyone,

So i wanted to show some values of my tow Sensirion sensors (SHT75) to a web server.

I made a simple programme to try it and for only one sensor there is no problem( the web server work and i can see all the values of my sensor in the serial com).

However for two sensors my web server didn't work and i can only see the value of the first sensor...

It is displayed for the second sensor sometimes "Error: -3 - CRC mismatch!" and often "Error: -4 - Measurement timeout!" on the serial com.

Of course all my sensors are functional because without the web server everything work.

I need your help please !

My code is below(and i use the 3.01 Sensirion Library):

// Variables for the server :
#include <SPI.h>
#include <Ethernet.h>

// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 166, 70); // IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80
//----------------------------------------------------------------------------------------
#include <Sensirion.h>
#define LED 13

long mtime;

// Sensirion(dataPin, sclkPin, address, noholdmaster);
// SHT1x address = 0x00  SHT2x address = 0x40  SHT3x address = 0x44 or 0x45
Sensirion sht1 = Sensirion(9, 8);
Sensirion sht2 = Sensirion(11, 10);
//Variables for the first sensor
float temperature;
float humidity;
float dewpoint;
float humidity37oC;
int ret, mret=1234;
//Variables for the second sensor
float temperature2;
float humidity2;
float dewpoint2;
float humidity37oC2;
int ret2, msret=1234;

void setup() 
{
  pinMode(LED, OUTPUT);     // initialize digital pin LED as an output
  Serial.begin(115200);     //initialize Serial
  Ethernet.begin(mac, ip);  // initialize Ethernet device
  server.begin();           // start to listen for clients
}

void loop()
{

 
  digitalWrite(LED,(((millis()>>6)&0x5)==0));   // double flash led rapidly

  // all parameters are optionals if user don't need it
  logError (ret = sht1.measure(&temperature, &humidity, &dewpoint, 37, &humidity37oC));       // Measurement for the first sensor
  logError (ret2 = sht2.measure(&temperature2, &humidity2, &dewpoint2, 37, &humidity37oC2));  // Measurement for the second sensor 
  
//---------------------------------------------------------------------------
//part of the first sensor
  if (ret != mret) // only for debug purpose
  {
    Serial.print("(");
    Serial.print(millis()-mtime);
    mtime=millis();
    Serial.print("mS)  ");
    if(ret==0)
    {
      Serial.println();
      Serial.println();
    }
    
    Serial.print("[");
    Serial.print(ret);
    Serial.print("] ");   
  }

  if (ret == S_Meas_Rdy) // A new measurement is available
  {    
    Serial.println();
    Serial.print("Temperature = ");   
    Serial.print(temperature);
    Serial.print(" oC, Humidity = ");  
    Serial.print(humidity);
    Serial.print(" %, Dewpoint = ");  
    Serial.print(dewpoint);
    Serial.print(" oC, Humidity @37oC = ");
    Serial.print(humidity37oC);
    Serial.print(" % ");  
  }
//---------------------------------------------------------------------------
//part of the second sensor
  if (ret2 != msret) // only for debug purpose
  {
    Serial.print("(");
    Serial.print(millis()-mtime);
    mtime=millis();
    Serial.print("mS)  ");
    if(ret2==0)
    {
      Serial.println();
      Serial.println();
    }
    
    Serial.print("[");
    Serial.print(ret2);
    Serial.print("] ");   
  }

  if (ret2 == S_Meas_Rdy) // A new measurement is available
  {    
    Serial.println();
    Serial.print("Temperature2 = ");   
    Serial.print(temperature2);
    Serial.print(" oC, Humidity2 = ");  
    Serial.print(humidity2);
    Serial.print(" %, Dewpoint2 = ");  
    Serial.print(dewpoint2);
    Serial.print(" oC, Humidity @37oC2 = ");
    Serial.print(humidity37oC2);
    Serial.print(" % ");  
  }
//------------------------------------------------------------------------------
  msret = ret2; 
  mret = ret;
  //----------------------------------------------------------------------------------------
  // Server part:
     EthernetClient client = server.available();  // try to get client
    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                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");
                    client.println();
                    // send web page
                    client.println("<!DOCTYPE html>");
                    client.println("<html>");
                    client.println("<head>");
                    client.println("<title>Arduino Web Page</title>");
                    client.println("</head>");
                    client.println("<body>");
                    client.println("<h1>Hello from Arduino!</h1>");
                    client.println("<p>A web page from the Arduino server</p>");
                    client.println("</body>");
                    client.println("</html>");
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)
    // listen for incoming clients
//-------------------------------------------------------------------------------------------------
}

// The following code is only used with error checking enabled
void logError(int error) 
{
  if (error>=0) // No error
    return;
    
  Serial.println();
  Serial.print("Error: ");
  Serial.print(error);

  switch (error) 
  {
    case S_Err_Param:
      Serial.print(" - Parameter error in function call! ");
      break;
    case S_Err_NoACK:
      Serial.print(" - No response (ACK) from sensor! ");
      break;
    case S_Err_CRC:
      Serial.print(" - CRC mismatch! ");
      break;
    case S_Err_TO:
      Serial.print(" - Measurement timeout! ");
      break;
    default:
      Serial.print(" - Unknown error received! ");
      break;
  }
}

Okay !

I don't find why i can't with the 3.01 library but it work perfectly with the first version of the library.
If you know why it dosen't work with the 3.01. Dont be shy :smiley: !