I tried to use MQTT approach with a broker, but since Pimoroni Enviro Urban is based on RPI zero W and ESPHome supports all sensors, I wrote a dedicated configuration. The most problematic part was enabling the PM sensor dc/dc converter early enough.
esphome:
name: pimoroni-ext
friendly_name: pimoroni_ext
on_boot:
- priority: 1000 #make sure PM sensor wakes up before the init
then:
- lambda: |-
pinMode(2, OUTPUT); //keep the board power on
digitalWrite(2, HIGH);
delay(100);
pinMode(11, OUTPUT); //enable Boost converter
digitalWrite(11, HIGH);
delay(1000); //wait until DC/DC wakes up
pinMode(10, OUTPUT);
digitalWrite(10, HIGH); //enable sensor
delay(100);
pinMode(9, OUTPUT); //reset sensor
digitalWrite(9, LOW);
delay(100);
digitalWrite(9, HIGH); //un-reset sensor
delay(1000); //wait until PM sensor wakes up
- delay: 2s
rp2040:
board: rpipicow
framework:
# Required until https://github.com/platformio/platform-raspberrypi/pull/36 is merged
platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxxx"
ota:
password: "xxxx"
wifi:
ssid: "xxxx"
password: "xxxx."
# Enable fallback hotspot in case wifi connection fails
ap:
ssid: "Pimoroni-Ext Fallback Hotspot"
password: "xxxxx"
i2c:
- id: bus_a # RTC + QWST + BME280
sda: 4
scl: 5
scan: true
- id: bus_b #pm sensor
sda: 14
scl: 15
scan: true
sensor:
- platform: pmsa003i
setup_priority: -100
i2c_id: bus_b
pm_1_0:
name: "PM1.0"
pm_2_5:
name: "PM2.5"
pm_10_0:
name: "PM10.0"
pmc_0_3:
name: "PMC <0.3µm"
pmc_0_5:
name: "PMC <0.5µm"
pmc_1_0:
name: "PMC <1µm"
pmc_2_5:
name: "PMC <2.5µm"
pmc_5_0:
name: "PMC <5µm"
pmc_10_0:
name: "PMC <10µm"
- platform: bme280
i2c_id: bus_a
temperature:
name: "BME280 Temperature"
oversampling: 16x
pressure:
name: "BME280 Pressure"
humidity:
name: "BME280 Humidity"
address: 0x77
update_interval: 60s
- platform: adc
id: adc_mic_reading
pin: 26
- platform: ct_clamp
sensor: adc_mic_reading
name: "Sound level from MEMS mic"
sample_duration: 10s
update_interval: 60s