read_sgp30.py 456 B

1234567891011121314151617181920212223
  1. #!/usr/bin/python3
  2. #
  3. # read sgp30 sensor
  4. #
  5. # 2020 05 19 * init /A
  6. # 2022 03 19 + published on https://github.com/InstallAndUse/RPi /A
  7. #
  8. # TODO:
  9. #
  10. #
  11. import busio
  12. import adafruit_sgp30
  13. import board
  14. i2c_bus = busio.I2C(board.SCL, board.SDA, frequency=1000000)
  15. sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c_bus)
  16. print("SGP30 serial #", [hex(i) for i in sgp30.serial])
  17. eCO2, TVOC = sgp30.iaq_measure()
  18. print("eCO2 = %d ppm \t TVOC = %d ppb" % (eCO2, TVOC))