Closed evaherrada closed 3 years ago
@dherrada I tested this on a Pi 4B+ with a DHT22 both with and without pulseio. It works both ways but I did see more checksum errors without pulseio.
use_pulseio=False
pi@gjnpi4desk:~/projects/DHT $ python3 dht_simpletest.py
Temp: 74.1 F / 23.4 C Humidity: 51.8%
Temp: 74.1 F / 23.4 C Humidity: 51.7%
Temp: 74.1 F / 23.4 C Humidity: 51.8%
Checksum did not validate. Try again.
Temp: 74.1 F / 23.4 C Humidity: 50.5%
Temp: 73.9 F / 23.3 C Humidity: 51.8%
Checksum did not validate. Try again.
Temp: 74.1 F / 23.4 C Humidity: 50.6%
Temp: 74.1 F / 23.4 C Humidity: 52.0%
use_pulseio=True
pi@gjnpi4desk:~/projects/DHT $ python3 dht_pulseio.py
Temp: 74.1 F / 23.4 C Humidity: 52.0%
Temp: 74.1 F / 23.4 C Humidity: 51.6%
Temp: 73.9 F / 23.3 C Humidity: 51.5%
Temp: 73.9 F / 23.3 C Humidity: 51.5%
Temp: 73.9 F / 23.3 C Humidity: 51.5%
Temp: 74.1 F / 23.4 C Humidity: 51.6%
Temp: 74.1 F / 23.4 C Humidity: 51.6%
Temp: 73.9 F / 23.3 C Humidity: 51.5%
Temp: 73.9 F / 23.3 C Humidity: 51.5%
Temp: 73.9 F / 23.3 C Humidity: 51.5%
Temp: 74.1 F / 23.4 C Humidity: 51.6%
I also test this on a feather_m4_express and the bitbang does not work at all
use_pulseio=False
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.4.0-beta.0-402-g5cd6bb4d5 on 2020-05-30; Adafruit Feather M4 Express with samd51j19
>>> import dht_bitbang_m4
A full buffer was not returned. Try again.
A full buffer was not returned. Try again.
A full buffer was not returned. Try again.
use_pulseio=True
import dht_pulseio_m4 Temp: 76.3 F / 24.6 C Humidity: 50.3% Temp: 76.3 F / 24.6 C Humidity: 50.1% Temp: 76.1 F / 24.5 C Humidity: 50.1%
FYI -- I upgraded to the latest version of the CP main repository and get the same results on the M4 -- biting does not appear to be working on the M4 and I have previously found that it does not work on an M0 either....
Is bitbang supposed to work at all under CP? If not, it should not be an option. If it should work, then something is broken.
@jerryneedell Ok. I think I'll add a comment somewhere in the example that explains this.
Is bitbang supposed to work at all under CP?
I think so. The learn guide (https://learn.adafruit.com/dht/dht-circuitpython-code#step-2980241) says it should work on any pin with PWM support, which, on the M4, is most of them (https://learn.adafruit.com/assets/78438), and, on the M0, is a lot of them (https://learn.adafruit.com/assets/46247).
tested updated PR on Raspberry Pi 4B= with DHT 22
pi@gjnpi4desk:~/projects/DHT $ python3 dht_simpletest.py
Temp: 74.8 F / 23.8 C Humidity: 54.3%
Temp: 74.8 F / 23.8 C Humidity: 53.9%
Temp: 74.7 F / 23.7 C Humidity: 53.8%
Temp: 74.8 F / 23.8 C Humidity: 53.9%
Temp: 74.8 F / 23.8 C Humidity: 53.8%
Temp: 74.8 F / 23.8 C Humidity: 53.8%
^Creceived SIGINT
Traceback (most recent call last):
File "dht_simpletest.py", line 34, in <module>
time.sleep(2.0)
KeyboardInterrupt
pi@gjnpi4desk:~/projects/DHT $ python3 dht_bitbang.py --- with use_pulseio=Fasle
Temp: 74.8 F / 23.8 C Humidity: 53.7%
Temp: 74.8 F / 23.8 C Humidity: 53.6%
Temp: 74.8 F / 23.8 C Humidity: 53.7%
Temp: 74.8 F / 23.8 C Humidity: 53.7%
Temp: 74.8 F / 23.8 C Humidity: 53.7%
Temp: 74.8 F / 23.8 C Humidity: 53.7%
Temp: 74.8 F / 23.8 C Humidity: 53.7%
Temp: 74.8 F / 23.8 C Humidity: 53.6%
^CTraceback (most recent call last):
File "dht_bitbang.py", line 34, in <module>
time.sleep(2.0)
KeyboardInterrupt
also tested using pulseio on feather m4_express -- worked normally.
@jerryneedell Do you think it's worth taking a deeper look into the bitbang issue on CircuitPython? Is there a valid reason that anyone would want to use the bitbang method over pulseio? I think that the really important ones are having both bit-banging and pulseio working on the Pi, and having pulseio working on CircuitPython. If you agree, then I think we should do what you suggested and disable bit-banging on CircuitPython for this library.
@jerryneedell Do you think it's worth taking a deeper look into the bitbang issue on CircuitPython? Is there a valid reason that anyone would want to use the bitbang method over pulseio? I think that the really important ones are having both bit-banging and pulseio working on the Pi, and having pulseio working on CircuitPython. If you agree, then I think we should do what you suggested and disable bit-banging on CircuitPython for this library.
Since bitbang does not appear to work under CP and I am not aware of anyone interested in fixing it, I agree it should be removed. Just throw an error if Pulseio is not available.
@jerryneedell Ok, that's what I'll do.
@jerryneedell To be completely honest, I didn't test this last commit outside of mock testing the if statement in the repl in circuitpython and on the raspberry pi
In my case I had to add dhtDevice.exit()
to my try
then it worked.
@jerryneedell Dylan is off for a while. Any chance you could take over this PR?
@jerryneedell Dylan is off for a while. Any chance you could take over this PR?
I’ll take a look at it tomorrow. I kind if lost track of it.
@kattni I have tested this on a feather_m0 (basic) and on a Raspberry Pi 4 It works on both using pulseio and as expected throws an error on the M0 if pulseio is disabled. On the Raspberry Pi 4 there are occasional errors - more when using bitbang.
By "taking over" this PR - did you want me to do more than this testing? I do not know what the full motivation was for this PR to begin with. The issues with bitbang seem to have eclipsed the issue related to de-init.
Do you want to go ahead and merge this as it is since it appears to be working and no one else has commented on the changes. I wish there were a better way to do this since it has a large piece of code that is never used by CircuitPython (only Blinka) but I don't have anything in mind. Is the bitbang support from Blinka important enough to keep it?
Let me know how you want to proceed.
Is the bitbang support from Blinka important enough to keep it?
@makermelissa Can you weigh in on this? Please glance over the entire thread. The question regarding Blinka is in the comment from Jerry immediately before this one, and that's the thing I'm specifically looking for input on. Thanks!
@jerryneedell I'm bringing in Melissa for the Blinka part of the decision. Then we can sort out where to go from here.
If I recall correctly, bitbang was originally introduced for the RPi because pulseio was not available. See #18 and #14. Are there are some SPC's supported by Blinka that still do not have pulseio? I was just wondering if it was still useful to have. It would simplify and reduce the size the library to take it out if it is not needed.
especially note this comment https://github.com/adafruit/Adafruit_CircuitPython_DHT/pull/18#issuecomment-431088168
That's a good point @jerryneedell. There are actually only a few boards (Raspberry Pi only perhaps) that have the pulseio available, so it's probably worth keeping for the other boards that don't have the hardware support.
If we are going to keep bitbang, then I think this PR is OK - possibly with one change as noted above.
@jerryneedell Can you please make the change you suggested? Then we can get this merged.
@jerryneedell Can you please make the change you suggested? Then we can get this merged.
OK -- I "think" I did that correctly ...
I have several remarks regarding this:
exit()
function be automatically called after a measure with pulseio ?exit()
function? (Remove the print())pi@raspberrypi:~ $ python3 dht_simpletest.py
A full buffer was not returned. Try again.
A full buffer was not returned. Try again.
A full buffer was not returned. Try again.
A full buffer was not returned. Try again.
I'm using a Raspberry Pi zero W, on pin D18
I can submit a PR regarding the exit()
function if needed.
Tried to test but my pi was not cooperating