B.Goode, you made a very interesting point when you commented
I wrote a small loop to only read the sensor and print the output. Inserting a sleep(2) between the temperature and the humidity read statements greatly improves the reliability of reading the sensor.
I've then tried the same approach in the temperature webserver code. This creates a new problem with reading the html page via a browser, but I'll post more about that once I understand why the sleep statements are causing a problem. I suspect the browser doesn't respond well to the delays once it has connected to the pico webserver.
Quite enjoying doing this kind of thing again. Thanks for your input, it's been a big help!
You're right. Any example I've seen shows the temp then humidity being read immediately one after the other, but I thought about what you said. That comment in the dht11 module suggests it may be necessary to leave a gap between each communication with the dht11. So I thought I'd try an experiment.You seem to be reading the sensor more often, and perhaps more quickly, than you want to admit.
I wrote a small loop to only read the sensor and print the output. Inserting a sleep(2) between the temperature and the humidity read statements greatly improves the reliability of reading the sensor.
I've then tried the same approach in the temperature webserver code. This creates a new problem with reading the html page via a browser, but I'll post more about that once I understand why the sleep statements are causing a problem. I suspect the browser doesn't respond well to the delays once it has connected to the pico webserver.
Quite enjoying doing this kind of thing again. Thanks for your input, it's been a big help!
Statistics: Posted by KennyRonin — Wed Jan 31, 2024 12:54 pm