Arduino 濕度感測器

2022-11-17 04:42:02 字數 2420 閱讀 2308

在本節中,我們將學習如何使不同的感測器連線我們的 arduino 板。 我們將討論以下感測器 -

濕度感測器(dht22

溫度感測器(lm35

檢測感測器(簡單觸發

pir 感測器

超聲波感測器

gps濕度感測器 (dht22

dht-22(也稱為 am2302 是個數字輸出,相對濕度和溫度感測器。 它使電容式濕度感測器和熱敏電阻測量周圍空,並在資料引腳上傳送數碼訊號。

在本例中,您將了解如何將此感測器與 arduino uno起使。 室溫和濕度將列印到串監視器上。

dht-22

感測器連線很簡單。 左邊的第個引腳為 3-5v 電源,第個引腳連線到資料輸引腳,最右邊的引腳連線到地。

技術細節

電源 - 3-5v

最電流 - 2.5ma

濕度 - 0-100%,精確度為 2-5%

溫度 - 40 80°c,精度為 ±0.5°c

必需的元件

您將需要以下元件 -

1 × breadboard 包板

1 × arduino uno r3

1 × dht22

1 × 10k歐姆電阻程式

按照電路圖並掛接包板上的元件,如下圖所。

草圖在計算機上開啟 arduino ide軟體。 在 arduino 語編碼將控制你的電路。 通過單擊新

建開啟個新的草圖件。

arduino **

// example testing sketch for various dht humidity/temperature sens #include ""

#define dhtpin 2 // what digital pin we're connected to

// uncomment whatever type you're using!

//#define dhttype dht11 // dht 11

#define dhttype dht22 // dht 22 (am2302, am2321

//#define dhttype dht21 // dht 21 (am2301

// connect pin 1 (on the left of the sensor to +5v

// note: if using a board with 3.3v logic like an arduino due conne // to 3.

3v instead of 5v!

// connect pin 2 of the sensor to whatever your dhtpin is

// connect pin 4 (on the right of the sensor to ground

// connect a 10k resistor from pin 2 (data to pin 1 (power of the // initialize dht sensor.

// note that older versions of this library took an optional third // tweak the timings for faster processors. this parameter is no lo // as the current dht reading algorithm adjusts itself to work on f dht dht(dhtpin, dhttype;

void setup(

void loop(

// compute heat index in fahrenheit (the default

float hif = h;

// compute heat index in celsius (isfahreheit = false

float hic = h, false;

("humidity: ";

(h;(" %\t";

("temperature: ";

(t;(" *c ";

(f;(" *f\t";

("heat index: ";

(hic;

(" *c ";

(hif;

(" *f";

}**說明

dht22感測器具有四個端 (v cc, data , nc , gnd ,它們連線到電路板,如下 : data 引腳連線到 arduino 引腳號 2

vcc 引腳到 5伏的 arduino 板

gnd 引腳連線到 arduino 板的地

我們需要在 data 和 vcc 引腳之間連線 10k 歐姆電阻(上拉電阻

旦硬體連線完成,您需要新增 dht22庫到您的 arduino 庫件,如前所述。 結果

您將看到串監視器上的溫度和濕度顯,每 2秒更新次。

w3cschool ( 最的技術知識分享與學習平台此篇內容來於 站戶上傳並發布。

感測器知識

稱重感測器實際上是一種將質量訊號轉變為可測量的電訊號輸出的裝置。用感測器茵先要考慮感測器所處的實際工作環境,這點對正確選用稱重感測器至關重要,它關係到感測器能否正常工作以及它的安全和使用壽命,乃至整個衡器的可靠性和安全性。在稱重感測器主要技術指標的基本概念和評價方法上,新舊國標有質的差異 傳統概念上...

感測器簡介

科技名詞定義 中文名稱 感測器英文名稱 sensor measuring element transducer 定義1 能感受規定的被測量並按照一定的規律轉換成可用輸出訊號的器件或裝置。所屬學科 機械工程 一級學科 感測器 二級學科 感測器一般名詞 學科 定義2 接受物理或化學變數 輸入變數 形式的...

感測器複習

感測器原理與應用 習題訓練1 一填空1.通常感測器由 敏感元件 轉換元件 基本轉換電路 三部分組成,是能把外界 非電量 轉換成 電量 的器件和裝置。2.金屬絲在外力作用下發生機械形變時它的電阻值將發生變化,這種現象稱 應變 效應 半導體或固體受到作用力後電阻率要發生變化,這種現象稱 壓阻 效應。直線...