Smart HomeNews wire, 5 h ago
Claude Code wrote working ESPHome code for an unsupported PM2.5 sensor
Reported by XDA Developers

The author of an XDA Developers article reports that Claude Code wrote a working ESPHome configuration for a sensor the firmware does not support. The sensor is the Winsen ZH03B, a laser dust sensor that reports PM1.0, PM2.5 and PM10 particulate levels. The author wanted the readings in Home Assistant to see how particle levels change while an air purifier runs. According to the author, the setup worked on the first attempt.
ESPHome already handles several common particulate sensors, including Plantower PMSx003 models and the Sensirion SPS30. For those, a user adds a ready-made component to the YAML file and sets the connections. The ZH03B has no native component. A community-made alternative exists, but the author wanted to test whether Claude Code could build a solution from the manufacturer documentation alone. The test was run by one person on one sensor.
The hardware is simple. The sensor needs a 5V supply, and it sends data over UART at 3.3V logic levels. In its default mode it outputs a reading about once a second. The data output connects to the receive pin of an ESP32 board, along with power and ground. The harder part is the data itself. The readings arrive as raw serial packets that generic UART support does not decode. Someone has to find the packet boundaries, pull out the values and reject corrupted data.
The author gave Claude Code the datasheet, the existing ESPHome file and a description of the wiring. The request was to read all three particulate values and expose them to Home Assistant without a separate custom component. According to the article, the datasheet describes 24-byte packets, with fixed bytes marking the start of each packet and a checksum for checking validity. Claude Code used these details to write the receiving logic, find complete packets, extract the values and discard bad ones.
The generated file used ESPHome's built-in UART handling and template sensors to publish the measurements. It also contained a short piece of C++ inside the YAML to process the incoming data. The author says this was the part that would have taken the most time by hand, especially the byte positions and the checksum calculation. After compiling through ESPHome and flashing an ESP32, the sensor reported values as expected, according to the author.
The article uses the test to argue that AI coding tools lower the barrier to ESP32 projects. Tasks such as choosing pins, installing libraries and writing configuration files can be handed to the tool, and logs can be shared when errors appear. The author also suggests the same approach for soil moisture monitors, motion sensors, Bluetooth proxies and displays. Automations and new sensors can be added as a setup grows.
The limits are worth noting. The result comes from one author's test. The article does not include independent verification or a long-term reliability check. The author also warns that Claude Code cannot see the physical setup, so wiring and power requirements must be checked against the hardware documentation. Readers should review generated code before running it on a device that is part of their home. It is not yet known whether the same result holds for other unsupported sensors or other users.
Enjoying this? Get the Smart Home brief
Every Tuesday: what changed in Matter, hubs and security.
✓ Free · seven editions · one click to leave
Original reporting by the sources above. Summary by smart-home.space.