Go Down

Topic: Multiple DHT11 Sensors (Read 4427 times) previous topic - next topic

Hi Forum,

I am new to Arduino. 

I am interested in connecting 8 x DHT11 to Ardunio Mega.  Is this possible?

I am a software engineer, not an electronics person.  Do I need anything special - such as pull up resistors for each DHT11 I connect?

The DHT11 - I am planning to connect are http://www.australianrobotics.com.au/products/electronic-brick-digital-temperature-humidity-sensor-dht11

How do I address each DHT11 or am I just reading from Digital IO 0-7 on the board?

Thanks

Stuart

Korman

Each sensor has it's own digital pin and you should connect the sensor signal pin directly to the Arduino-pin. Communication then is done by first setting the pin as output pin to tell the sensor to go ahead and send data, then the pin is reconfigured as input and the sensor pulls down the signal line for bits. As the sensors themselves seem to have a maximum date refresh rate of 2 seconds, you shouldn't be in any hurry to poll all sensors sequentially.

Korman

robtillaart

You cannot set the DHT11's on a single bus, the protocol looks a bit like the one-wire but it ommitted an addressing scheme. So you need one pin per DHT, (you can share the GND and 5V).  As the Arduino has more than 8 pins this is doable, or use a multiplexer as KE7GKP suggested.

Check - http://arduino.cc/playground/Main/DHT11Lib -

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

sheehado

I am still having trouble translating the code from http://arduino-info.wikispaces.com/Cosm-Arduino to use the numbering scheme you show.

Can you provide any guidance as to where I have gone astray? (Code below)

Thanks!

robtillaart


A quick hack
Code: [Select]

void loop()   /*** LOOP: RUNS CONSTANTLY ***/
{
  /*---( Read the DHT11 Temperature / Humidity Sensor, and check for errors. )---*/

  Serial.println(); 
  Serial.print("Sensor 2: ");

  int chk2 = DHT11_2.read(DHT11PIN2); 
  switch (chk2)
  {
  case  0:
    Serial.println("OK");
    break;
  case -1:
    Serial.println("Checksum error");
    delay(
    break;
  case -2:
    Serial.println("Time out error");
    break;
  default:
    Serial.println("Unknown error");
    break;
  }
 
  Serial.print("Sensor 5: ");
  int chk5 = DHT11_5.read(DHT11PIN5); 
  switch (chk5)
  {
  case  0:
    Serial.println("OK");
    break;
  case -1:
    Serial.println("Checksum error");
    break;
  case -2:
    Serial.println("Time out error");
    break;
  default:
    Serial.println("Unknown error");
    break;
  }
 
  if (chk2 == 0)
  {
    OfficeTempC     =  (float)DHT11_2.temperature,2;     // Value from Sensor
    OfficeTempF     =  Fahrenheit(DHT11_2.temperature);  // Computed value from C
    OfficeHumidity  =  (float)DHT11_2.humidity;          // Value from Sensor
    OfficeDewPoint  =  dewPointFast(DHT11_2.temperature, DHT11_2.humidity); // Computed Value

    Serial.print("Office Temperature (oC): ");
    Serial.println(OfficeTempC);
    Serial.print("Office Temperature (oF): ");
    Serial.println(OfficeTempF);
    Serial.print("Office Humidity (%): ");
    Serial.println(OfficeHumidity);
    Serial.print("Office Dew PointFast (oC): ");
    Serial.println(OfficeDewPoint);
   
    datastreams2[0].setFloat(OfficeTempC);    // Set sensor values into datastreams 1
    datastreams2[1].setFloat(OfficeTempF);    // Set sensor values into datastreams 2
    datastreams2[2].setFloat(OfficeHumidity);  // Set sensor values into datastreams 3
    datastreams2[3].setFloat(OfficeDewPoint);  // Set sensor values into datastreams 4
     
    cosmReturn = cosmclient.put(feed2,cosmKey);   // Send feed to cosm
     
    Serial.print("COSM client returned : "); // Get return result code, similar to HTTP code
    Serial.println(cosmReturn);
  }

  if (chk5 == 0)
  {
    MBdrmTempC     =  (float)DHT11_5.temperature,2;
    MBdrmTempF     =  Fahrenheit(DHT11_5.temperature);
    MBdrmHumidity  =  (float)DHT11_5.humidity;
    MBdrmDewPoint  =  dewPointFast(DHT11_5.temperature, DHT11_5.humidity); 

    Serial.print("Master Bedroom Temperature (oC): ");
    Serial.println(MBdrmTempC);
    Serial.print("Master Bedroom Temperature (oF): ");
    Serial.println(MBdrmTempF);
    Serial.print("Master Bedroom Humidity (%): ");
    Serial.println(MBdrmHumidity);
    Serial.print("Master Bedroom Dew PointFast (oC): ");
    Serial.println(MBdrmDewPoint);

    datastreams5[0].setFloat(MBdrmTempC);
    datastreams5[1].setFloat(MBdrmTempF);
    datastreams5[2].setFloat(MBdrmHumidity);
    datastreams5[3].setFloat(MBdrmDewPoint);
   
    cosmReturn = cosmclient.put(feed5,cosmKey);   // Send feed to cosm

    Serial.print("COSM client returned : "); // Get return result code, similar to HTTP code
    Serial.println(cosmReturn);
  }

  delay(2500); // Put a delay before the next updates to Cosm (2.5 Seconds)
}//--(end main loop )---



if you look at the code above it is "screaming" for some functions that handle the individual steps per sensor
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

sheehado

That was a great step forward and much cleaner! Thank you!

I was able to integrate it and make the multiple sensors read separately but it won't execute the part to post to COSM. The data never hits the COSM site (tried the debug page there) nor does the SerialPrint show up in the Serial Monitor.

I attached the full file this time as it is too many lines for this forum when I tried to edit it down last time.

Any thoughts as to where I have gone astray on the COSM client stuff? Or am I really off base?

Thanks!!

robtillaart

Do a step back an make a sketch that posts just one value every 60 seconds on cosm. If that works scale it up.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up