1 | VDD Power supply(2.6 -5.5V) |
2 | SDA Serial data, bidirectional port |
3 | GND Ground |
4 | SCL Serial clock input port (single bus ground) |
1 | VDD Power supply(2.6 -5.5V) |
2 | SDA Serial data, bidirectional port, プルアップ抵抗必須 |
3 | GND Ground |
4 | GND Ground |
1 | VDD Power supply(3.3 -5.5V) |
2 | SDA Serial data, bidirectional port |
3 | NC 使わない |
4 | GND Ground |
センサー | Arduino |
1 | 5V |
2 | A4 (データ) |
3 | GND |
4 | A5 (クロック) |
#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() ); }