Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

No module named machine
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

No module named machine

by declanshanaghy on Sun Apr 26, 2020 5:38 pm

I'm trying to use bitbang i2c on raspbarry pi 3b+
I've installed adafuit blinka and RPI.GPIO.

Hardware i2c works fine. However i need to use many devices with same addresses so i need an alternative to the HW I2C.
Trying with SW I2C for now, I'm aware of the I2C multiplexers, but trying this out to see if i can avoid more hardware in the mix.

I've searched all over for what the 'machine' module is provided by. I also installed all the dependencies listed in requirements.txt. I'm not sure where this dependency is supposed to come from, is it internal to blinka?

Here's the code.
Code: Select all | TOGGLE FULL SIZE
#!/usr/bin/env python3

import board
import bitbangio
import busio
import adafruit_is31fl3731

i2c = bitbangio.I2C(board.D0, board.D1)

# initialize display using Feather CharlieWing LED 15 x 7
#display = adafruit_is31fl3731.CharlieWing(i2c)

# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
display = adafruit_is31fl3731.Matrix(i2c)

# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet
# display = adafruit_is31fl3731.CharlieBonnet(i2c)

# initial display using Pimoroni Scroll Phat HD LED 17 x 7
# display = adafruit_is31fl3731.ScrollPhatHD(i2c)

# draw a box on the display
# first draw the top and bottom edges
for x in range(display.width):
    display.pixel(x, 0, 50)
    display.pixel(x, display.height - 1, 50)
# now draw the left and right edges
for y in range(display.height):
    display.pixel(0, y, 50)
    display.pixel(display.width - 1, y, 50)


The error:
Code: Select all | TOGGLE FULL SIZE
pi@tuya-donor:~/CharlieMatrix $ python3 example1-bitbang.py
Traceback (most recent call last):
  File "example1-bitbang.py", line 8, in <module>
    i2c = bitbangio.I2C(board.D0, board.D1)
  File "/usr/local/lib/python3.7/dist-packages/bitbangio.py", line 19, in __init__
    self.init(scl, sda, frequency)
  File "/usr/local/lib/python3.7/dist-packages/bitbangio.py", line 22, in init
    from machine import Pin
ModuleNotFoundError: No module named 'machine'



And pip freeze output
Code: Select all | TOGGLE FULL SIZE
Adafruit-Blinka==4.6.0
adafruit-circuitpython-framebuf==1.3.1
adafruit-circuitpython-is31fl3731==2.6.3
Adafruit-PlatformDetect==2.8.0
Adafruit-PureIO==1.1.5
asn1crypto==0.24.0
binho-host-adapter==0.1.4
certifi==2018.8.24
chardet==3.0.4
cryptography==2.6.1
ecdsa==0.13
entrypoints==0.3
idna==2.6
keyring==17.1.1
keyrings.alt==3.1.1
machine==0.0.1
olefile==0.46
paho-mqtt==1.5.0
Pillow==5.4.1
pyaes==1.6.1
pycrypto==2.6.1
pycryptodomex==3.9.6
pyftdi==0.50.2
PyGObject==3.30.4
pyserial==3.4
python-apt==1.8.4
pyusb==1.0.2
pyxdg==0.25
requests==2.21.0
rpi-ws281x==4.2.3
RPi.GPIO==0.7.0
SecretStorage==2.3.1
six==1.12.0
ssh-import-id==5.7
sslpsk==1.0.0
sysv-ipc==1.0.1
tornado==6.0.3
ufw==0.36
urllib3==1.24.1
wiringpi==2.60.0

declanshanaghy
 
Posts: 27
Joined: Fri Mar 11, 2011 1:08 pm

Re: No module named machine

by tannewt on Sun Apr 26, 2020 11:35 pm

What distro are you running on your Pi? I think Blinka is tested on Raspbian.

The machine missing error is due to Blinka misdetecting the system it's on I believe.

tannewt
 
Posts: 1691
Joined: Thu Oct 06, 2016 8:48 pm

Re: No module named machine

by MakerMelissa on Mon Apr 27, 2020 2:43 am

Hello,

The current implementation of bitbangio on the Raspberry Pi only works for micropython boards. We decided to create a separate library and have implemented SPI, but still need to add I2C. If you’d like to watch the issue for adding I2C, you can view it at: https://github.com/adafruit/Adafruit_Ci ... O/issues/6

Thanks,
Melissa

MakerMelissa
 
Posts: 146
Joined: Wed Jun 05, 2013 2:10 am

Re: No module named machine

by declanshanaghy on Mon Apr 27, 2020 10:04 am

I'm on raspbian buster

Code: Select all | TOGGLE FULL SIZE
pi@tuya-donor:~/CharlieMatrix $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

declanshanaghy
 
Posts: 27
Joined: Fri Mar 11, 2011 1:08 pm

Re: No module named machine

by declanshanaghy on Mon Apr 27, 2020 10:08 am

Great thanks,
Is there any timeline on when that's slated to be completed?

I would like to contribute but i just took on another project to add support for the MAX31856 breakout to ESPHome.

I'm blocked on both my projects by these things :-(
Is there even a workaround that i could put in place in BlinkA to limp by?
My other alternative is to use a Mux i suppose.

declanshanaghy
 
Posts: 27
Joined: Fri Mar 11, 2011 1:08 pm

Re: No module named machine

by MakerMelissa on Mon Apr 27, 2020 12:47 pm

Hi,

I'm hoping to get to fixing up some I2C this week starting with hardware I2C working better on alternate ports on the Pi. So, probably later this week or next, but it's best to watch the issue as I usually post updates there.

Melissa

MakerMelissa
 
Posts: 146
Joined: Wed Jun 05, 2013 2:10 am

Re: No module named machine

by declanshanaghy on Mon Apr 27, 2020 12:59 pm

That's great, will do. Thanks.

I posted elsewhere (https://github.com/adafruit/Adafruit_Blinka/pull/190) about trouble i was having getting alternate ports to work. I defined bus3 in config.txt and the device show up but I cant detect anything on the bus with i2cdetect and each address takes about a second to timeout.

I don't really get the point of the PR anyway. Why would someone want bus 1 & 3 on the same pins?

declanshanaghy
 
Posts: 27
Joined: Fri Mar 11, 2011 1:08 pm

Re: No module named machine

by MakerMelissa on Mon Apr 27, 2020 1:30 pm

Hi,

https://github.com/adafruit/Adafruit_Blinka/pull/190 was added in response to viewtopic.php?f=50&t=159207&p=784164#p784164 which enabled i2c-3 instead of i2c-1 using pin muxing. Unfortunately it did not address using the i2c-gpio device tree overlay. Issue https://github.com/adafruit/Adafruit_Blinka/issues/241 is to address that and that is what I was referring to when I mentioned starting with hardware I2C. :)

Melissa

MakerMelissa
 
Posts: 146
Joined: Wed Jun 05, 2013 2:10 am

Please be positive and constructive with your questions and comments.