答案 0 :(得分:1)
您是否尝试过简单地创建多个dht对象并单独轮询它们?
#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)
}
改编自this。