我的湿度显示是这样的,很奇怪,连I都有??
左边是DHT11的数据,右边是设置的报警温度,程序如下?
能不能教教我怎么把湿度的数据调正常呀?
DHT11部分的程序:
/*********************** DHT11测试模块***************************************/
void start()//开始信号
{
io=1;
delay1();
io=0;
delay(20);//>18ms
io=1;
delay1();//20-40us
delay1();
delay1();
delay1();
delay1();
}
uchar receive_byte()//接收一个字节
{
uchar i,temp,count;
for(i=0;i<8;i++)
{
temp=0;
delay1();delay1();delay1();delay1();
if(io==1)temp=1;
count=2;
while((io)&&count++);
if(count==1)break;
data_byte<<=1;
data_byte|=temp;
}
return data_byte;
}
void receive()//接收数据
{
uchar T_H,T_L,R_H,R_L,check,num_check;
uchar count;
start();//开始信号
io=1;
if(!io)//读取DHT11响应信号
{
while((io)&&count++);
R_H=receive_byte();
R_L=receive_byte();
T_H=receive_byte();
T_L=receive_byte();
check=receive_byte();
io=0;//拉低延时50us
delay1();delay1();delay1();delay1();delay1();
io=1;
num_check=R_H+R_L+T_H+T_L;
if(num_check=check)
{
RH=R_H;
RL=R_L;
TH=T_H;
TL=T_L;
check=num_check;
}
}
}
中间其他模块的省了,
这是主程序中的显示:
display(0x05,TH/10+0x30); //温度显示
display(0x06,TH%10+0x30);
display(0x45,RH/10+0x30); //湿度显示
display(0x46,RH%10+0x30);
这里的RH好像只有湿度的整数部分,但这样取出来也不会像照片里那样吧,好奇怪啊