CommandActor CommandActor - 1 year ago 110
Python Question

Python DHT22 code error

I am working on a Raspberry Pi DHT22 Humidity monitor.
This is my code:
And when I run this code, this is the output:

Humidity is Critical! (Too high) Current humidity: 45.2 %

And I have no idea why it says that "Humidity is CRITICAL!", because the humidity is 45.2% and 45.2 is not higher than 75%.
Please help.

Answer Source

You create string hum and then you compare string with integer (65 and 75) so you get wrong result. You have to compare number t (or maybe h) with integer (65 and 75).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download