Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

MCP2221 Ubuntu Laptop connection
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MCP2221 Ubuntu Laptop connection

by georgie123 on Wed Oct 27, 2021 10:53 pm

Hi,

I bought the MCP2221A board thinking it would help me interface my color sensor (which communicates using I2C) with my laptop that runs Ubuntu 20.04 (through USB).
However, even after following all the setup instructions, I am unable to import Blinka's 'board' through python. I have looked everywhere and I have almost exhausted all the online solutions.

So I was wondering, if there is a solution to getting the board library to work on my laptop? Or is it the case that this library was only meant to work on boards like arduino and raspberry pi and not an actual laptop?

Any help on this issue would be greatly appreciated

Thanks in advance

georgie123
 
Posts: 9
Joined: Wed Oct 27, 2021 10:43 pm

Re: MCP2221 Ubuntu Laptop connection

by adafruit_support_carter on Thu Oct 28, 2021 12:48 pm

What happens when you try the import? Do you get error messages? etc.

adafruit_support_carter
 
Posts: 21915
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP2221 Ubuntu Laptop connection

by georgie123 on Thu Oct 28, 2021 5:38 pm

Hello,
Thanks for the reply. The error was something like "NotImplementedError("Board not supported {}".format(board_id))" and the second line was "Board not supported GENERIC_LINUX_PC."
Is this saying that the boards that it support does not include a Linux PC? I am really confused.

georgie123
 
Posts: 9
Joined: Wed Oct 27, 2021 10:43 pm

Re: MCP2221 Ubuntu Laptop connection

by adafruit_support_carter on Thu Oct 28, 2021 5:41 pm

That indicates the environment variable has not been set:
https://learn.adafruit.com/circuitpytho ... 3049721-25

adafruit_support_carter
 
Posts: 21915
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP2221 Ubuntu Laptop connection

by georgie123 on Fri Oct 29, 2021 10:37 pm

Looks like that actually solved the problem. Thank you for all your help.

Not sure how I missed that simple step

georgie123
 
Posts: 9
Joined: Wed Oct 27, 2021 10:43 pm

Re: MCP2221 Ubuntu Laptop connection

by georgie123 on Fri Oct 29, 2021 10:39 pm

Not sure if I should make a separate post, but I was wondering how can I get the rgb sensor values through python on my laptop (using the mcp2221 as the interface). Should I use the board.I2C() method given in the example code or should I use serial/tty communication?
If it is the latter, are there any codes I can refer to implement that?

Thanks in advance

georgie123
 
Posts: 9
Joined: Wed Oct 27, 2021 10:43 pm

Re: MCP2221 Ubuntu Laptop connection

by georgie123 on Fri Oct 29, 2021 10:50 pm

Sorry for the multiple replies, but this is the error I am now facing when I run the python code after exporting BLINKA_MCP2221=1.

Error:
Traceback (most recent call last):
File "rgb_sesnor.py", line 9, in <module>
import board
File "/usr/local/lib/python3.8/dist-packages/board.py", line 187, in <module>
from adafruit_blinka.board.microchip_mcp2221 import *
File "/home/user/.local/lib/python3.8/site-packages/adafruit_blinka/board/microchip_mcp2221.py", line 2, in <module>
from adafruit_blinka.microcontroller.mcp2221 import pin
File "/home/user/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/mcp2221/pin.py", line 2, in <module>
from .mcp2221 import mcp2221
File "/home/user/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/mcp2221/mcp2221.py", line 386, in <module>
mcp2221 = MCP2221()
File "/home/user/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/mcp2221/mcp2221.py", line 53, in __init__
self._hid.open(MCP2221.VID, MCP2221.PID)
File "hid.pyx", line 113, in hid.device.open
OSError: open failed

Any advice?

georgie123
 
Posts: 9
Joined: Wed Oct 27, 2021 10:43 pm

Re: MCP2221 Ubuntu Laptop connection

by adafruit_support_carter on Sat Oct 30, 2021 10:27 am

Try the simple checks here and make sure they all work. Or if not, which one doesn't:
https://learn.adafruit.com/circuitpytho ... all-checks

It may just be a permissions issue which the udev settings should fix:
https://learn.adafruit.com/circuitpytho ... -3049707-5

adafruit_support_carter
 
Posts: 21915
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP2221 Ubuntu Laptop connection

by georgie123 on Sun Oct 31, 2021 1:32 am

Hi,

So I tried everything mentioned in those two websites and I'm still getting the same error.
I also tried using serial.Serial('/dev/ttyACM0') and readline() but even that isn't showing anything

Please help me

georgie123
 
Posts: 9
Joined: Wed Oct 27, 2021 10:43 pm

Re: MCP2221 Ubuntu Laptop connection

by georgie123 on Sun Oct 31, 2021 2:51 am

Update: When I unplug and replug the sensor, the python code runs without any problem. But if I want to reuse the code after terminating it the first time, it shows the above error everytime. Really confused why this is happening

georgie123
 
Posts: 9
Joined: Wed Oct 27, 2021 10:43 pm

Re: MCP2221 Ubuntu Laptop connection

by adafruit_support_carter on Sun Oct 31, 2021 10:58 am

At which step of the checks:
https://learn.adafruit.com/circuitpytho ... all-checks
do you get an error and what is the text of the error?

adafruit_support_carter
 
Posts: 21915
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP2221 Ubuntu Laptop connection

by georgie123 on Sun Oct 31, 2021 3:49 pm

I don't get an error in any of the checks.
I only get it when I try to run my python code from the terminal "$python3 rgb_sensor.py"

The error looks like:
Traceback (most recent call last):
File "rgb_sesnor.py", line 9, in <module>
import board
File "/usr/local/lib/python3.8/dist-packages/board.py", line 187, in <module>
from adafruit_blinka.board.microchip_mcp2221 import *
File "/home/user/.local/lib/python3.8/site-packages/adafruit_blinka/board/microchip_mcp2221.py", line 2, in <module>
from adafruit_blinka.microcontroller.mcp2221 import pin
File "/home/user/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/mcp2221/pin.py", line 2, in <module>
from .mcp2221 import mcp2221
File "/home/user/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/mcp2221/mcp2221.py", line 386, in <module>
mcp2221 = MCP2221()
File "/home/user/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/mcp2221/mcp2221.py", line 53, in __init__
self._hid.open(MCP2221.VID, MCP2221.PID)
File "hid.pyx", line 113, in hid.device.open
OSError: open failed

georgie123
 
Posts: 9
Joined: Wed Oct 27, 2021 10:43 pm

Re: MCP2221 Ubuntu Laptop connection

by adafruit_support_carter on Mon Nov 01, 2021 11:20 am

It's weird that the open check passes:
https://learn.adafruit.com/circuitpytho ... -3049740-7
but then it can't open when trying to use with your code.
Code: Select all | TOGGLE FULL SIZE
self._hid.open(MCP2221.VID, MCP2221.PID)
File "hid.pyx", line 113, in hid.device.open
OSError: open failed

Those should essentially be the same thing.

Are you running the checks and code as different users (permissions issue)? Or anything else different?

As another check, see if an I2C scan will run OK:
Code: Select all | TOGGLE FULL SIZE
import board
i2c = board.I2C()
i2c.scan()

adafruit_support_carter
 
Posts: 21915
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP2221 Ubuntu Laptop connection

by georgie123 on Wed Nov 03, 2021 2:12 pm

the "import board" is the only command that gives me the error. All the other commands including the post check ones do not give me any error.
I'm also a bit confused as to why this is happening

georgie123
 
Posts: 9
Joined: Wed Oct 27, 2021 10:43 pm

Re: MCP2221 Ubuntu Laptop connection

by adafruit_support_carter on Wed Nov 03, 2021 2:45 pm

The behavior is repeatable? Even after a reset? This is very weird.

adafruit_support_carter
 
Posts: 21915
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.