BME280 and SGP30 with Raspberry Pi Pico

Hi,
I am new to the hardware devices, I am currently doing a raspberry pi pico data logging, and I am using Raspberry Pi Pico and BME280 (breakout BME280) sensor by pimoroni, I am getting errors as below when I tried !pip install pimoroni-bme280 smBus
inside Thonny as there is no other way to interact with Pip :


Defaulting to user installation because normal site-packages is not writeable
Collecting pimoroni-bme280
  Using cached pimoroni_bme280-0.1.1-py3-none-any.whl (5.5 kB)
Collecting smBus
  Using cached smbus-1.1.post2.tar.gz (104 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting i2cdevice>=0.0.6
  Using cached i2cdevice-0.0.7-py3-none-any.whl (7.2 kB)
Building wheels for collected packages: smBus
  Building wheel for smBus (setup.py): started
  Building wheel for smBus (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  Γ— python setup.py bdist_wheel did not run successfully.
  β”‚ exit code: 1
  ╰─> [5 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'i2c' library
      error: [WinError 2] The system cannot find the file specified
      [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 setup.py clean for smBus
Failed to build smBus
Installing collected packages: smBus, i2cdevice, pimoroni-bme280
  Running setup.py install for smBus: started
  Running setup.py install for smBus: finished with status 'error'
  error: subprocess-exited-with-error
  
  Γ— Running setup.py install for smBus did not run successfully.
  β”‚ exit code: 1
  ╰─> [5 lines of output]
      running install
      running build
      running build_ext
      building 'i2c' library
      error: [WinError 2] The system cannot find the file specified
      [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.

AND, This below, for SGP30:

>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/lib/sgp30/__init__.py", line 1, in <module>
  File "/lib/sgp30/sgp30.py", line 1, in <module>
  File "/lib/smbus2/__init__.py", line 23, in <module>
  File "/lib/smbus2/smbus2.py", line 25, in <module>
  File "/lib/fcntl.py", line 1, in <module>
  File "/lib/ffi.py", line 39, in <module>
  File "/lib/ffi.py", line 43, in DynMod
AttributeError: 'module' object has no attribute 'c_char_p'

I think you’re trying to install Python drivers there which I suspect is why it’s not working, you need MicroPython drivers for the Pico.

Our batteries included MicroPython build has drivers for most breakouts baked in. You can download it from here and there’s a guide on how to install it here.

BME280 example: pimoroni-pico/demo_bme280.py at main Β· pimoroni/pimoroni-pico Β· GitHub
SGP30 example: pimoroni-pico/demo.py at main Β· pimoroni/pimoroni-pico Β· GitHub

1 Like

Hello, Thank you for your response, but I am not able to find the breakout_spg30.py library for importing to run the demo.py

I am getting error like this

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
MicroPython v1.19 on 2022-08-10; Raspberry Pi Pico with RP2040

Type "help()" for more information.
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
  File "<stdin>", line 9, in <module>
RuntimeError: BreakoutSGP30: breakout not found when initialising

What example file are you running? With the Pico its Micro Python, not the Python you may be used to using on a Pi.
It needs to be from here,
pimoroni-pico/micropython/examples/breakout_bme280 at main Β· pimoroni/pimoroni-pico (github.com)
or
pimoroni-pico/micropython/examples/breakout_sgp30 at main Β· pimoroni/pimoroni-pico (github.com)

And you need to make sure its using the correct i2c pins, based on what they are connected to. You also need to be running the custom Pimoroni uf2 file, which will have the libraries needed for Pimoroni products.
Release Version 1.19.6 Β· pimoroni/pimoroni-pico (github.com)

Hello, everytime when I try to install micropython-bme280 version 2.1.3 (GitHub - SebastianRoll/mpy_bme280_esp8266: Driver for the Bosch BME280 for use with MicroPython on ESP8266 boards) on Thonny Python 3.11.4 I face this error: install micropython-bme280
Error [WinError 2] The system cannot find the file specified. I tried almost everything that was on Google and still nothing. On my seminars at university, same error. Any ideas how to fix this?