Hacking The ZH03B Laser Particle Sensor

Laser particle detectors are a high-tech way for quantifying whats floating around in the air. With a fan, a laser, and a sensitive photodetector, they can measure smoke and other particulates in real-time. Surprisingly, they are also fairly cheap, going for less than $20 USD on some import sites. They just need a bit of encouragement to do our bidding.

[Dave Thompson] picked up a ZH03B recently and wanted to get it working with his favorite sensor platform, Mycodo. With a sprinkling of hardware and software, he was able to get these cheap laser particle sensors working on his Raspberry Pi, and his work was ultimately incorporated upstream into Mycodo. Truly living the open source dream.

The ZH03B has PWM and UART output modes, but [Dave] focused his attention on UART. With the addition of a CP2102 USB-UART adapter, he was able to connect it to his Pi and Mac, but still needed to figure out what it was saying. He eventually came up with some Python code that lets you use the sensor both as part of a larger network or service like Mycodo and as a stand-alone device.

His basic Python script (currently only tested on Linux and OS X), loops continuously and gives a running output of the PM1, PM2.5, and PM10 measurements. These correspond to particles with a diameter of 1, 2.5, and 10 micrometers respectively. If you want to plug the sensor into another service, the Python library is a bit more mature and lets you do things like turn off the ZH03B’s fan to save power.

These sensors are getting cheap enough that you can build distributed networks of them, a big breakthrough for crowd-sourced environmental monitoring; especially with hackers writing open source code to support them.

23 thoughts on “Hacking The ZH03B Laser Particle Sensor

  1. For those interested there was a big conference about Air Quality Sensor last month.
    All the proceedings are available here: https://asic.aqrc.ucdavis.edu/current-speakers
    Lots of interesting details about about how to calibrate them and improve their accuracy (they can be sensitive to change of relative humidity).
    There are many similar low cost network around the world. Most of them are built around the PMS5007 (from Plantower)

        1. You can get some pretty good measurement from a regular smoke detector. See this for example: berkeleyair.com/wp-content/publications/UCB-PATS_Specifications.pdf
          But the sensor in the article (or the PMS5003) are Particle Counter (they count individual particle) not photometer like in the smoke detectors who detect a bunch of particle at the same time. So the particle counters can usually detect much lower concentration.
          They also are active (they draw air), smoke detector are usually passive.

    1. These types of sensors are used in aspirated (forced air sampling, or active) smoke detection systems.
      https://www.coloradoci.com/bin-pdf/5270/ParticleSize.pdf
      https://www.orrprotection.com/blog/air-sampling-smoke-detection-system

      This may not be the same sensor, but it is of the same type and may be useful in that application. I am actually looking to get one of these to play around with for the same purpose.

      The neat thing with aspirated systems is that you can use piping systems to sample the air in zones in a large area like a datacenter, or in the case of a home rooms vs floors.

    1. Yes. The title is very misleading.
      Whilst the article is interesting and shows what the sensor is capablel of and the pre-exisiting resource for it, the title should have been:
      Talking to the ZH03B particle sensor

      I was expecting a hack potentially showing how to improve the results the sensor produces, or something equally “hacky” that it doesn’t do out of the box.

      Here is a nice article on how to use it with arduino and code:
      https://www.dfrobot.com/wiki/index.php/PM2.5_laser_dust_sensor_SKU:SEN0177
      Long overdue getting one of these and controlling my air filtering hepa fan with it.
      But backlog etc…

    1. That is a major point for the project – useful data like how fast does my HEPA filter clean up the room air after all the windows are closed. At that point I start measuring the CO2 levels to figure when they need to open again. In my case the HEPA filter can clean some pretty nasty air to double and single digit concentrations in 15-20 minutes and CO2 takes a couple of hours to accumulate to levels that would have me wanting to ventilate to clear CO2.

      The sensor measures the density of small particles. This is a reasonable explanation of what this is all about:

      https://www.epa.gov/pm-pollution/particulate-matter-pm-basics

Leave a Reply to mikeCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.