Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prog delivers confused/zero values inbetween #2

Open
woodz- opened this issue Feb 8, 2024 · 1 comment
Open

prog delivers confused/zero values inbetween #2

woodz- opened this issue Feb 8, 2024 · 1 comment

Comments

@woodz-
Copy link

woodz- commented Feb 8, 2024

When compiling and running your program with g++

$ g++ ./src/main.cpp ./src/DHT22.cpp -I./include -lwiringPi -o dht22

$ ./dht22

the output looks like

Temp : 12.00 °C,  Humidity : 99.90 %                                                            
Temp :  0.00 °C,  Humidity :  0.00 %                                                            
Temp : 12.00 °C,  Humidity : 99.90 %                                                            
Temp : 24.00 °C,  Humidity : 199.80 %                                                           
Temp :  0.00 °C,  Humidity :  0.00 %                                                            
Temp :  0.00 °C,  Humidity :  0.00 %                                                            
Temp :  0.00 °C,  Humidity :  0.00 %                                                            
Temp : 12.00 °C,  Humidity : 99.90 %                                                            
Temp : 12.00 °C,  Humidity : 99.90 %                                                            
Temp : 12.10 °C,  Humidity : 99.90 %                                                            
Temp : 12.10 °C,  Humidity : 99.90 %                                                            
Temp : 24.20 °C,  Humidity : 199.80 %

Note
I've been reformatting the output a bit and changing the loop delay to 5000ms inmain.cpp.

We can see zero values and sporadic doubled temperature values and +100 humidity values.

Why is that?

@woodz- woodz- changed the title prog delivers zero values inbegtween prog delivers zero values inbetween Feb 8, 2024
@woodz- woodz- changed the title prog delivers zero values inbetween prog delivers confused/zero values inbetween Feb 8, 2024
@Qengineering
Copy link
Owner

The cause is simple, your timing jitters. The cure is difficult.

The code is more or less a foundation on which to build further.
For example, no threading is used. In practice, all processes run simultaneously parallel to the DHT22 code and can influence the timing. As can be found in the documentation, timing needs to be quite precise.

You can address the issue from two sides.

  • Try to get the timing as accurate as possible.
  • Fix the outcome. Most errors are so obvious (>100% humidity) or have a completely different outcome compared to the previous one (temperature dropping from 25° to 0° between readings) that you already know they are erroneous values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants