Skip to content

Micropython bme.data.gas_resistance always exact same reading (-1.986394e+07 Ohms) #43

@jjcfrancisco

Description

@jjcfrancisco

Everything is working as it should, except from the gas readings, I always get the exact same number. I am using a generic ESP32 DEVKITV1 (VROOM 32). The sensor is not broken because it works fine when used in a raspberry pi. So it is got to do with Micropython? I followed instructions from here.

This is the code I have used:

import bme680
from i2c import I2CAdapter
import machine

i2c_dev = I2CAdapter(scl=machine.Pin(22),sda=machine.Pin(21))
sensor = bme680.BME680(i2c_device=i2c_dev)

sensor.set_humidity_oversample(bme680.OS_2X)
sensor.set_pressure_oversample(bme680.OS_4X)
sensor.set_temperature_oversample(bme680.OS_8X)
sensor.set_filter(bme680.FILTER_SIZE_3)

sensor.set_gas_status(bme680.ENABLE_GAS_MEAS)
sensor.set_gas_heater_temperature(320)
sensor.set_gas_heater_duration(150)
sensor.select_gas_heater_profile(0)

while True:
    if sensor.get_sensor_data():
        output = "{0:.2f} C,{1:.2f} hPa,{2:.2f} %RH".format(sensor.data.temperature, sensor.data.pressure, sensor.data.humidity)

        if sensor.data.heat_stable:
            print("{0},{1} Ohms".format(output, sensor.data.gas_resistance))

        else:
            print(output)

    time.sleep(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions