Upload
-
View
70
Download
0
Embed Size (px)
Citation preview
クラウド対応温度計その 1第 3 回 MOSA 自習室村上幸雄
MQTT APNs
Virtuabotix DHT11
Arduino ライフラリー をダウンロード
黒線は、グラウンド (GND) ピンからグラウンド (GND) ピンへ。赤線は、電源 (VDD) ピン から 5V ピンへ。青線は、データ (DTA) ピン から デジタル・ピン 2 (~2) へ。
ファイル > スケッチフック > libraries dht11_functions#include dht11 DHT11; void setup(){ DHT11.attach(2); Serial.begin(9600); Serial.println("DHT11 TEST PROGRAM "); Serial.print("LIBRARY VERSION: "); Serial.println(DHT11LIB_VERSION);} void loop(){ Serial.println("\n"); int chk = DHT11.read(); Serial.print("Read sensor: "); switch (chk) { case 0: Serial.println("OK"); break; case -1: Serial.println("Checksum error"); break; case -2: Serial.println("Time out error"); break; default: Serial.println("Unknown error"); break; } Serial.print("Humidity (%): "); Serial.println((float)DHT11.humidity, DEC);
Serial.print("Temperature (°C): "); Serial.println((float)DHT11.temperature, DEC); Serial.print("Temperature (°F): "); Serial.println(DHT11.fahrenheit(), DEC); Serial.print("Temperature (°K): "); Serial.println(DHT11.kelvin(), DEC); Serial.print("Dew Point (°C): "); Serial.println(DHT11.dewPoint(), DEC); Serial.print("Dew PointFast (°C): "); Serial.println(DHT11.dewPointFast(), DEC); delay(2000);}
シリアルモニタ