water temp sensor - sleep() does not work as intended!!
See original GitHub issueI have a water temp sensor DS18B20 (https://www.adafruit.com/product/381) It’s connected to pin GPIO4 and it has a 10k resistor like recommended I want to have readings every second So I’ve done this
from time import sleep
from datetime import datetime
from w1thermsensor import W1ThermSensor
## Constants
MEASURE_INTERVAL = 1 #seconds
while True:
d = datetime.now()
time_ = '{:%H:%M:%S}'.format(d)
# (DS18B) Water temperature sensor
try:
w = W1ThermSensor()
water_temp = str(w.get_temperature()) # default pin GPIO4 for data and temp in Celsius degrees
except:
water_temp = '0'
print(time_,water_temp)
sleep(MEASURE_INTERVAL)
However instead 1 sec interval I’m having 2 sec consistently (most of times) this is the result
17:20:55 19.437
17:20:57 19.437
17:20:59 19.437
17:21:01 19.437
17:21:03 19.437
17:21:05 19.437
17:21:06 19.437
17:21:08 19.437
17:21:10 19.437
17:21:12 19.437
17:21:14 19.437
17:21:16 19.437
17:21:17 19.437
17:21:19 19.437
17:21:21 19.437
Why? I don’t understand should i change something in W1ThermSensor class?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
[SOLVED] DHT11/DHT22 - Failed to read from DHT sensor
Troubleshooting guide for the most common issues and errors with DHT11, DHT22, AM2302 or AM2301 sensors, follow the next steps to make your...
Read more >How to check a faulty temperature sensor?
Guide on how to check a faulty thermocouple or resistance thermometer to solve any issues. If in doubt contact us and we can...
Read more >Track your nightly wrist temperature changes with Apple Watch
Apple Watch Series 8 or Apple Watch Ultra can gather wrist temperature data while you sleep to help give you insight into your...
Read more >Shelly Sensors Guide: Humidity and Temperature | Facebook
The Shelly “temperature sensor add-on” is another option which eliminates both the battery life and “sleep” parts of this discussion. The add-on is...
Read more >Getting Started with the MCP9808 Temperature Sensor ...
Next, the setup()-method wakes up the MCP9808 from its sleep mode. You can put the sensor in its low-power sleep mode by calling...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes! But I placed the reading in a separate Thread. Thanks
On 5 Feb 2018 12:31 p.m., “Timo Furrer” notifications@github.com wrote:
Thanks @bsimmo ! @Ricardosgeral does that solve your problem?