Re: i2c pyb or machine for sgp30 adafruit sensor?
Posted: Sun Jun 20, 2021 7:42 am
In case anyone else wants to use this sensor. This post was very useful for getting the SGP30 working with the current Micropython version on an esp8266. A quick summary:
Use the driver from here: https://github.com/alexmrqt/micropython-sgp30
modify line 54 from to this:
Use the driver from here: https://github.com/alexmrqt/micropython-sgp30
modify line 54 from
Code: Select all
_SGP30_FEATURESET = const(0x0020)
Code: Select all
_SGP30_FEATURESET = const(0x0022)
Code: Select all
import machine
import adafruit_sgp30
i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4), freq=100000)
i2c.init(scl=machine.Pin(5), sda=machine.Pin(4))
sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c)
co2eq, tvoc = sgp30.iaq_measure()
print("CO2eq = %d ppm \t TVOC = %d ppb" % (co2eq, tvoc))