Home > other >  Could you tell me why the DHT11 humidity data show is this?
Could you tell me why the DHT11 humidity data show is this?

Time:10-08

My humidity display is such, very strange, even I have??


DHT11 data on the left, the right is to set the alarm temperature, the procedure is as follows?
Can you teach me how to turn the humidity data is normal?
DHT11 part of the program:
/* * * * * * * * * * * * * * * * * * * * * * * DHT11 test module * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

Void the start ()//signal
{
IO=1;
Delay1 ();
IO=0;
Delay (20);//& gt; 18 ms
IO=1;
Delay1 ();//20-40 us
Delay1 ();
Delay1 ();
Delay1 ();
Delay1 ();
}
Uchar receive_byte ()//receiving one byte
{
Uchar I, temp, count;
for(i=0; i<8; I++)
{
temp=0;
Delay1 (); Delay1 (); Delay1 (); Delay1 ();
If (I/o==1) temp=1;
Count=2;
While ((IO) & amp; & Count++);
If (count==1) break;
Data_byte & lt; <=1;
Data_byte |=temp;
}
Return data_byte;
}
Void the receive ()//receiving data
{
Uchar T_H T_L, R_H R_L, check, num_check;
Uchar count;
Start ().//start signal
IO=1;
if(! IO)//read the response signal DHT11
{
While ((IO) & amp; & Count++);
R_H=receive_byte ();
R_L=receive_byte ();
T_H=receive_byte ();
T_L=receive_byte ();
Check=receive_byte ();
IO=0;//lower latency 50 us
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;
}
}
}
Other modules among provinces,
This is shown in the main program:
The display (0 x05, TH/10 + 0 x30);//temperature display
Display (0 x06, TH % 10 + 0 x30);
The display (0 x45, RH/10 + 0 x30);//humidity display
The display (0 x46, RH % 10 + 0 x30);
The RH here as if only the integer part of humidity, but this out will not see in the photos, so strange

CodePudding user response:

Check your display function, check the RH variable

Recommend you in RH=R_H; Here, set breakpoints, observe the RH values are normal, if the normal is the use of the display function has a problem, if does not normal, it could be the module Settings

CodePudding user response:

Check your value of RH, may be too big,

The display (0 x45, RH/10 + 0 x30); If the RH/10 values greater than 9, is likely to be after + 0 x30 digital characters,

For example,
ASC (" B ")=0 x42, RH/10=18
ASC (" B ")=0 x49, RH/10=27

Try the display (0 x45, (RH/10) % 10 + 0 x30); , whether to have other content high?

CodePudding user response:

When can display data validation should be normal,
Will is a problem of the LCD screen display program? Maybe a look at the effect of the above according to fixed Numbers?

CodePudding user response:

Learning how to learn
  • Related