-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add raspberry pi and other fast-gpio device support when no pulseio #14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this on a Raspberry Pi 3B+
It works - sometimes ...
I get bad readings quite often (every 3 or 4) but there is an occasional crash -- see example:
>>> import dht_simpletest
Temp: 85.1 F / 29.5 C Humidity: 68.3%
A full buffer was not returned. Try again.
Temp: 85.1 F / 29.5 C Humidity: 68.7%
Checksum did not validate. Try again.
Temp: 84.9 F / 29.4 C Humidity: 68.9%
Temp: 84.9 F / 29.4 C Humidity: 68.9%
Temp: 84.9 F / 29.4 C Humidity: 68.9%
A full buffer was not returned. Try again.
Temp: 84.9 F / 29.4 C Humidity: 69.0%
Checksum did not validate. Try again.
Temp: 84.7 F / 29.3 C Humidity: 69.0%
Checksum did not validate. Try again.
Temp: 84.7 F / 29.3 C Humidity: 69.0%
Temp: 84.7 F / 29.3 C Humidity: 69.0%
Temp: 84.7 F / 29.3 C Humidity: 68.9%
Checksum did not validate. Try again.
Temp: 84.7 F / 29.3 C Humidity: 68.9%
Temp: 84.7 F / 29.3 C Humidity: 68.7%
Temp: 84.7 F / 29.3 C Humidity: 68.6%
A full buffer was not returned. Try again.
Temp: 84.6 F / 29.2 C Humidity: 68.5%
Temp: 84.6 F / 29.2 C Humidity: 68.5%
A full buffer was not returned. Try again.
Temp: 84.6 F / 29.2 C Humidity: 68.4%
A full buffer was not returned. Try again.
Temp: 84.6 F / 29.2 C Humidity: 68.4%
Temp: 84.4 F / 29.1 C Humidity: 68.4%
Temp: 84.4 F / 29.1 C Humidity: 68.5%
Temp: 84.4 F / 29.1 C Humidity: 68.5%
Temp: 84.4 F / 29.1 C Humidity: 68.6%
Temp: 84.4 F / 29.1 C Humidity: 68.6%
Temp: 84.4 F / 29.1 C Humidity: 68.6%
Temp: 84.4 F / 29.1 C Humidity: 68.6%
Temp: 84.4 F / 29.1 C Humidity: 68.6%
A full buffer was not returned. Try again.
Checksum did not validate. Try again.
Checksum did not validate. Try again.
Temp: 84.2 F / 29.0 C Humidity: 68.5%
Temp: 84.2 F / 29.0 C Humidity: 68.6%
Temp: 84.2 F / 29.0 C Humidity: 68.6%
Temp: 84.2 F / 29.0 C Humidity: 68.6%
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/projects/blinka/dht/dht_simpletest.py", line 11, in <module>
temperature_c = dhtDevice.temperature
File "/home/pi/projects/blinka/dht/adafruit_dht.py", line 213, in temperature
self.measure()
File "/home/pi/projects/blinka/dht/adafruit_dht.py", line 164, in measure
pulses = self._get_pulses()
File "/home/pi/projects/blinka/dht/adafruit_dht.py", line 149, in _get_pulses
pulses.append(int(1000000 * (transitions[i] - transitions[i-1])))
OverflowError: unsigned short is greater than maximum
>>>
I made this change and it seems to run OK: Lots of invalid checksums and "Full buffer not returned " errors, but it keeps running without the integer overflows.
|
awesome, added! |
How much more memory does this take up in a SAMD? (You can measure with |
Is there a reason why this has not been merged yet? It just came up via the forum: |
umm i didnt get around to calculating the gc.free on an m0 before and after |
i can check mem usage here in a minute. |
@brennen let us know what you find. |
ok, so i was running the following test on a feather m0 express: import time
from board import D6
import gc
gc.collect()
print("before import:", gc.mem_free())
import adafruit_dht
print("after import:", gc.mem_free())
gc.collect()
print("before init:", gc.mem_free())
#initial the dht device
dhtDevice = adafruit_dht.DHT22(D6)
print("after init:", gc.mem_free())
while True:
gc.collect()
print("before sensor read:", gc.mem_free())
try:
time.sleep(.5)
# show the values to the serial port
temperature = dhtDevice.temperature * (9 / 5) + 32
humidity = dhtDevice.humidity
print("Temp: {:.1f} F Humidity: {}% ".format(temperature, humidity))
print("after sensor read:", gc.mem_free())
except (RuntimeError, TypeError) as error:
print(error.args) on master, i get:
all well and good. with changes in this PR, i get:
increasing
|
...aaaaand i see i probably got my wires crossed with another merge to master. @jerryneedell lemme know if you want a memory check once conflicts are resolved. |
Hmm, I don’t the sensor not found error is not the same as the None issues we saw. I’ll try to reproduce this tomorrow. |
hmm -- I reproduced the errors reported by @brennen on a Trinket M0
In the PR code , while loop will immediately end - the test is inverted - it should wait at least .25 sec.
Here is the output of @brennen test code on the trinket M0:
I'm not sure how to try to make this change to the PR and resolve the conflicts with the current master. |
sorry i have no idea how to fix and im not going to have time this week to learn, the changes arent that large. i can just close this, y'all cna start a new PR? |
@ladyada I'll work on w new PR - hopefully tomorrow to fix this and reconcile with the master. Once it is in, you can close this one if you approve. |
yay thanks! |
tested on Pi 3