Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jjcfrancisco opened this issue Jun 4, 2021 · 0 comments

Comments

@jjcfrancisco
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant