Claude Code wrote the ESPHome config for a sensor nobody supports, and it worked the first time

Claude Code wrote the ESPHome config for a sensor nobody supports, and it worked the first time

Published Nov 23, 2026, 7:30 AM EST Anurag is an experienced journalist and author who’s been covering tech for the past 5 years, with a focus on Windows, Android, and Apple. He’s written for sites like Android Police, Neowin, Dexerto, and MakeTechEasier. Anurag’s always pumped about tech and loves getting his hands on the latest gadgets. When he's not procrastinating, you’ll probably find him catching the newest movies in theaters or scrolling through Twitter from his bed. I've been experimenting with ESP32 boards for my Home Assistant setup, and ESPHome is a big reason these projects are so approachable. Most sensors only need a few lines of YAML, a couple of pin assignments, and a firmware flash before their readings show up in Home Assistant. However, things get complicated when you come across a sensor ESPHome doesn't officially support. That's what happened with the Winsen ZH03B, a laser dust sensor I wanted to use to track PM2.5 and other particulate levels at home. ESPHome supports plenty of air-quality sensors, just not this particular model. To get it working, I'd need to interpret the manufacturer's serial communication protocol and write the configuration to process its data. I figured Claude Code could handle that part, so I gave it the datasheet and asked it to put everything together. To my surprise, the configuration worked on the first try. ESPHome supports plenty of sensors, but not this one The hardware was straightforward; the software wasn't The Winsen ZH03B is a laser-based dust sensor that measures airborne particulate matter, including PM1.0, PM2.5, and PM10. I wanted to use it to monitor air quality in my room, particularly to see how particulate levels change when my air purifier is running. It reports actual particle concentrations in µg/m³, which I can track over time in Home Assistant. Connecting the sensor to an ESP32 requires a 5V power supply, and it communicates over UART using 3.3V logic. In its default mode, the sensor sends readings approximately once every second, so you only need to connect its data output to an ESP32's receive pin, along with power and a common ground. There's no complicated wiring or additional hardware involved. ESPHome already supports plenty of particulate matter sensors, including the popular Plantower PMSx003 series and Sensirion SPS30. For these sensors, you can add the appropriate component to your YAML configuration, specify the connections, and ESPHome handles the communication. Unfortunately, the ZH03B doesn't have a native ESPHome component. There is a community-maintained alternative, but I wanted to see if Claude Code could get it working directly from the manufacturer's documentation. The ZH03B transmits its measurements as packets of raw serial data, and ESPHome's generic UART support doesn't automatically know how to interpret them. You need to identify the correct data packets, extract the particulate measurements, verify that the readings aren't corrupted, and publish them as sensors that Home Assistant can understand. That's quite a bit of work for something that would otherwise take a handful of lines in ESPHome. I gave Claude Code the datasheet and let it figure things out From documentation to a working configuration I started by giving Claude Code the ZH03B's datasheet and my existing ESPHome configuration. I explained how the sensor was connected to the ESP32 and asked it to create a configuration that would read all three particulate measurements and make them available in Home Assistant. I also wanted it to work using ESPHome's existing features, without requiring a separate custom component. The datasheet contained most of the information Claude Code needed. The ZH03B transmits its readings in 24-byte data packets, with specific bytes identifying the start of each packet and others containing the actual measurements. It also includes a checksum that can be used to verify whether the received data is valid. Claude Code used these details to write the logic for receiving the data, identifying complete packets, extracting the readings, and discarding corrupted ones. The generated configuration used ESPHome's built-in UART support to communicate with the sensor and template sensors to expose the measurements. It also included a small piece of C++ code within the YAML configuration to handle the data processing. This was exactly the part I would've spent the most time figuring out manually, particularly getting the data positions and checksum calculations right. Once the configuration was ready, I compiled it through ESPHome and flashed it onto the ESP32. To my surprise, everything worked on the first attempt. Claude Code makes ESP32 projects much more accessible You don't need to know everything ESP32 projects involve more than connecting a sensor and getting some readings. Even a basic setup requires figuring out the board's pinout, installing libraries, writing configuration files, and more. ESPHome simplifies a lot of this, but there's still a learning curve, especially if you have little experience with programming or electronics. Claude Code can handle much of that work. You can tell it which ESP32 board and sensors you're using, provide the hardware documentation, and explain what you want to build. It can suggest the wiring connections, generate the ESPHome configuration, and explain how everything works. If something goes wrong during compilation or the ESP32 starts throwing errors, you can share the logs and have Claude Code investigate the problem. It becomes even more useful when you're building projects for Home Assistant. For instance, you could build a soil moisture monitor and have Claude Code configure the sensor, expose its readings to Home Assistant, and create an automation that notifies you when your plant needs watering. Since Claude Code can work directly with your existing configuration files, you can also ask it to modify automations and add sensors as your setup grows. The same approach works for motion sensors, physical buttons, Bluetooth proxies, displays, and plenty of other ESP32 projects. Claude makes it easier to tinker You'll still need to verify the wiring and power requirements against the hardware documentation since Claude Code can't physically inspect your setup. However, it takes away much of the programming and troubleshooting involved, making these projects far more accessible to people who have never worked with microcontrollers before.

Original Source

Read the full article at Xda-developers →

KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.