tested on UARt and I2C builds
@@ -7,6 +7,7 @@ from adafruit_esp32spi import adafruit_esp32spi, adafruit_esp32spi_wifimanager
from adafruit_io.adafruit_io import IO_HTTP
from simpleio import map_range
import adafruit_pm25
+import adafruit_bme280
### Configure Sensor ###
# Return environmental sensor readings in degrees Celsius
@@ -14,8 +15,6 @@ USE_CELSIUS = False
# Interval the sensor publishes to Adafruit IO, in minutes
PUBLISH_INTERVAL = 10
-# Set this to True if you are using a PMSA003I breakout, False otherwise
-USE_PMSA003I = False
### WiFi ###
@@ -37,23 +36,24 @@ status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2)
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light)
-# Create i2c object, use 'slow' 100KHz frequency!
-i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
-reset_pin = None
-if USE_PMSA003I:
- import adafruit_bme680
- # Connect to a PM2.5 sensor over I2C
- pm25 = adafruit_pm25.PM25_I2C(i2c, reset_pin)
- # Connect to a BME680 sensor over I2C
- bme_sensor = adafruit_bme680.Adafruit_BME680_I2C(i2c)
-else:
- import adafruit_bme280
# Connect to a PM2.5 sensor over UART
+reset_pin = None
uart = busio.UART(board.TX, board.RX, baudrate=9600)
pm25 = adafruit_pm25.PM25_UART(uart, reset_pin)
- # Connect to a BME280 sensor over I2C
+
+# Create i2c object
+i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)
+
+# Connect to a BME280 over I2C
bme_sensor = adafruit_bme280.Adafruit_BME280_I2C(i2c)
+# Uncomment below for PMSA003I Air Quality Breakout
+# pm25 = adafruit_pm25.PM25_I2C(i2c, reset_pin)
+
+# Uncomment below for BME680
+# import adafruit_bme680
+# bme_sensor = adafruit_bme680.Adafruit_BME680_I2C(i2c)
+
### Sensor Functions ###
def calculate_aqi(pm_sensor_reading):
"""Returns a calculated air quality index (AQI)
