【正文】
if(value % 6 == 0) { flag_300ms = 1。 //lcd1602 初始化顯示 dst11()。 }else write_string(1,0, DHT11 Kz System )。 //溫度取消報(bào)警時(shí)回差 1% } else value1 = 0。amp。 break。 //按鍵蜂鳴器使能 26 } } key_can = 20。 else key_value = 0。 flag_key_set_en = byte_read(0x2400)。 uchar table_dht11[5]={1,2,3,4,5}。 //溫度報(bào)警參數(shù) uint s_high = 30,s_low = 10。 [11] 使用開(kāi)發(fā)板下載程序界面如下圖所示: 圖 STC 下載程序 18 6 結(jié)論與展望 本系統(tǒng) 經(jīng)過(guò)自己長(zhǎng)時(shí)間的探索和改進(jìn),基本達(dá)到 目標(biāo)要求 。而傳感器的電源端口 Pin1 和 Pin4 分別接單片機(jī)的 VDD 和 GND 端。 12345678RST9(RXD)10(TXD)11(INT0)12(INT1)13(T0)14(T1)15(WR)16(RD)17XTAL218XTAL119GND202122232425262728PSEN29ALE/PROG30EA/VPP313233343536373839VCC40U2U1Y112MC2 C3 VCCR1110KC1 10uFVCC1234J1VCCS1S2 S3 S5P24P25546231SW1sw 灰色12P5R13 2K12D5DVCCB1蜂鳴器Q58550VCC+R122KP25R4VCC1 2 3 4U1DTT11P24S4P10P11P12P13P14P15P16P17GND1VCC2VO3RS4RW5E6DB07DB18DB29DB310DB411DB512DB613DB714BG/VCC15BG/GND16LCD1LCD1602VCCVCCP10 P11 P12 P13 P14 P15 P16 P17RS RW ENENRSRWVOVOR3 2KP30P31P26P27Q18550VCCGNDR12KP26K1RelaySPDT12P112D1DR52KQ28550VCCGNDR22KP27K2RelaySPDT12P212D2DR62K 圖 主控模塊原理圖 傳感器模塊設(shè)計(jì) DHT11 傳感器簡(jiǎn)介 DHT11 是復(fù)合傳感器 ,可同時(shí)測(cè)定溫度和濕度,直接取代了單獨(dú)的溫度和濕度傳感器 。 單片機(jī)主芯片選擇 采用 STC89C52 單片機(jī)作為監(jiān)測(cè)溫度和輸出控制 的核心, 功能強(qiáng)大, 用其在 整個(gè)控制系統(tǒng)中,滿(mǎn)足了最初的設(shè)計(jì)需求, 功耗低,內(nèi)部?jī)?chǔ)存足夠存儲(chǔ)一些程序, 而且 STC單片機(jī)功能豐富,也適合在后期改進(jìn)或者增加功能時(shí)候使用, 市面上出售的單片機(jī) STC系列很多, 價(jià)格低廉, 4 塊錢(qián)一個(gè)嗎, 而且好多電子愛(ài)好者都使用其對(duì)應(yīng)的開(kāi)發(fā)板,使用這些開(kāi)發(fā)板讓我們最大限度的學(xué)習(xí)了其功能,讓初學(xué) 者很快上手,所以選擇了 STC系類(lèi)單片機(jī)。 課題研究的意義 類(lèi)似的 控制在許多方面都有 應(yīng)用。 關(guān)鍵詞 : 單片機(jī) STC89C5 DHT11 傳感器、 溫濕度 監(jiān)測(cè) 控制 Based on the design and implementation of digital temperature controllers and humidity controllers on STC microcontroller AS a person Che Wenliang The instructor Xingang wang Abstract In electric cabi electrical equipment are in need of a dry, cool environment, some electric power equipment itself there is a big resistance, the electromagic coil also after work for a long time to produce more heat and humid environment corrosion to electrical equipment, greatly reduce its service life, so they need a way to control devices in electric cabi temperature and humidity, environmental temperature and humidity inside ark power to keep the scope of the work in a suitable electrical equipment and power incase of temperature and humidity monitoring, through the great error in manual monitoring in electrical cabi temperature and humidity, randomness, unable to continuous monitoring nor safe. Through the 51 singlechip microputer to monitor temperature and humidity and control relay onoff, dehumidifier and radiator, achieve the goal of power rack cooling dehumidification. Using single chip microputer system for electrical cabi temperature and humidity monitoring and control, can be realtime monitoring control, the error is relatively small, and straightforward, by setting the also can adjust temperature and humidity monitoring and control. Reduces the power equipment maintenance costs, and safeguard the personal safety. Keywords: Microcontroller STC89C51。以 單片機(jī) 為溫濕度的 控制核心,用 DHT11 溫濕度傳感器檢測(cè)電力柜內(nèi)溫度和濕度,LCD1602 液晶 顯示溫濕度 。 開(kāi)關(guān)的通斷或者使用復(fù)位電路可以讓單片機(jī)重啟 。 Pin4( VDD),接地端,電源負(fù)極。 [6] Keil 是單片機(jī)學(xué)習(xí)者必備的編程軟件, 其使用的 c 語(yǔ)言,極大的降低了學(xué)習(xí)者的門(mén)檻, c 語(yǔ)言相比較于匯編語(yǔ)言,更容易讓初學(xué)者上手,短短幾個(gè)月便可學(xué)到許多基本語(yǔ)句,而 keil 軟件 編譯單片機(jī) 程序 必不可少 。 bit flag_300ms 。 //按鍵蜂鳴器使能 // void delay_1ms(uint q) // { // uint i,j。 } void write_eepom_key() { SectorErase(0x2400)。 //開(kāi)總中斷 TMOD = 0X01。 //按鍵按下的時(shí)候 else key_value = 0。 0x0f) { case 0x0e: key_can = 4。 //顯示溫度 } if((menu_1 == 1) amp。 (menu_2 == 2)) { write_(0x80+0x4b)。amp。 flag_key_b_en = 0。 if(key_can 10) 31 { key_with()。 flag_lj_3_en = 1。 zd_break_value = 0。 //打開(kāi)蜂鳴器 value ++。 //用做報(bào)警的 if(value 5) value = 0。 (menu_1 3)) amp。 //先讀出溫濕度的值 27 if(menu_1 == 0) //開(kāi)始界面顯示的內(nèi)容 { write_sfm2(2,10,table_dht11[0])。amp。 } } else { if((P2 amp。 write_eepom_shidu()。 byte_write(0x2202, s_low)。 //溫度報(bào)警變量 uchar flag_fuzi。 至此,感謝給我?guī)椭睦蠋熀屯瑢W(xué)們,謝謝你們的一路的鼓勵(lì)和支持! 附 錄 21 附錄 A 元器件清 單 名稱(chēng) 元件號(hào) 規(guī)格參數(shù) 數(shù)量 蜂鳴器 B1 BELL 1 電解電容 C1 10uF 1 瓷片電容 C2, C3 30PF 2 發(fā)光二極管 D1, D2, D5 3mm 3 排針 J1 Header 4 4P 排母座 LCD1 Header 16 16P 繼電器 K1, K2 SRD05VDC 2 液晶 LCD1 LCD1602 1 接線(xiàn)柱 P1, P2 Header 2 3 三極管 Q1, Q2,Q5 8550 3 電阻 R