Blinka setup on R Pi 4 for Trinkey
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- JimBoulder
- Posts: 11
- Joined: Wed Jul 12, 2023 10:32 pm
Blinka setup on R Pi 4 for Trinkey
I am trying to setup a Raspberry Pi 4 to use blinka to control a trinkey.
Folling the instructions https://learn.adafruit.com/circuitpytho ... pico/linux. I am stuck on the step to install pyserial.
jim@pi03:~ $ sudo pip3 install pyserial
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install. ...
jim@pi03:~ $ sudo apt install python3-pyserial
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python3-pyserial
jim@pi03:~ $ sudo apt install python-pyserial
returns the same error.
The step before. for hiaapi
jim@pi03:~ $ sudo apt install python3-hidapi
was successful.
What am I missing?
Thank you,
Jim
Folling the instructions https://learn.adafruit.com/circuitpytho ... pico/linux. I am stuck on the step to install pyserial.
jim@pi03:~ $ sudo pip3 install pyserial
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install. ...
jim@pi03:~ $ sudo apt install python3-pyserial
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python3-pyserial
jim@pi03:~ $ sudo apt install python-pyserial
returns the same error.
The step before. for hiaapi
jim@pi03:~ $ sudo apt install python3-hidapi
was successful.
What am I missing?
Thank you,
Jim
- Franklin97355
- Posts: 24333
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Blinka setup on R Pi 4 for Trinkey
This might help. https://pimylifeup.com/python-externall ... vironment/ I have the problem on my Linux computer sometimes and this helps.
- JimBoulder
- Posts: 11
- Joined: Wed Jul 12, 2023 10:32 pm
Re: Blinka setup on R Pi 4 for Trinkey
OK that worked to install pyserial and adafruit-blinka. The first few post install checks are good.
It fails on the check-if-found test.
>>> import hid
>>> device = hid.device()
>>> device.open(0x239A, 0x0109)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "hid.pyx", line 143, in hid.device.open
OSError: open failed
I have the Trinkey QT2040 - RP2040 USB Key with Stemma QT PID 5056. I have the same result with u2if_trinkey_qt2040_rp2040.uf2 and u2if_trinkey.uf2 installed.
Any ideas?
Thank you,
Jim
It fails on the check-if-found test.
>>> import hid
>>> device = hid.device()
>>> device.open(0x239A, 0x0109)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "hid.pyx", line 143, in hid.device.open
OSError: open failed
I have the Trinkey QT2040 - RP2040 USB Key with Stemma QT PID 5056. I have the same result with u2if_trinkey_qt2040_rp2040.uf2 and u2if_trinkey.uf2 installed.
Any ideas?
Thank you,
Jim
- adafruit2
- Posts: 22717
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Blinka setup on R Pi 4 for Trinkey
why do you need low level - hid control? you can just use pyserial right?
(like this https://learn.adafruit.com/uart-communi ... hon-boards but one side uses pyserial to send over the commands rather than bidirecitonally)
(like this https://learn.adafruit.com/uart-communi ... hon-boards but one side uses pyserial to send over the commands rather than bidirecitonally)
- JimBoulder
- Posts: 11
- Joined: Wed Jul 12, 2023 10:32 pm
Re: Blinka setup on R Pi 4 for Trinkey
I would like to have direct reading of my sensors from my Raspberry Pi host. As described in
https://learn.adafruit.com/adafruit-tri ... on-example
and
https://learn.adafruit.com/diy-trinkey- ... -with-u2if
This has one install hidapi, pyserial and adafruit-blinka.
In following the instructions it fails the post install checks, as I detailed above. I did try running the sample code and it fails.
How do I get to where I can do direct reading?
Thank you,
Jim
https://learn.adafruit.com/adafruit-tri ... on-example
and
https://learn.adafruit.com/diy-trinkey- ... -with-u2if
This has one install hidapi, pyserial and adafruit-blinka.
In following the instructions it fails the post install checks, as I detailed above. I did try running the sample code and it fails.
How do I get to where I can do direct reading?
Thank you,
Jim
- adafruit2
- Posts: 22717
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Blinka setup on R Pi 4 for Trinkey
ok so you installed U2IF on the trinkey?
- Speedy_VI
- Posts: 227
- Joined: Sat Feb 24, 2024 10:58 pm
Re: Blinka setup on R Pi 4 for Trinkey
Sorry to butt in but curious - Is the U2IF a Trinkey QT2040 only thing or can this be done on any RP2040 based board?
Thanks.
Thanks.
- adafruit2
- Posts: 22717
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Blinka setup on R Pi 4 for Trinkey
we have builds ready for *some* boards but it could be recompiled to any RP2040
- Speedy_VI
- Posts: 227
- Joined: Sat Feb 24, 2024 10:58 pm
Re: Blinka setup on R Pi 4 for Trinkey
Thanks.adafruit2 wrote: Thu Jan 02, 2025 11:22 am we have builds ready for *some* boards but it could be recompiled to any RP2040
- JimBoulder
- Posts: 11
- Joined: Wed Jul 12, 2023 10:32 pm
- adafruit2
- Posts: 22717
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Blinka setup on R Pi 4 for Trinkey
oh i see what you mean, so you have the trinkey but you want blinka to use that not the native Pi GPIO. i've never done that before (most folks just use the native IO) but you should be able to set an environment variable BLINKA_U2IF in the same shell before calling python
https://github.com/adafruit/Adafruit_Py ... ip.py#L103
https://github.com/adafruit/Adafruit_Py ... ip.py#L103
- JimBoulder
- Posts: 11
- Joined: Wed Jul 12, 2023 10:32 pm
Re: Blinka setup on R Pi 4 for Trinkey
Yes I have set BLINKA_U2IF, and the connection check fails.
jim@pi03:~/trinkey $ echo $BLINKA_U2IF
1
jim@pi03:~/trinkey $ python3
Python 3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hid
>>> device = hid.device()
>>> device.open(0x239A, 0x0109)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "hid.pyx", line 143, in hid.device.open
OSError: open failed
Running the chip.py referenced in the previous post returns nothing.
jim@pi03:~/trinkey $ echo $BLINKA_U2IF
1
jim@pi03:~/trinkey $ python3 chip.py
jim@pi03:~/trinkey $ echo $?
0
Any ideas?
jim@pi03:~/trinkey $ echo $BLINKA_U2IF
1
jim@pi03:~/trinkey $ python3
Python 3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hid
>>> device = hid.device()
>>> device.open(0x239A, 0x0109)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "hid.pyx", line 143, in hid.device.open
OSError: open failed
Running the chip.py referenced in the previous post returns nothing.
jim@pi03:~/trinkey $ echo $BLINKA_U2IF
1
jim@pi03:~/trinkey $ python3 chip.py
jim@pi03:~/trinkey $ echo $?
0
Any ideas?
- adafruit2
- Posts: 22717
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Blinka setup on R Pi 4 for Trinkey
well you dont want to run any of that HID stuff right? you should just `import board` ?
is there a particular reason you want to use U2IF and not just connect to the pi directly?
is there a particular reason you want to use U2IF and not just connect to the pi directly?
- JimBoulder
- Posts: 11
- Joined: Wed Jul 12, 2023 10:32 pm
Re: Blinka setup on R Pi 4 for Trinkey
The 'import hid' statemant is part of the check-if-found test code on https://learn.adafruit.com/circuitpytho ... 040-boards.
Running 'import board' generated errors.
Note that https://learn.adafruit.com/circuitpytho ... pico/linux
has one install hidapi not hid, which is what I have done.
The chip.py file uses hid:
if os.environ.get("BLINKA_U2IF"):
import hid
I have reinstalled the OS and the libraries etc following the instructions on https://learn.adafruit.com/circuitpytho ... pico/linux. With the same results.
I would prefer to use U2IF because my Pi case makes it difficult to access the GPIO pins. The Adafruit instructions indicate this should be a valid way to access the I2C sensor boards.
Running 'import board' generated errors.
Note that https://learn.adafruit.com/circuitpytho ... pico/linux
has one install hidapi not hid, which is what I have done.
The chip.py file uses hid:
if os.environ.get("BLINKA_U2IF"):
import hid
I have reinstalled the OS and the libraries etc following the instructions on https://learn.adafruit.com/circuitpytho ... pico/linux. With the same results.
I would prefer to use U2IF because my Pi case makes it difficult to access the GPIO pins. The Adafruit instructions indicate this should be a valid way to access the I2C sensor boards.
- adafruit2
- Posts: 22717
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Blinka setup on R Pi 4 for Trinkey
maybe run the python3 command as sudo?
Please be positive and constructive with your questions and comments.