文件名称:DHT11forSTM32
- 所属分类:
- 单片机(51,AVR,MSP430等)
- 资源属性:
- [Text]
- 上传时间:
- 2016-06-03
- 文件大小:
- 1kb
- 下载次数:
- 1次
- 提 供 者:
- feij****
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
本章我们将向大家介绍如何使用STM32来读取DHT11数字温湿度传感器,从而得到环境温度和湿度等信息,并把从温湿度值显示在TFTLCD模块上。-// -
//
void calc_sth11(float*p_humidity ,float*p_temperature)
{
const float C1=-4.0 // for 12 Bit
const float C2= 0.0405 // for 12 Bit
const float C3=-0.0000028 // for 12 Bit
const float T1=0.01 // for 14 Bit @ 5V
const float T2=0.00008 // for 14 Bit @ 5V
float rh=*p_humidity // rh: Humidity [Ticks] 12 Bit
float t=*p_temperature // t: Temperature [Ticks] 14 Bit
float rh_lin // rh_lin: Humidity linear
float rh_true // rh_true: Temperature compensated humidity
float t_C // t_C : Temperature [¬ C
t_C=t*0.01-40 //calc. Temperature ticks to [¬ C
rh_lin=C3*rh*rh+ C2*rh+ C1 //calc. Humidity ticks to [ RH]
rh_true=(t_C-25)*(T1+T2*rh)+rh_lin //calc. Temperature compensated humidity [ RH]
if(rh_true>100)rh_true=100 //cut if the value is outside of
if(rh_true<0.1)rh_true=0.1 //the physical possible range
*p_temperature=t_C //return tem
//
void calc_sth11(float*p_humidity ,float*p_temperature)
{
const float C1=-4.0 // for 12 Bit
const float C2= 0.0405 // for 12 Bit
const float C3=-0.0000028 // for 12 Bit
const float T1=0.01 // for 14 Bit @ 5V
const float T2=0.00008 // for 14 Bit @ 5V
float rh=*p_humidity // rh: Humidity [Ticks] 12 Bit
float t=*p_temperature // t: Temperature [Ticks] 14 Bit
float rh_lin // rh_lin: Humidity linear
float rh_true // rh_true: Temperature compensated humidity
float t_C // t_C : Temperature [¬ C
t_C=t*0.01-40 //calc. Temperature ticks to [¬ C
rh_lin=C3*rh*rh+ C2*rh+ C1 //calc. Humidity ticks to [ RH]
rh_true=(t_C-25)*(T1+T2*rh)+rh_lin //calc. Temperature compensated humidity [ RH]
if(rh_true>100)rh_true=100 //cut if the value is outside of
if(rh_true<0.1)rh_true=0.1 //the physical possible range
*p_temperature=t_C //return tem
(系统自动生成,下载前可以参看下载内容)
下载文件列表
DHT11forSTM32.txt