Comments (3)
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.
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.
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)
- Pigpio BB Serial Read CPU Resource vs. RPI version HOT 4
- Is there a way to flush an open gpioSerialRead buffer? HOT 9
- event_callback with 0 bytes
- Issue with pigpio Initialization on Raspberry Pi 5 Model B HOT 1
- Understanding pigpiod command implementation HOT 9
- Glitch filter active while doing bbSerialRead? HOT 3
- SPI Slave - BSCX not consistently working RPi4B HOT 6
- i2c_open() returns the same handle for two devices on the same bus HOT 37
- Scheduling repetitive SPI writes HOT 3
- Isr doesn't work on raspberry os 12.5 HOT 3
- Continuous Wave Program Concept HOT 6
- SPI6 mode 3 HOT 1
- Leave CS low HOT 1
- Pigpio stuck on activating HOT 4
- Adding new functions to the library HOT 2
- Missed packets using RaspberryPi and nRF24L01. HOT 8
- Python 3.11.2 is installed but still getting "Depends: python:any (>= 2.7~) but it is not installable" HOT 2
- gpioSetISRFunc error -123 HOT 1
- setup.py does not work with python 3.12
- libpigpio1 and libpigpio-dev version issue with pigpio
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pigpio.