




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、第三十五課 Arduino 濕度傳感器在本節(jié)中,我們將學(xué)習(xí)如何使用不同的傳感器連接我們的Arduino板。我們將討論以下傳感器:· 濕度傳感器(DHT22)· 溫度傳感器(LM35)· 水位檢測(cè)傳感器(簡(jiǎn)單水觸發(fā)器)· PIR傳感器· 超聲波傳感器· GPS濕度傳感器(DHT22)DHT-22(也稱(chēng)為AM2302)是一個(gè)數(shù)字輸出,相對(duì)濕度和溫度傳感器。它使用電容式濕度傳感器和熱敏電阻來(lái)測(cè)量周?chē)諝?,并在?shù)據(jù)引腳上發(fā)送數(shù)字信號(hào)。在本例中,你將學(xué)習(xí)如何將此傳感器與Arduino UNO一起使用。室溫和濕度將打印到串口監(jiān)視器上。DHT-22
2、傳感器連接很簡(jiǎn)單。左邊的第一個(gè)引腳為3-5V電源,第二個(gè)引腳連接到數(shù)據(jù)輸入引腳,最右邊的引腳接地。技術(shù)細(xì)節(jié)· 電源 - 3-5V· 最大電流 - 2.5mA· 濕度 - 0-100,精確度為2-5· 溫度 - 40至80°C,精確度為±0.5°C必需的組件你將需要以下組件:· 1 × Breadboard 面包板· 1 × Arduino Uno R3· 1 × DHT22· 1 × 10K歐姆電阻程序按照
3、電路圖連接面包板上的組件,如下圖所示。草圖在計(jì)算機(jī)上打開(kāi)Arduino IDE軟件。使用Arduino語(yǔ)言進(jìn)行編碼控制你的電路。通過(guò)單擊“New”打開(kāi)一個(gè)新的草圖文件。Arduino代碼/ Example testing sketch for various DHT humidity/temperature sensors#include "DHT.h"#define DHTPIN 2 / what digital pin we're connected to/ Uncomment whatever type you're using!/#define DH
4、TTYPE 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 connect pin 1/ to 3.3V instead of 5V!/ Connect pin 2 of the sensor to whatever you
5、r 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 sensor/ Initialize DHT sensor./ Note that older versions of this library took an optional third parameter to/ tweak the timings for faster processors. This parameter is
6、 no longer needed/ as the current DHT reading algorithm adjusts itself to work on faster procs.DHT dht(DHTPIN, DHTTYPE);void setup() Serial.begin(9600); Serial.println("DHTxx test!"); dht.begin();void loop() delay(2000); / Wait a few seconds between measurements float h = dht.readHumidity(
7、); / Reading temperature or humidity takes about 250 milliseconds! float t = dht.readTemperature(); / Read temperature as Celsius (the default) float f = dht.readTemperature(true); / Read temperature as Fahrenheit (isFahrenheit = true) / Check if any reads failed and exit early (to try again). if (i
8、snan(h) | isnan(t) | isnan(f) Serial.println("Failed to read from DHT sensor!"); return; / Compute heat index in Fahrenheit (the default) float hif = puteHeatIndex(f, h); / Compute heat index in Celsius (isFahreheit = false) float hic = puteHeatIndex(t, h, false); Serial.print ("Humid
9、ity: "); Serial.print (h); Serial.print (" %t"); Serial.print ("Temperature: "); Serial.print (t); Serial.print (" *C "); Serial.print (f); Serial.print (" *Ft"); Serial.print ("Heat index: "); Serial.print (hic); Serial.print (" *C "); Serial.print (hif); Serial.println (" *F");代碼說(shuō)明DHT22傳感器具有四個(gè)端子連接到電路板的端子(Vcc,DATA,NC,GND),如下:· DATA引腳連接到Arduino的2號(hào)引腳號(hào)· Vcc引腳
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 勞動(dòng)合同標(biāo)準(zhǔn)格式范文
- 簡(jiǎn)易自愿離婚合同模板
- 菜鳥(niǎo)驛站快遞柜租賃合同
- 餐飲企業(yè)戰(zhàn)略合作區(qū)域代理合同樣本
- 老舊農(nóng)村房屋轉(zhuǎn)讓合同范本
- 自行車(chē)安全培訓(xùn)課件
- 木工機(jī)械的現(xiàn)代控制技術(shù)考核試卷
- 木質(zhì)游藝器材制作工藝考核試卷
- 批發(fā)行業(yè)的品牌形象塑造考核試卷
- 合成材料在汽車(chē)制造領(lǐng)域的應(yīng)用研究考核試卷
- 2024年鎮(zhèn)江市高等專(zhuān)科學(xué)校單招職業(yè)適應(yīng)性測(cè)試題庫(kù)完美版
- 2024年云上貴州大數(shù)據(jù)(集團(tuán))有限公司招聘筆試沖刺題(帶答案解析)
- 珠海市高級(jí)技工學(xué)校校企合作管理辦法修訂
- GB 31825-2024制漿造紙單位產(chǎn)品能源消耗限額
- 消防設(shè)施操作員報(bào)名工作證明(操作員)
- 供應(yīng)商開(kāi)發(fā)流程及質(zhì)量要求
- 2024年技術(shù)監(jiān)督質(zhì)檢職業(yè)技能考試-電力技術(shù)監(jiān)督上崗員(中國(guó)華能)筆試歷年真題薈萃含答案
- 反假幣測(cè)試附有答案
- 怎樣調(diào)動(dòng)員工積極性
- 2024年內(nèi)科護(hù)理學(xué)(第七版)期末考試復(fù)習(xí)題庫(kù)(含答案)
- 急診科培訓(xùn)急診科與其他科室的協(xié)作與溝通
評(píng)論
0/150
提交評(píng)論