Add PulseIn to BeagleBone
See original GitHub issueInstalled these libraries on my Beaglebone Black
pip3 install adafruit-blinka pip3 install adafruit-circuitpython-dht
Running this test code (Python 3.5)
import time
import board
import adafruit_dht
# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT22(board.P8_11)
while True:
try:
# Print the values to the serial port
temperature_c = dhtDevice.temperature
temperature_f = temperature_c * (9 / 5) + 32
humidity = dhtDevice.humidity
print("Temp: {:.1f} F / {:.1f} C Humidity: {}% "
.format(temperature_f, temperature_c, humidity))
except RuntimeError as error:
# Errors happen fairly often, DHT's are hard to read, just keep going
print(error.args[0])
time.sleep(2.0)
Getting this message
Traceback (most recent call last): File “/var/lib/cloud9/Python/dht_simpletst.py”, line 6, in <module> dhtDevice = adafruit_dht.DHT22(board.P8_11) File “/usr/local/lib/python3.5/dist-packages/adafruit_dht.py”, line 255, in init super().init(False, pin, 1000) File “/usr/local/lib/python3.5/dist-packages/adafruit_dht.py”, line 66, in init self.pulse_in = pulseio.PulseIn(self._pin, 81, True) AttributeError: module ‘pulseio’ has no attribute ‘PulseIn’
Beaglebone Black Debian/Linux versions
BeagleBoard.org Debian Image 2018-03-05 Linux beaglebone 4.9.82-ti-r102 #1 SMP PREEMPT Thu Feb 22 01:16:12 UTC 2018 armv Debian GNU/Linux 9 (stretch)
Blinka test code works
import board
import digitalio
import busio
print("Hello blinka!")
# Try to create a Digital input
pin = digitalio.DigitalInOut(board.P8_11)
print("Digital IO ok!")
# Try to create an I2C device
i2c = busio.I2C(board.SCL, board.SDA)
print("I2C ok!")
# Try to create an SPI device
spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
print("SPI ok!")
print("done!")
Hello blinka! Digital IO ok! I2C ok! SPI ok! done!
The instructions I am following
https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging?view=all
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (6 by maintainers)
Top GitHub Comments
Yes. I would like to add it. I will start looking at the code.
On Mon, Jul 22, 2019, 7:43 PM Melissa LeBlanc-Williams < notifications@github.com> wrote:
Took a major side-trip into understanding device tree overlay and loadable kernel module development…
1. The sysfs/libgpiod playground
In order to free up a pin for use by libgpiod_pulseio (via libgpiod interface) and leave pins for use by Adafruit_* modules (via sysfs interface), the universal cape overlay that is loaded during boot-up must be edited, compiled, then copied back into /lib/firmware where available for next boot-up.
In my system, the overlay being loaded is,
univ-bbb-EVA-00A0.dtbo univ-bbb-EVx-00A0.dtbo univ-bbb-Exx-00A0.dtbo univ-bbb-xVA-00A0.dtbo univ-bbb-xVx-00A0.dtbo univ-bbb-xxx-00A0.dtbo
and is determined by my /boot/uEnv.txt configuration.
I edited the corresponding DTS file in “/opt/source/bb.org-overlays/src/arm/”, compiled it using “/opt/source/bb.org-overlays/make src/arm/univ-bbb-Exx-00A0.dtbo”, then copied the DTBO file to “/lib/firmware”.
I edited the DTS file by disabling all configuration of pin P8_11 (the one used in the dht_simpletst.py example) by following what was done to disable pins P9_19 and P9_20 (the pins supporting the cape I2C EEPROM bus).
Now…
Both “blinkatest.py” and “dht_simpletst.py” run successfully.
2. libgpiod_pulseio CPU hog!!
I am running “dht_simpletst.py” with a 10 second sleep between attempts to read temperature and humidity.
The CPU utilization by libgpiod_pulseio remains pegged at a constant 98% even while the python program is sleeping!
More later…