>>> Join Us in the Fight Against Air Pollution

AirGradient Forum

Failed applying Home Assistant ESPHome config to Open Air Outdoor Monitor (Pre-Soldered Kit) - did I brick it?

@Achim_AirGradient @ex-nerd

Recently deployed Home Assistant OS onto a rapsberry-pi and directly connected to it via USB A to USB C on my new Open Air Outdoor Monitor (Pre-Soldered Kit). A few days prior I had this same monitor fully functioning and reporting to the AirGradient Web Dashboard. I had intended to move it to Home Assistant so I could have much longer sensor data retention to spot historical trends over months and years.

I attempted to install the config at https://github.com/ex-nerd/ESPHome-AirGradient/blob/main/air-gradient-open-air.yaml and the subsequent steps found at GitHub - ex-nerd/ESPHome-AirGradient: ESPHome config for AirGradient Air Quality Sensor, but it didn’t complete successfully. Instead it stopped at “Writing at 0x0011d45c… (91 %)” and the Open Air Outdoor Monitor become unresponsive, no longer showing any blue light or other signs of life. Did I brick it? Did I do something wrong from what anyone can tell? I am new to both these air monitors and home assistant OS. Full ESPHome log output of the install attempt below:

INFO ESPHome 2023.8.3
INFO Reading configuration /config/esphome/air-gradient-open-air.yaml...
WARNING GPIO2 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO9 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Core config or version changed, cleaning build files...
INFO Compiling app...
Processing airgradient-open-air-1 (board: esp32-c3-devkitm-1; framework: arduino; platform: platformio/espressif32@5.4.0)
--------------------------------------------------------------------------------
Platform Manager: Installing platformio/espressif32 @ 5.4.0
INFO Installing platformio/espressif32 @ 5.4.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Platform Manager: espressif32@5.4.0 has been installed!
INFO espressif32@5.4.0 has been installed!
Tool Manager: Installing espressif/toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
INFO Installing espressif/toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%          
Tool Manager: toolchain-riscv32-esp@8.4.0+2021r2-patch5 has been installed!
INFO toolchain-riscv32-esp@8.4.0+2021r2-patch5 has been installed!
Tool Manager: Installing platformio/framework-arduinoespressif32 @ ~3.20005.0
INFO Installing platformio/framework-arduinoespressif32 @ ~3.20005.0
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%          
Tool Manager: framework-arduinoespressif32@3.20005.220925 has been installed!
INFO framework-arduinoespressif32@3.20005.220925 has been installed!
Tool Manager: Installing platformio/tool-esptoolpy @ ~1.40400.0
INFO Installing platformio/tool-esptoolpy @ ~1.40400.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: tool-esptoolpy@1.40400.0 has been installed!
INFO tool-esptoolpy@1.40400.0 has been installed!
Library Manager: Installing esphome/AsyncTCP-esphome @ 1.2.2
INFO Installing esphome/AsyncTCP-esphome @ 1.2.2
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: AsyncTCP-esphome@1.2.2 has been installed!
INFO AsyncTCP-esphome@1.2.2 has been installed!
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 2.1.0
INFO Installing esphome/ESPAsyncWebServer-esphome @ 2.1.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: ESPAsyncWebServer-esphome@2.1.0 has been installed!
INFO ESPAsyncWebServer-esphome@2.1.0 has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
Library Manager: Installing esphome/noise-c @ 0.1.4
INFO Installing esphome/noise-c @ 0.1.4
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: noise-c@0.1.4 has been installed!
INFO noise-c@0.1.4 has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
Library Manager: Installing esphome/libsodium @ 1.10018.1
INFO Installing esphome/libsodium @ 1.10018.1
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: libsodium@1.10018.1 has been installed!
INFO libsodium@1.10018.1 has been installed!
Library Manager: Installing bblanchon/ArduinoJson @ 6.18.5
INFO Installing bblanchon/ArduinoJson @ 6.18.5
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: ArduinoJson@6.18.5 has been installed!
INFO ArduinoJson@6.18.5 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40502.0
INFO Installing platformio/tool-scons @ ~4.40502.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: tool-scons@4.40502.0 has been installed!
INFO tool-scons@4.40502.0 has been installed!
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 1.2.2
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 2.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.4
|-- Wire @ 2.0.0
|-- ArduinoJson @ 6.18.5
|-- WiFiClientSecure @ 2.0.0
|-- HTTPClient @ 2.0.0
####removed the compiling lines to fit as much of this log as allowed in this post.  full log is at https://gist.githubusercontent.com/fourg/e13de56f033ab45e1a779d39fdf96e53/raw/bba473f3654b425f4eda7f12b61ccb19a849abfe/gistfile1.txt####
Building /data/airgradient-open-air-1/.pioenvs/airgradient-open-air-1/firmware.bin
Creating esp32c3 image...
Successfully created esp32c3 image.
esp32_create_combined_bin(["/data/airgradient-open-air-1/.pioenvs/airgradient-open-air-1/firmware.bin"], ["/data/airgradient-open-air-1/.pioenvs/airgradient-open-air-1/firmware.elf"])
Wrote 0x1392e0 bytes to file /data/airgradient-open-air-1/.pioenvs/airgradient-open-air-1/firmware-factory.bin, ready to flash to offset 0x0
======================== [SUCCESS] Took 377.25 seconds ========================

********************************************************************************
We found 1.12GB of unnecessary PlatformIO system data (temporary files, unnecessary packages, etc.).
Use `pio system prune --dry-run` to list them or `pio system prune` to save disk space.
INFO Successfully compiled program.
esptool.py v4.6.2
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C3 (revision v0.4)
Features: WiFi, BLE
Crystal is 40MHz
MAC: dc:54:75:ba:a3:58
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00010000 to 0x00139fff...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Compressed 1217248 bytes to 739396...
Writing at 0x0011d45c... (91 %)

I’ve had it fail sometimes in the middle of uploading without any permanent consequences.

You may want to try installing it while connected with a USB Cable. If you are using ESPHome in a Docker container, then you need to connect the AirGradient and then restart the docker container so it can map the USB port into the container.

I use Docker, so I add this in my docker-compose.yml file, under the esphome: header like the other items like image and container_name

      devices: # most of the time we'll be flashing over OTA (that's why we have port 6052), so the devices setting is not needed, only if it's the first flash of a new device
      - /dev/ttyUSB0:/dev/ttyUSB0 # the ESP device has to be mapped to the docker host (in my case it's a VM in ESXi), if it's not mapped, the /dev/ttyUSB0 device will not exist and the container will fail. If the ESP32 is not connected at the time, we need to comment out the devices section.

Flashing over USB has been the most reliable, but the bigger pain to deal with, so if I start having trouble flashing over wifi, then I’ll do the USB method for awhile

Sometimes it also helps to disconnect the PM module so to reduce the voltage load during flashing.