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 Answer
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.
-
*note this is slightly outside my expertise, and I don't have an arduino to test with..– AaronCommented May 5, 2017 at 20:41