Beaglebone AI - read analog input with python

28 views
Skip to first unread message

dav...@gmail.com

unread,
Jul 3, 2020, 11:20:49 AM7/3/20
to BeagleBoard

Hello, i have a Beaglebone AI, i need read analog input with python code, example:

import Adafruit_BBIO.ADC as ADC
from time import sleep

ADC.setup()

analogPin = "P9_33"

while(1):
       potVal = ADC.read(analogPin)
       potVolt = potVal*1.8
       print ("The Potentiometer Voltage is: {}".format(potVolt))
       sleep(0.5)

but, this code generated error:

debian@beaglebone:~$ sudo python3 test_bbai_ai.py
Traceback (most recent call last):
  File "test_bbai_ai.py", line 4, in <module>
    ADC.setup()
RuntimeError: Unable to setup ADC system. Possible causes are:
  - A cape with a conflicting pin mapping is loaded
  - A device tree object is loaded that uses the same name for a fragment: helper

Please, help me, thank you.

PD. BeagleBoard.org Debian Buster IoT TIDL Image 2020-04-06

Dennis Lee Bieber

unread,
Jul 3, 2020, 2:39:37 PM7/3/20
to Beagleboard
On Fri, 3 Jul 2020 08:02:20 -0700 (PDT), in
gmane.comp.hardware.beagleboard.user
davavru-Re5JQEe...@public.gmane.org wrote:

>
>Hello, i have a Beaglebone AI, i need read analog input with python code,
>example:
>
>import Adafruit_BBIO.ADC as ADC

The first thing to realize is that the BB AI does not support runtime
pin-mux changes. There is no config-pin tool available. The second is that,
due to some changes in Px_y assignments to chip "balls", Adafruit_BBIO may
not be compatible.


> ADC.setup()
>RuntimeError: Unable to setup ADC system. Possible causes are:
> - A cape with a conflicting pin mapping is loaded
> - A device tree object is loaded that uses the same name for a fragment:

As stated -- the loaded device tree does not have pins configured for
ADC mode (hopefully it doesn't require all potential ADCs to be set, and
can find those that are active)

>
>Please, help me, thank you.

You are going to have to edit the device tree source to define the
desired pin as analog input, compile it, and set up uEnv.txt to load this
device tree in place of the one that is already in place.

NOTE: I don't know if it is possible to provide just an overlay device tree
without modifying the primary device tree. Maybe start with
https://www.element14.com/community/community/project14/visionthing/blog/2019/11/16/beagleboard-ai-brick-recovery-procedure#jive_content_id_PINMUXING
or
https://github.com/MalavPatel3501/BeagleBone-AI--mpBBAI-IO-Python-Library
which is a replacement for Adafruit_BBIO (no ADC.setup() in the example
https://github.com/MalavPatel3501/BeagleBone-AI--mpBBAI-IO-Python-Library/blob/master/mpBBAI-ADC.py
as it is set up in device tree). Looking at the main file, it performs
everything through sysfs access.

Note that
https://github.com/adafruit/adafruit-beaglebone-io-python/issues/317
indicates the Adafruit_BBIO is not yet compatible with the BB AI.



--
Dennis L Bieber

Mark Lazarewicz

unread,
Jul 3, 2020, 4:42:23 PM7/3/20
to beagl...@googlegroups.com
Hello Daveru

Please tell The professor Or H1B boot camp instructor he's given you an assignment thats not possible.
If he doesn't know that how's he going to coach you after you add BBAI on your resume. Besides there's no travel right now.
We understand tracking  down Runtime errors is a tremendous task hopefully someone is available 24/7 in the future when you get another runtime  error
Where are you  going to school?


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/9a415935-e8b3-47fc-b2ac-625f0c799f37o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages