简体   繁体   English

Arduino-DHT11库,每30秒读取一次

[英]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.

相关问题 无法安装Adafruit的DHT11 Python库 - Trouble installing Adafruit's DHT11 Python library 使用Android Things通过DHT11读取温度 - Reading temperature through DHT11 using Android Things 如何将传感器数据(例如来自DHT11传感器的温度数据)发送到Google Cloud IoT Core并将其存储 - How to send sensor data (like temperature data from DHT11 sensor) to Google Cloud IoT Core and store it Raspberry Pi和Arduino读取串行传感器数据 - Raspberry Pi & Arduino reading serial sensor data Adafruit_DHT 不适用于 python 3 Raspberry Pi 3 B - Adafruit_DHT not working for python 3 Raspberry Pi 3 B 在 RaspberryPi3 上使用 DHT22 传感器进行实时数据记录 - Real time data logging with a DHT22 sensor on a RaspberryPi3 “Arduino Remote”和“Arduino Wiring”有什么区别 - What is the difference between "Arduino Remote" and "Arduino Wiring" Arduino的价值在处理和Arduino串行监控器中有所不同 - Arduino Values arriving differently in Processing and Arduino Serial Monitor 在使用 NRF24L01+ 从 Arduino 发送的 Raspberry pi 3b+ 上读取 Python 中的结构时出错 - Error reading Struct in python on Raspberry pi 3b+ sent from Arduino using NRF24L01+ Arduino Makefile失败-目标``重置&#39;&#39;的配方失败 - Arduino Makefile fails - recipe for target 'reset' failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM