Arduino Uno: PM2.5 sensing revisited


Arduino Uno code

The code is a variation of the code in the original blog post, but now it uses Software Serial.

One might observe the change in the flush_portOne routine, which now expects an array of 32 bytes. As the sensor doesn’t issue any string terminator. A 10-second timeout was also implemented, unlike in the original code. This routine is required as the sensor starts in auto-send mode, and we want to put in in manual mode.

Even with those changes, there are some minor quirks and unsolved things. In particular, when the reset button of the Arduino Uno is pressed, the sensor becomes unresponsive. I assume this has something to do with the way SoftwareSerial initializes, as this won’t happen with hardware serial. The only way to make the sensor work is to briefly remove 5V power from the sensor and reapply it before the timeout expires.

1 2


  1. Hello,

    I’d really like to try and do this, but I can’t see the code referred to on this or the other post – would you be able to send to me? Also – how long does this take to put together?


Leave A Reply

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