[英]Arduino-DHT11 library for reading every 30 second
does any one here experienced with various dht11 library for arduino?, I want to read the temperature value every 30 second, I am using the standard library but sometimes throw me NaN. 这里有没有人对arduino的各种dht11库有经验?我想每30秒读取一次温度值,我正在使用标准库,但有时会丢掉NaN。 In avarege I got 2 NaN values out of 10 readings (20%). 在平均情况下,我从10个读数(20%)中得到2个NaN值。
I got many errors about many dht11 libraries, but one day finally I found a good library and good example code. 关于许多dht11库,我遇到了很多错误,但是有一天终于找到了一个好的库和好的示例代码。
Firstly you have to download the library from this link and add this to arduino's library folder. 首先,您必须从此链接下载库,并将其添加到arduino的库文件夹中。
Secondly, you should do this pin connections 其次,您应该进行此引脚连接
Lastly, here it is example code. 最后,这是示例代码。 It should work. 它应该工作。
#include <dht11.h>
int DHT11_pin=2;
dht11 DHT11_sensor;
void setup()
{
Serial.begin(9600);
Serial.println("GOOD LUCK");
Serial.println("*********************");
}
void loop()
{
int chk = DHT11_sensor.read(DHT11_pin);
Serial.print("Humidity (%): ");
Serial.println((float)DHT11_sensor.humidity, 2);
Serial.print("Temp (Celcius): ");
Serial.println((float)DHT11_sensor.temperature);
Serial.print("Temp (Kelvin): ");
Serial.println(DHT11_sensor.kelvin(), 2);
Serial.print("Temp (Fahrenheit): ");
Serial.println(DHT11_sensor.fahrenheit(), 2);
Serial.print("Dew Point: ");
Serial.println(DHT11_sensor.dewPoint(), 2);
Serial.println("------------------");
delay(500);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.