pinMode(dhPin, OUTPUT); } void loop( ) { start_test( ); // 读取湿度温度和检核位到 dat[ ]; 其中dat[4]是checkSum // 根据datasheet规定, dat[4] 要 == (dat[0]+dat[1]+dat[2]+dat[3]) %256 // 否则表示沟通有错误 !! Serial.print("Current humdity = "); Serial.print(dat[0...
unsigned char dht11HumidityRead(unsigned char *pHumidity, unsigned char *pTemperature) { unsigned char dataIndex; unsigned char dataVal[5]={0}; unsigned int dataTime; P1DIR |= 0X01;/*output mode*/ READ_PIN = 0; delayMS(40); READ_PIN = 1; delayUS(2); P1DIR &= 0Xfe;/*read mode*...
If you are trying to interface it with some other MCU, then the datasheet given below will come in handy. The output given out by the data pin will be in the order of 8bit humidity integer data + 8bit the Humidity decimal data +8 bit temperature integer data + 8bit fractional tempera...
2. Create a dht object that refers to the sensor’s data pin, in this case, it’s GPIO 22: #sensor = dht.DHT11(Pin(22)) sensor = dht.DHT22(Pin(22)) 3. To measure and read the sensor values, use: sensor.measure() sensor.temperature() sensor.humidity() Continue reading for mor...
Datasheet PDF Parts with Similar Specs Overview of the DHT11 TheDHT11is a commonly used temperature and humidity sensor that comes with a dedicated NTC to measure temperature and an8-bit microcontrollerto output the values of temperature and humidity as serial data. The component is a 4-pin ...
dht_sensor=adafruit_dht.DHT11(dht_pin) whileTrue: try: temperature=dht_sensor.temperature humidity=dht_sensor.humidity print("Temperature:", temperature,"°C") print("Humidity:", humidity,"%") exceptRuntimeErrorase: print("Error:", e.args[0]) 参考资料 •DHT11 datasheet, [link]( •...
注意现在 ggyy 代表 DHT11 传感器constintpin =2;// 请把 DHT11 的 data pin 连到 arduino Pin ...
DHT11温湿度传感器典型应⽤电路 DHT11温湿度传感器时序图 DHT11温湿度传感器连接图 将DHT11的正极与5V电源接⼝相连,负极与GND相连,中间的数据接⼝与2号引脚相连。 代码 #include <dht11.h> dht11 DHT11;#define DHT11PIN 3 void setup(){ Serial.begin(9600);Serial.println("DHT11...
Simply ignore pin 3, its not used. You will want to place a 10K resistor between VCC and the data pin, to act as a medium-strength pull up on the data line. The Arduino has built in pullups you can turn on but they're very weak, about 100K ...
); pinMode(dhPin, OUTPUT); } void loop( ) { start_test( ); // 读取湿度温度和检核位到 dat[ ]; 其中dat[4]是checkSum // 根据datasheet规定, dat[4] 要 == (dat[0]+dat[1]+dat[2]+dat[3]) %256 // 否则表示沟通有错误 !! Serial.print("Current humdity = "); Serial.print(...