Claude Code Generated a Working ESPHome Configuration for the Unsupported Winsen ZH03B Sensor
An experiment using Claude Code turned a Winsen ZH03B datasheet into an ESPHome configuration that worked on the first flash to an ESP32, despite the sensor lacking a native ESPHome component.
The Winsen ZH03B is a laser dust sensor that measures PM1.0, PM2.5 and PM10. It communicates with an ESP32 over UART, but ESPHome does not officially support the model with a native component.
The configuration was created from the sensor’s datasheet and an existing ESPHome setup. It uses ESPHome’s built-in UART support to process the sensor’s 24-byte data packets, validate them with a checksum and expose the three particulate readings through template sensors in Home Assistant. A small C++ section inside the YAML handles the data processing.
After compiling and flashing the configuration to an ESP32, the setup reportedly worked on the first attempt. The approach could reduce some of the programming needed for unsupported hardware, although wiring and power requirements still need to be checked against the sensor documentation.
The sensor uses a 5V supply and 3.3V logic for UART communication, and its default mode sends readings approximately once per second.