CommandActor CommandActor - 1 month ago 9
Python Question

Python DHT22 code error

I am working on a Raspberry Pi DHT22 Humidity monitor.
This is my code: pastebin.com/vHGCgjd2
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

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).