Library available for particulate matter sensor?

I would like to use the PM3015 particulate matter sensor in an Arduino project. Is there a “stand alone” library available for this sensor?

Hi @Jan_B,

The library can be found under the SnifferBike project

Best regards,
Jan

i am trying to the code below. Not quite getting there…
Can you point me in the right direction?

(#)include <PM3015.h>

(#)define PM_SENSOR_STREAM Serial
(#)define PM_SENSOR_RX_PIN (PIN_SERIAL_RX)#define (#)PM_SENSOR_TX_PIN (PIN_SERIAL_TX)

PM3015 pm3015;

void setup() {
Serial.begin(9600);
PM_SENSOR_STREAM.begin(pm3015.getDefaultBaudrate());
pm3015.init(PM_SENSOR_STREAM);

}
void loop() {
// get particulate matter sensor data
uint32_t pm1_0;
uint32_t pm2_5;
uint32_t pm10;
pm3015.openMeasurement();
pm3015.readMeasurements(&pm1_0, &pm2_5, &pm10);
PM_SENSOR_STREAM.end();
Serial.println(pm1_0);
Serial.println(pm2_5);
Serial.println(pm10);
Serial.println(" ");
}

Hi @Jan_B,

What board do you use to communicate with the PM sensor?

I see that you communicate over Serial to the PM sensor

But you also have the debug stream on Serial

You can’t use the same serial for two different things at the same time.

Best regards,
Jan

I am using a regular arduino uno board.
If i cant use the Serial.print command, in what way can i display de sensor readings?

I am not very experienced in handling communication protocols with sensors.

I tried de deconstruct the snifferbike arduino sketch…

Thnx for your efforts

Aaaah blast…the sensor has 3.3v logic right?

Dear @Jan_B,

The sensor has a 5V logic.

On your Arduino UNO you can print to Serial (monitor on your pc) and use other pins to connect to the PM sensor with SoftwareSerial.
https://www.arduino.cc/en/Reference/softwareSerial

Best regards,
Jan

Ok so i now have the code: below. But how do i tell the arduino to take the readings via the softwareSerial (pin 2 and 3) so that they can be stored in the variables?

Thanks for your effort!!

I am trying to build a Ardusniffer that can be used by pupils of my [Technasium] school. And learn along the way…
The ardusniffer will log data to a SD-card.

#include <PM3015.h>
#include <SoftwareSerial.h>

SoftwareSerial pmSerial(2, 3); // RX, TX (rx pin sensor connected to tx pin arduino(3)
// (tx pin sensor connected to rx pin arduino (2)

PM3015 pm3015;

void setup() {
Serial.begin(9600);
pmSerial.begin(9600);
}

void loop() {
//declaring variables to store sensordata
uint32_t pm1_0;
uint32_t pm2_5;
uint32_t pm10;

// take a reading from the sensor and store in variables
pm3015.openMeasurement();
pm3015.readMeasurements(&pm1_0, &pm2_5, &pm10);
pm3015.closeMeasurement();

//print data to the serial monitor
Serial.print("PM1.0: ");
Serial.println(pm1_0);
Serial.print("PM2.5: ");
Serial.println(pm2_5);
Serial.print(“PM10:”);
Serial.println(pm10);
delay(2000);
}

Blast… i overlooked the init command…

New code below! Is it correct to assume that the init command tels the arduino to communicate witg de pm3015?

Serial monitor is nowprinting but PM values are “zero”

#include <PM3015.h>
#include <SoftwareSerial.h>

SoftwareSerial pmSerial(2, 3); // RX, TX (rx pin sensor connected to tx pin arduino(3)
// (tx pin sensor connected to rx pin arduino (2)

PM3015 pm3015;

void setup() {
Serial.begin(9600);
pmSerial.begin(9600);
pm3015.init(pmSerial);
}

void loop() {
//declaring variables to store sensordata
uint32_t pm1_0;
uint32_t pm2_5;
uint32_t pm10;

// take a reading from the sensor and store in variables
pm3015.openMeasurement();
pm3015.readMeasurements(&pm1_0, &pm2_5, &pm10);
//pm3015.closeMeasurement();

//print data to the serial monitor
Serial.print("PM1.0: ");
Serial.println(pm1_0);
Serial.print("PM2.5: ");
Serial.println(pm2_5);
Serial.print(“PM10:”);
Serial.println(pm10);
delay(2000);
}

This code still doesn’t read the PM sensor. Anyone to the rescue?

Still struggling with this library. Maybe Jan could be so kind to point in the right direction. Or are my arduino skills to limited…

Kind regards,

Jan

Dear Jan,

Sorry for the late reply.
Your Arduino skills are good.

I overlooked something in the datasheet.
The UART has a 3.3V logic, the I2C has a 5V/3.3V logic.

In order to get your board working on an Arduino Uno you need to use the I2C.
The Arduino Library we made only support UART.

Best regards,
Jan

@Jan is there a library to use the PM3015 with micropython?

Hi @braulio,

These are all the libraries from the manufacturer:

Best regards,
Jan

Hi @Jan, thanks, I mean a python library to use this PM3015 sensor with a micro-controller running micropython. Are you aware of libraries to read out the output of PM3015 from a microcontroller such as pycom? I found many examples with other sensors that also connected to the serial, but not quite one for the PM3015.

Hi @braulio,

I am not aware of a python library for the PM3015 sensor .

Best regards,
Jan