A comparative test of two particle sensors


Arduino code for sensors comparison

The code I propose in this blog post reads the output of the two sensors and writes the data on an SD card in CSV format. On each line in the log file we will write:

  • the current value of millis()
  • PM2.5 data returned by SDS011
  • PM2.5 data returned by HPMA115S0
  • PM10 data returned by SDS011
  • PM10 data returned by HPMA115S0

The code is written in such way that the log file is opened before every log entry, then closed. Thus, the risk of corrupting the logged data if greatly reduced.

A new line in the log file is added at an interval specified by the log_delay variable. In my code I set log_delay = 15000; thus a new line is added every 15 seconds.

However,  this approach comes with a quirk: the SDS011 sends data every second. Turning off the sensor between measurements is not a good option; the sensor needs to suck fresh air to provide meaningful results. This is especially important if a hose is used on the air intake.

So, in the code, for a time interval equal to log_delay I will just read the data from the SDS011 and throw it away, I will keep only the readings that occur at log_delay intervals.

For the HPMA115So things are simpler. I only have to disable auto send mode, configure the sensor in measurement mode (active, the fan is on), and then trigger measurements on demand.

This how the log file should look:

millis()SDS011 PM2.5HPMA115S0 PM2.5SDS011 PM10HPMA115S0 PM10


Now all I have to do is wait for a day or so for enough data to accumulate, and then to perform the comparison of the two sensors. A follow-up is coming soon…


1 2

Leave A Reply

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