Design of temperature and humidity LabView host computer monitoring system based on single chip DHT22

Publisher:技术旅人Latest update time:2023-09-12 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. System plan
This design uses AT89C52 microcontroller as the main controller. The LCD 1602 displays the temperature and humidity. LabView communicates with the host computer. The host computer displays the temperature. At the same time, the host computer can set the upper and lower temperature limits. When the measured temperature is lower than or higher than the upper limit, the temperature Alarm, the upper computer can control the starting and shutting down of the heating equipment of the lower computer, and realize the exchange of data between the upper computer and the lower computer.

wKgZomS1QYSAQlAOAAAZw44TFRo191.png


2. The hardware design
schematic diagram is as follows:

wKgaomS1QYyAOCvmAAEotUKS6-Y003.png

3. Microcontroller software design
1. The microcontroller code is mainly serial port initialization and serial port interrupt service routine. The first is the serial port initialization:
void uart_init()
{
TMOD |= 0x20;//Timer 1, working mode 2 8-bit automatic reloading
TH1 = 0xfd;
TL1 = 0xfd; //Set the bit rate 9600
SM0 = 0;
SM1 = 1 ;//Serial port working mode 1, 8-bit UART baud rate variable
TR1 = 1; //Start timer 1
REN = 1;
EA = 1; //Open total interrupt
ES = 1; //Open serial port interrupt
}
2 , paste the two functions of the 51 microcontroller responsible for serial port transmission:
void SendByte(unsigned char dat) //Send one byte of data, the formal parameter dat is the data to be sent.
{
SBUF = dat; //Write data to the serial port buffer
while(!TI); //Wait for the sending to complete
TI = 0;
}
void SendArray(unsigned char *Array, unsigned char Size)//Send an array through the serial port, Construct a for loop, change the index and send
{
unsigned char i;

for(i = 0; i < Size; i++)
{
SendByte(Array[i]);
}
}
Process the received data in the serial port interrupt:
void uart(void ) interrupt 4 //Serial port interrupt
{
unsigned char Res;
static unsigned char Rec_state = 0;

if(RI) //Data received
{
RI = 0; // Clear interrupt request
Res = SBUF;
if(Res == 0xFF) // Frame header received
{
Rec_state = 1;
}
else if(Rec_state == 1 && Res == 0xEE)//Received end of frame
{
Rec_state = 0;
}
else if(Rec_state == 1)
{
switch(Res)//Received data, relay control
{
case 0x02: RY2 = 0; break;
case 0x03 : RY2 = 1; break;
default : RY2 =1; break;
}
}
}
else //After sending one byte of data
{
//TI = 0;
}
}
3. Paste the DHT22 temperature and humidity reading function
unsigned char Read_Sensor(void )
{
unsigned char i;
//Host pulls low (Min=800US Max=20Ms)
DHT_PIN = 0;
Delay_N1ms(18); //Delay 18Ms

//Release bus delay (Min=30us Max=50us)
DHT_PIN = 1;
Delay_N10us(2); //Delay 30us
//The host is set to input the sensor response signal
DHT_PIN = 1;

Sensor_AnswerFlag = 0; // Sensor response flag

//Judge whether the slave has a low-level response signal. If it does not respond, it will jump out. If it responds, it will run downward
if(DHT_PIN ==0)
{
Sensor_AnswerFlag = 1; //Receive the start signal
Sys_CNT = 0;
//Judge the slave. Whether the machine sends out a low-level response signal of 80us and ends
while((!DHT_PIN))
{
if(++Sys_CNT>300) //Prevent entering an infinite loop
{
Sensor_ErrorFlag = 1;
return 0;
}
}
Sys_CNT = 0;
// Determine whether the slave sends a high level of 80us. If it does, it will enter the data receiving state
while((DHT_PIN))
{
if(++Sys_CNT>300) //Prevent entering an infinite loop
{
Sensor_ErrorFlag = 1;
return 0;
}
}
/ / The data receiving sensor sends a total of 40 bits of data
// That is, the high bits of 5 bytes are sent first and the 5 bytes are the high bits of humidity, the low bits of humidity, the high bits of temperature, the low bits of temperature, checksum
// The checksum is: high bits of humidity + low bits of humidity + temperature High bit + temperature low bit
for(i=0;i<5;i++)
{
Sensor_Data[i] = Read_SensorData();
}
}
else
{
Sensor_AnswerFlag = 0; // Sensor response not received
}
return 1;
}
4. Host computer The software design
host computer is developed with the help of LabView. The interface is relatively simple. First, the UI interface is designed on the front panel, and then the software development is completed through graphical programming on the back panel. Here is a screenshot of the front panel of the host computer:

wKgZomS1QZmAeTcgAAEOoYm8f2E953.png

The screenshot of the rear panel is as follows:

wKgaomS1QZ-AAqSRAACZ1h2Uzlg640.pngwKgZomS1QaaAS31aAABTztsfJm4680.png

Reference address:Design of temperature and humidity LabView host computer monitoring system based on single chip DHT22

Previous article:Comparative analysis of two methods of CAN bus and Ethernet embedded gateway circuit design
Next article:Practical methods of 51 series microcontroller timer

Recommended ReadingLatest update time:2024-11-23 02:44

Design of Motor Speed ​​Monitoring System Based on LabVIEW
    LabVIEW is a virtual instrument platform developed by National Instruments . It is a development tool that uses icon codes instead of text-based programming languages. It completes the program of the host computer by connecting icons representing different functional nodes. In this respect, it is completely diffe
[Microcontroller]
Design of Motor Speed ​​Monitoring System Based on LabVIEW
How to Connect an Analog Discovery™ USB Oscilloscope to LabVIEW
Step 1: Materials hardware Simulation discovery: link Software (see next step for link) WaveForms 2.6.2 or higher LabVIEW (versions 2013 and 2014 have been tested to work fine so far) LabView Run-Time Engine 2103 (This is an optional LabVIEW Editor alternative, see the next step.) Note: Installing LabVIEW requires
[Test Measurement]
How to Connect an Analog Discovery™ USB Oscilloscope to LabVIEW
Automating Multisim with LabVIEW
Overview This document describes the LabVIEW Multisim Connectivity Toolkit (ß version). Available from ni.com/labs, the toolkit is a wrapper around the Multisim Automation API. With this set of toolkit VIs for LabVIEW, you can create applications that acquire circuit simulation data. In this white paper, you wi
[Test Measurement]
Automating Multisim with LabVIEW
Design of low-cost LabVIEW experimental teaching system based on MCS51 single-chip microcomputer
    NI proposed the concept of virtual instruments in the 1970s. Virtual instruments are computer instrument systems designed by users on a computer-based platform, with virtual panels and software to implement test functions. They are the product of the combination of computers and test instruments. The most commonly
[Microcontroller]
Design of low-cost LabVIEW experimental teaching system based on MCS51 single-chip microcomputer
Design of Temperature Measurement System Based on LabVIEW
Temperature is a very important parameter in mechanical industrial production and scientific research experiments. Many systems work within a certain temperature range, and there are many occasions where temperature measurement and temperature control are needed. The current temperature measurement control system of
[Test Measurement]
Design of Temperature Measurement System Based on LabVIEW
LabVIEW Design Pattern Series - Functional Global Variables
Standardization: 1. Standardization of icons                2. Operation: Write & Read                3. xx is the variable name, w is write, the value in brackets is the default value, r is read                 4. Error input and output terminals Standards: 1. After the write operation, the read operation al
[Test Measurement]
Reducing RF Power Amplifier Characterization Time with NI PXI and LabVIEW
Challenge: Reduce characterization time for increasingly complex wireless power amplifiers (PAs) without sacrificing measurement accuracy or increasing device cost. Solution: Using NI LabVIEW software and NI PXI modular instruments to develop a power amplifier characterization system allowed us to increase test throu
[Test Measurement]
Reducing RF Power Amplifier Characterization Time with NI PXI and LabVIEW
Creating a connector pane in LabVIEW
  Right-click the VI icon in the front panel window and select "Show Connector Pane" from the shortcut menu to switch to the connector pane state. Create and select the connector pane terminal mode, set the connector pane terminals, and assign the terminals in the connector pane to the front panel controls.   Select a
[Test Measurement]
Creating a connector pane in LabVIEW
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号