Skip to content

Instantly share code, notes, and snippets.

@benevpi
Created April 22, 2020 15:51
Show Gist options
  • Save benevpi/36621dbc0560e048873231287843b0e9 to your computer and use it in GitHub Desktop.
Save benevpi/36621dbc0560e048873231287843b0e9 to your computer and use it in GitHub Desktop.
enviroplus featherwing gauge example
import time
import board
from pimoroni_envirowing import gas
from pimoroni_envirowing import screen
from gauge import Gauge
import displayio
import terminalio
import busio
import adafruit_bme280
from pimoroni_pms5003 import PMS5003
pms5003 = PMS5003()
i2c = busio.I2C(board.SCL, board.SDA)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, address=0x76)
from adafruit_display_text import label
display=screen.Screen()
interval = 1 # uncomment for 1 reading per second
# colours for the plotter are defined as rgb values in hex, with 2 bytes for each colour
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF
gauge_pm10 = Gauge(0,88, 40, 40, value_label="pm10:")
gauge_pm2 = Gauge(0,44, 40, 40, value_label="pm2.5:")
guage_humidity = Gauge(0,100, 40, 40, value_label="hum%:")
gauge_pm10.y = 40
guage_humidity.x=80
group = displayio.Group(scale=1)
group.append(gauge_pm10)
group.append(gauge_pm2)
group.append(guage_humidity)
display.show(group)
while True:
reading = pms5003.read()
pm2 = reading.data[1]
pm10 = reading.data[2]
print(pm2)
gauge_pm10.update(pm10)
gauge_pm2.update(pm2)
guage_humidity.update(bme280.humidity)
time.sleep(interval)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment