So, I’m using a raspberry pi 3b+ with a dht22 sensor. I’m working with Python 3.7 using the blynk library.
I want to be able to keep the blynk loop running, but I also want to check independently the current humidity/temperature, to do other stuff with that (turn on/off fans, a humidifyer, etc).
I’ve faced some problems trying this:
I tried just checking if the humidity is over a given value in the same loop where blynk.run() is, and then call another function which does whatever it has to do, and check for humidity again, to return to the main loop when humidity is at desired value, but when this function is called, the blynk loop stops and the app hangs.
DHT22 sensor has a delay of 1.5s between readings. I don’t want to be checking it all the time. My intention was to normally check values like each 5 minutes, and when a minimum value is reached, call a function which would check it more frequently (1.5s) until it’s in the desired range.
I tried running two different processes, one for the blynk loop, and another one for ‘main’ loop (which doesnt interact with blynk). The problem is, as the two processes check the dht22 sensor, they might do it at the same time, and because the sensor has a response time of 1.5s it will glitch out