[Iot smart gateway-01] obtains temperature and humidity through AD collection

Source: Internet
Author: User
Tags drawtext

Whether it is a data center management system or a management system for rural greenhouses, the temperature and humidity acquisition module is essential. There are generally three kinds of common temperature and humidity modules in terms of communication interfaces. The first is the single-bus mode. I wrote two blog posts to introduce the content of "DHT11 temperature and humidity sensor communication: ), the second is the serial port mode RS232 or RS485, and I will write a blog post later), and the third is the AD mode.

These three methods have their own advantages and disadvantages. The first one is usually cheaper, but the temperature and humidity sensor must be very close to the Collection chip and must implement Code related to the single bus, development and debugging are relatively complex. The second method is relatively easy to use. In general, most of them communicate with PCs directly, but the price is also the highest. The third method is moderately priced, in addition, the transmission distance is much farther than that of a single bus.

The temperature and humidity sensors in AD mode are different from the other two. The first two kinds of General temperature and humidity have been well handled, and the temperature and humidity values can be directly obtained through protocol analysis. The AD method only collects the voltage value. The final temperature and humidity value can be obtained only by calculating the data according to certain formulas.

Today, we will introduce how to use the AD interface of wisteria 207 Iot smart gateway to collect the temperature and humidity values of the AMT1001 temperature and humidity sensor.

Wisteria 207 Iot smart gateway has a total of eight AD channels. The corresponding pins are PA4, F6, PA5, PB1, PA0, PC3, PC2, and PC0, respectively corresponding to the AnalogInput Class 0 ~ 7-channel AnalogChannel. ANALOG_0 ~ AnalogChannel. ANALOG_7), of course, these pins can be used not only as AD input channels, but also as IO input, IO output, and PWM output only PB1 and PB5 ).

It must be noted that the voltage range of the Active Directory can be set to 0 ~ 3.3V the total circuit of all collection channels should not exceed 20mA). Be sure not to go beyond this range to avoid permanent damage to the chip. For specific indicators, see the relevant data manual of STM32F207 ).

The following describes the AMT1001 temperature and humidity sensor ):

650) this. width = 650; "alt =" "src =" http://pic002.cnblogs.com/images/2012/11611/2012050700041237.jpg "/>

The sensor uses a four-wire mode and provides 5 V power supply, and provides some standard parameters for calculation. It is very simple for humidity collection, and the corresponding pins directly output 0 ~ 3 V voltage value, and then directly look up the table to easily calculate the humidity value. While the temperature acquisition is different, the output voltage range is about 0 ~ 0.8 V, the change is very small, and the temperature value cannot be obtained through the voltage value, directly look up the table to obtain the temperature value, but indirectly calculate the resistance value, and then look up the table to obtain the relevant temperature value.

In addition to the differences between temperature acquisition and Humidity Acquisition, a resistance is also required. The resistance value of the resistance is the same as that of the temperature-sensitive resistance of the sensor module at 25 degrees. The main purpose is to facilitate the calculation ). The external resistance and the temperature-sensitive resistance are actually connected together. AD collects the voltage value of 10 KB. The temperature-sensitive resistance value can be calculated as follows: if the voltage value of 10 KB is V, the voltage of the temperature-sensitive resistance is 5-V because the power supply voltage of the module is 5 V ), according to the proportional formula, we can know the current temperature-sensitive resistance value R = (5-V)/V * R0.

The circuit connection diagram of wisteria 207 module and ATM 1001 module is as follows: the resistance is 10 KB ):

650) this. width = 650; "alt =" "src =" http://pic002.cnblogs.com/images/2012/11611/2012050700042798.jpg "/>

The related code is as follows:

// Humidity

Static double ConvertHumidity (double value)

{

Double V = (value/4096) * 3.3;

Return DataTransition (V, AMT1001_Voltage, AMT1001_Humidityvalue );

}

// Temperature

Static double ConvertTemperature (double value)

{

Double V = (value/4096) * 3.3;

Double R = (5-V)/V * AMT1001_R;

Return DataTransition (R, AMT1001_Resistance, AMT1001_Temperaturevalue );

}

For ease of demonstration, in addition to serial output, the relevant temperature and humidity values are directly displayed on the LCD. The core code is as follows.

Screen. DrawRectangle (Color. Black, 0, 60, 70,200,200, 0, 0, Color. Black, 0, 0, Color. Black, 0, 0,255 );

Screen. DrawText ("temperature:" + T. ToString ("F2") + "℃? ", Font, Colors. Green, 60, 70 );

Screen. DrawText ("humidity:" + H. ToString ("F2") + "%", font, Colors. Blue, 60,120 );

Screen. Flush ();

Screen is a Bitmap object ).

The program runs as follows:

650) this. width = 650; "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1JPG4Z-2.jpg "/>

Source: http://www.sky-walker.com.cn/MFRelease/Sample/YF_AMT1001.rar

MF Introduction: http://blog.csdn.net/yefanqiu/article/details/5711770

MF data: http://www.sky-walker.com.cn/News.asp? Id = 25

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1JPH960-3.png "/>

This article is from the "ye fan Studio" blog, please be sure to keep this source http://yfsoft.blog.51cto.com/1635641/855235

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.