文件名称:DHT11forSTM32
介绍说明--下载内容来自于网络,使用问题请自行百度
本章我们将向大家介绍如何使用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
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.