Git Product home page Git Product logo

Comments (3)

joan2937 avatar joan2937 commented on September 26, 2024

Leave the class as it originally was but remove the import atexit and the atexit call.

Change the main to look like the following.

   import pigpio

   import DHT22

   pi = pigpio.pi()

   s = DHT22.sensor(pi, 4)

   s.trigger()

   time.sleep(0.2)

   print("{} {} {:3.2f} {} {} {} {}".format(
      s.humidity(), s.temperature(), s.staleness(),
      s.bad_checksum(), s.short_message(), s.missing_message(),
      s.sensor_resets()))

   s.cancel()

   pi.stop()

The reading will be good provided bad_checksum(), short_message(), missing_message(), and
sensor_resets() are all zero.

from pigpio.

HeatfanJohn avatar HeatfanJohn commented on September 26, 2024

That resolved the problem. Thank you!

Is the atexit code a safety mechanism to ensure that cancel is always
performed?

What would happen if the program exited without calling cancel?

Also, I have noticed that on my gen 1 Pi model B that pigpiod always uses
around 8% CPU as reported by TOP.

Is that normal?

On Tue, Jul 28, 2015 at 5:30 PM, joan2937 [email protected] wrote:

Leave the class as it originally was but remove the import atexit and the
atexit call.

Change the main to look like the following.

import pigpio

import DHT22

pi = pigpio.pi()

s = DHT22.sensor(pi, 4)

s.trigger()

time.sleep(0.2)

print("{} {} {:3.2f} {} {} {} {}".format(
s.humidity(), s.temperature(), s.staleness(),
s.bad_checksum(), s.short_message(), s.missing_message(),
s.sensor_resets()))

s.cancel()

pi.stop()

The reading will be good provided bad_checksum(), short_message(),
missing_message(), and
sensor_resets() are all zero.


Reply to this email directly or view it on GitHub
#16 (comment).

from pigpio.

joan2937 avatar joan2937 commented on September 26, 2024

The atexit in the class was really to make sure the watchdog was switched off if the main program terminated (the expectation being that most often the class would be used in a forever loop). If the watchdog was left switched on it might confuse a later script which just expected to get level changes.

8% CPU usage is about right on a non-Pi2. That's the base level for the overhead of the 200 thousand gpio reads per second made by the daemon. However that's a fixed overhead regardless of how many gpios are used for PWM or servo pulses and is very quickly more efficient than trying to service anywhere near that number of gpio interrupts.

from pigpio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.