Import error: smbus

I have recently ordered your Bar100 Sensors for field testing. I have a few concerns and queries id like to bring up.

Firstly, I am using an ESP32 S2 Feather to run the python code which you have provide for these sensors. I have tried to download step 1, the install smbus, however I am having the hardest time downloading this as it throws this error consistently (did pip, pip3, etc):
C:\Users\s_ada>pip3 install smbus
Collecting smbus
Using cached smbus-1.1.post2.tar.gz (104 kB)
Preparing metadata ( … done
Building wheels for collected packages: smbus
Building wheel for smbus ( … error
error: subprocess-exited-with-error

× python bdist_wheel did not run successfully.
│ exit code: 1
╰─> [5 lines of output]
running bdist_wheel
running build
running build_ext
error: [WinError 2] The system cannot find the file specified
building ‘i2c’ library
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for smbus
Running clean for smbus
Failed to build smbus
Installing collected packages: smbus
Running install for smbus … error
error: subprocess-exited-with-error

× Running install for smbus did not run successfully.
│ exit code: 1
╰─> [5 lines of output]
running install
running build
running build_ext
error: [WinError 2] The system cannot find the file specified
building ‘i2c’ library
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> smbus

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

I then tried smbus2 as an install, now that installed, however even when trying to run the smbus or smbus on the circuitpython editor this is the error I keep getting, for smbus and smbus2:

Traceback (most recent call last):
File “”, line 1, in
File “/lib/”, line 2, in
ImportError: no module named ‘smbus2’

I have tried everything I can imagine to fix this but cant seem to get anywhere.

Query 2: How do I go about changing the i2c address of one sensor so that I can have 2 of these sensors, different addresses (one is 0x40 already), but on the same peripheral running together.



MicroPython is pretty different than regular Python. This is how you are supposed to use i²c in there. you will need to tweak our libraries slightly.

im using circuit python? does that not make a difference

aLso, what tweaks need to be made? cant seem to figure out what needs changing (if it needs to) to be able to run these sensors on circuit python.

My bad. I didn’t realize there were multiple python implementations that could run on microcontrollers.

This is how you access i2c on Circuit Python: CircuitPython I2C | CircuitPython Essentials | Adafruit Learning System

You will need to replace this line: KellerLD-python/ at master · bluerobotics/KellerLD-python · GitHub with i2c = board.I2C()

The unlock() logic will probably be needed as well. The api is different, so the writes and reads will need to be changed, too.

This looks like a nice guide:

1 Like

Hi Willian,

still having difficulty doing this, is there any simple way in order to get this working on my circuit python, or is it going to have to refer to a firmware change.

Or what registers do i need to call in order to get the pressure readings. Where can i find this on the data sheet?

Hi @s_adam09, welcome to the forum :slight_smile:

Anything in our library file that involves smbus or _bus will need to be changed to instead use the circuit-python i2c equivalents.

For the code to run on your device, it needs to be modified. Either you can do that modification, or get someone else to do it for you. You’re welcome to submit an issue to the code repository asking for circuit-python support to be added, but I’m unsure when we’re likely to get to that (it could be anywhere from a couple of weeks to over a year - especially if no one else expresses interest in it).

I suppose it would technically be simpler to use a Raspberry Pi or similar instead (which supports standard Python), but presumably that’s not what you’re after.

As per the library README:

The datasheet doesn’t specify registers and the like - that’s in the communication protocol document :slight_smile:

Note that it will likely be easier to follow and modify our existing library rather than remaking it from scratch yourself, but you’re welcome to do so if you want to. As is it’s written for compatibility with Python 2, and it could be re-written to have a more versatile interface (although the process and logic of the I2C communication, parameter reading, and conversions from raw measurements will all be the same, which is most of the library).

The process for doing this is also in the communication protocol document, although it’s not reversible, and not recommended by the manufacturer. Presumably this would be for redundancy or something?

Hi Elliot,

Okay so will i need to make adjustments to the ‘KellerLD’ Code from the library?

Also, regarding the change of i2c address on one sensor, it would be so i can attach two of the bar100 sensors to my esp32. Which would require 2 different addresses?


Yes, our KellerLD-python library is not currently compatible with circuit python, so to use it with circuit python requires changing the library.

Using two Bar100s on the same I2C lines would indeed require them to have different addresses. As I mentioned, it’s possible to change the address, but doing so is not reversible (you can’t change the address back later, and there are limited changes that are possible).

I’m curious as to why you want to have two Bar100s connected to the same device, and am wondering if that’s for redundancy, or for some other reason.