question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

water temp sensor - sleep() does not work as intended!!

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Ricardosgeralcommented, Feb 5, 2018

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 https://github.com/bsimmo ! @Ricardosgeral https://github.com/ricardosgeral does that solve your problem?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/timofurrer/w1thermsensor/issues/45#issuecomment-363071319, or mute the thread https://github.com/notifications/unsubscribe-auth/AdESUDjeDe8g-02h3qqxNKEZr2biwAmeks5tRvSTgaJpZM4R3h1z .

0reactions
timofurrercommented, Feb 5, 2018

Thanks @bsimmo ! @Ricardosgeral does that solve your problem?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found