Skip to content

python3 smbus error #6

@johannstieger

Description

@johannstieger

Hi,
when I want to run
sudo python3 merged.py
or
sudo python3 bat.py
I got these errors (line number is different in bat.py) :
File "~/x120x/merged.py", line 5, in
import smbus
ModuleNotFoundError: No module named 'smbus'

It seems that smbus is missing. Is it better, to install smbus via
sudo apt install python3-smbus
or edit bat.py and merged.py and change
import smbus
bus = smbus.SMBus(1)
to
import smbus2
bus = smbus2.SMBus(1)
?
In both cases I was able to read the battery status (Voltage and battery charge level) with "sudo python3 bat.py".
But in none of the cases above I was able to get some informations via "sudo python3 merged.py". I only get a line break.

When I run
sudo i2cdetect -y 1
I can see that address 36 is detected.

Best regards, Johann

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions