1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ESP32でDHT11を使う

Last updated at Posted at 2019-03-14

DHT11(デジット社の説明書より)

相対湿度 20~90%(25℃時、精度±5%)
温度 0~50℃(精度±2℃)
データ線にプルアップ4.7kΩ
応答時間 湿度6~15秒、温度6~30秒
電源電圧 3.3~5VDC

準備(ライブラリ)

https://github.com/adafruit/Adafruit_Sensor
https://github.com/adafruit/DHT-sensor-library

最小プログラム


# include "DHT.h"

DHT dht(2,DHT11);  //2番ポート

void setup() {
  Serial.begin(115200);
  Serial.println("DHT11 trial");
  dht.begin();

}

void loop() {

  delay(3000);

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  Serial.print("Humidity : ");
  Serial.println(h);
  Serial.print("Temperature : ");
  Serial.println(t);
}

出力は小数点以下2桁だけど、出力は整数値だった
Humidity : 36.00
Temperature : 23.00
みたいに。

次:

アナログ入力を試す

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?