Pico W, can't install BME688 sensor 4-in-1

Done! Thanks for this.
Here’s the code that worked for me, in case anyone else finds useful.
Fellow newbs: Check your SDA and SCL links and code carefully to make sure they correspond to the correct GPIO. See also the bit about 12C below.
This is probably a tiny step for you folks but a major one for me :D Thanks for your help!

from breakout_bme68x import BreakoutBME68X, STATUS_HEATER_STABLE
from pimoroni_i2c import PimoroniI2C
import time

PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}

i2c = PimoroniI2C(**PINS_PICO_EXPLORER)
bme = BreakoutBME68X(i2c)

temperature, pressure, humidity, gas_resistance, status, gas_index, meas_index = bme.read(heater_temp=250, heater_duration=50)

print("Temperature: {:.2f}°C".format(temperature))
print("Pressure: {:.2f}Pa".format(pressure))
print("Humidity: {:.2f}%".format(humidity))
print("Gas Resistance: {:.2f} Ohms".format(gas_resistance))
print("Status: {}".format(status))
print("Gas Index: {}".format(gas_index))
print("Measurement Index: {}".format(meas_index))

while True:
    temperature, pressure, humidity, gas, status, _, _ = bme.read()
    heater = "Stable" if status & STATUS_HEATER_STABLE else "Unstable"
    print("{:0.2f}c, {:0.2f}Pa, {:0.2f}%, {:0.2f} Ohms, Heater: {}".format(
        temperature, pressure, humidity, gas, heater))

About I2C communication protocol:
I2C, or Inter-Integrated Circuit, is a communication protocol commonly used to connect multiple devices on a bus. It uses a master-slave architecture and supports multiple peripherals or sensors connected to the same two-wire bus. The two main lines in I2C are SDA (data line) and SCL (clock line).

In the context of your code, i2c is an object that represents the I2C bus on your microcontroller (in this case, a Raspberry Pi Pico) and is used to communicate with I2C devices, such as the BME688 sensor. The i2c object is typically an instance of a class that provides methods for sending and receiving data over the I2C bus.

For example, in the line i2c = PimoroniI2C(**PINS_PICO_EXPLORER), you are initializing an i2c object using the PimoroniI2C class with the specified pins (SDA and SCL) from the PINS_PICO_EXPLORER dictionary.

This i2c object is then used when initializing the BreakoutBME68X object, allowing you to communicate with the BME688 sensor over the I2C bus.

PS thanks also for soldering advice @alphanumeric

1 Like

If you click the Preformatted Text </> button, and past your code in there. It will retain the formating, indents etc. It will make it a lot easier to read, and easier for somebody to copy and use it. ;)

1 Like

Ops, forgot to say the most important part, well done. Now you can have some fun coding etc. =)

1 Like