A look at the care required to robustly parse a simple serial protocol.

First two bytes of serial transmission from a PMS5003.

This article looks at some of the bugs discovered in a library for the Plantower PMS5003 particulate matter sensor. This device uses a simple serial interface to send data at low speed to another device. The library sounds trivial to design and implement but it’s remarkably easy to produce a library with protocol parsing flaws.

The Pimoroni Enviro+ FeatherWing board has a connector for the PMS5003. The example code includes a plotting program which can graph the particulate data over time at different rates. The combined plotter program typically terminated with a ChecksumMismatchError exception after a minute or two when…

Kevin J. Walters

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store