センサー | Arduino |
1 | 5V |
2 | A4 (データ) |
3 | GND |
4 | A5 (クリック) |
上記のページにあったソースをそのまま実行してみる。それらしい値が出てくる。しかし、湿度の値は高すぎるようである。
ここで 2014-11-29 (土) 18:33:04
(時間かかりすぎ>自分)
上記にライブラリ(github)のページを追加し、これを入れて実行してみた。それらしい値は、はやり湿度が高すぎるようである。
ここで 2014-11-29 (土) 18:54:44
動作確認-2- †
- 配線
AM2302 | Arduino | | AM2321 | Arduino |
| | | | |
1 | 5V | | 1 | 5V |
2 | 2 (データ) | | 2 | 4 (データ, 10kΩでプルアップ) |
3 | 配線しない | | 3 | GND |
4 | GND | | 4 | GND |
- 2つのセンサー共に DHT ライブラリで動かした。
#include <DHT.h>
#define DHTPIN2 2 // センサー1つめ(AM2302)は Arduino 2番ピンへ
#define DHTPIN4 4 // センサー2つめ(AM2321)は Arduino 4番ピンへ
#define DHTTYPE DHT22 // DHT 22 (AM2301, AM2321)
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 3 of the sensor to GROUND (AM2321)
// Connect pin 4 (on the right) of the sensor to GROUND
// ※ AM2321 の 2番ピンに 10KΩ のプルアップ抵抗を。
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht2(DHTPIN2, DHTTYPE);
DHT dht4(DHTPIN4, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println("Using 2 DHTxx sensors!");
Serial.println(" --2: 2302-- --4: 2321--");
Serial.println(" Temp, Humid, Temp, Humid");
dht2.begin();
dht4.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
Serial.print( dht2.readTemperature() );
Serial.print(", ");
Serial.print( dht2.readHumidity() );
Serial.print(", ");
Serial.print( dht4.readTemperature() );
Serial.print(", ");
Serial.println( dht4.readHumidity() );
}
- 測定例
違いすぎる…。
2014-12-06 (土) 16:45:06
相変わらず時間かかりすぎ。
2014-12-06 (土) 18:16:06
写真・グラフ追加