0

ok, I have been building a tissue culture lab. It has three compartments, one is for new culture, second is for vegetating plants and third for full grown plants. I have two Arduino mega boards one is already setup to monitor the lights and temp and controls 4 relays on a 8 channel board. I have three Dht22 for the second mega board but I have no clue how to make them work the way I want to. I would like each to read and report one for each compartment - so I can control airflow based on humidity through ventilation. How can I make three dht22 work and read separately? Any help with code is appreciated.

1
  • Welcome to stackoverflow, is there something you have already tried? What isn't working? Commented May 5, 2017 at 21:44

1 Answer 1

1

Have you tried simply creating multiple dht objects and polling them separately?

#include "DHT.h"

#define DHTPINA 2     // what digital pin the first one's connected to
#define DHTPINB 3     // what digital pin the second one's connected to

#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321

DHT dhtA(DHTPINA, DHTTYPE);
DHT dhtB(DHTPINA, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("DHTxx test!");

  dhtA.begin();
  dhtB.begin();
}

void loop() {
  delay(2000);
  float tA = dhtA.readTemperature();
  float tB = dhtB.readTemperature();

  Serial.print("Temp A:")
  Serial.print(tA)
  Serial.print("Temp B:")
  Serial.print(tB)
}

adapted from this.

1
  • *note this is slightly outside my expertise, and I don't have an arduino to test with..
    – Aaron
    Commented May 5, 2017 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.