溫溼度感測器
Last updated
Was this helpful?
Last updated
Was this helpful?
專案說明
使用「Raspberry Pi Pico W」連接「DHT 22溫溼度模組」, 每3秒讀取DHT22溫溼度感測器模組溫度和濕度數值。
· Raspberry Pi Pico W
· Raspberry Pi Pico W 擴充板
· DHT 22溫溼度模組
DHT 22溫溼度模組是數位訊號輸出, 可以接「D0 ~ D28」的Raspberry Pi Pico擴充板訊號端上。 本範例連接到「D7」
每3秒鐘讀取DHT溫溼度感測器的溫度和濕度一次,並顯示在序列埠監控視窗上。
#include <DHT_mini.h>
DHT dht22_p7(7, DHT22);
void setup()
{
dht22_p7.begin();
Serial.begin(9600);
}
void loop()
{
Serial.println((String("溫度 : ")+String(dht22_p7.readTemperature())+String(" ")+String("濕度 : ")+String(dht22_p7.readHumidity())));
delay(3000);
}