question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add PulseIn to BeagleBone

See original GitHub issue

Installed 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:open
  • Created 4 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jrobparsonscommented, Jul 23, 2019

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:

Most likely this is because the BBB board hasn’t had PulseIn added yet, whereas the Raspberry Pi has. Are you interested in adding it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/adafruit/Adafruit_Blinka/issues/140?email_source=notifications&email_token=AAVRFUAVFI3ZKHHD5T6HHKLQAZAZJA5CNFSM4IF5635KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2RPGGI#issuecomment-513995545, or mute the thread https://github.com/notifications/unsubscribe-auth/AAVRFUF5TN6BCSZMLBNYMULQAZAZJANCNFSM4IF5635A .

0reactions
jrobparsonscommented, Aug 30, 2019

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!

top - 14:04:35 up 32 min,  2 users,  load average: 1.17, 0.84, 0.67
Tasks: 102 total,   2 running, 100 sleeping,   0 stopped,   0 zombie
%Cpu(s): 19.5 us, 80.5 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :   495588 total,   274928 free,   110764 used,   109896 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   367568 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
 1822 debian    20   0    1448    976    904 R 97.1  0.2   0:53.91 libgpiod_pulsei
 1772 debian    20   0    7192   2900   2344 R  1.6  0.6   0:03.28 top
 1821 debian    20   0   13104   9328   5580 S  1.0  1.9   0:00.94 python
    4 root      20   0       0      0      0 D  0.3  0.0   0:13.51 kworker/0:0
  821 www-data  20   0  228992   3172   1780 S  0.3  0.6   0:02.00 apache2
 1491 root      20   0       0      0      0 S  0.3  0.0   0:00.46 kworker/0:2
    1 root      20   0   25496   5000   3904 S  0.0  1.0   0:03.42 systemd

More later…

Read more comments on GitHub >

github_iconTop Results From Across the Web

PRU Cookbook - BeagleBoard.org
It uses the PRU to extend the real-time hardware of the Bone by adding eight addional servo channels and one addition real-time encoder...
Read more >
Source Code - Exploring BeagleBone
The auto-generated PDF document. To build this documentation enter the exploringBB/library/docs directory and type: doxygen ExploringBB.Doxyfile ...
Read more >
node-red-node-beaglebone (node) - Node-RED
A set of Node-RED nodes to interface to the GPIO pins of a Beaglebone Black board. npm install node-red-node- ... npm install node-red-node-beaglebone@0.0.8 ......
Read more >
PulseIn function - LinuxCNC Forum
I did it with Arduino using the function Pulseln. But I need to do this using a Beaglebone and programming in C++ (Using...
Read more >
PWM | Fading a RGB LED on BeagleBone Black
Every 1/5000 of a second, the PWM output will produce a pulse from 3.3V down to 0V. The length of this pulse is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found