GuL NovaFitness is a library for the Arduino-Framework to work with the novafitness particulate matter sensors like SDS011 or SDS198
- Arduino Library Manager (Recommended)
- Download or clone this repository into your arduino libraries directory
-
Include module
#include <SDS011.h> // Or one of the other moduls
-
Create a instance with the serial port it uses
//The modul uses the namespace GuL. Instead of Serial1 you can use Serial, Serial2, or own instantiated HardwareSerial or SoftwareSerial
GuL::SDS011 sds(Serial1);
-
In
setup()
, basic setup of the modul.void setup() { sds.setToPassiveReporting(); // Or // sds.setToActiveReporting(); // For power saving reasons, not neccessary sds.sleep(); }
-
In
loop()
of the sketch, run the object's loop() method.void loop() { // If in passive reporting mode sds.poll(); // A bit delay, so the sensor can respond, not really neccessary delay(20); // Read the actual data sds.read(); // Fetch the specific data channel, eg. int pm10 = sds.getPM10(); }
SDS011(Stream& stream);
std::string getSensorName() { return _name; }
Return the device name (Like SDS011 or SDS198)
bool poll();
Polls the next dataframe from the sensor, the call is only neccessary if the sensor is in passive reporting mode
bool pollFirmwareVersion();
Polls the firmware version from the sensor
bool pollReportingMode();
Polls the reporting mode from the sensor
bool pollWorkingMode();
Polls the working mode from the sensor
bool pollWorkingPeriod();
Polls the working period from the sensor
virtual bool read();
Reads the incomming data frame, validates and unpack
bool sleep();
Switch the sensor to sleep mode (Saves power consumption)
bool wakeup();
Wake the sensor up (also wakes up if there is a poll() call)
bool setToActiveReporting();
Like tha name says, set the sensor in active reporting mode, so each second a data frame will be send automatically
bool setToPassiveReporting();
Set the sensor in passive reporting mode, each data frame have do be polled
float getPM2_5_STD();
Get the last received PM2.5 (µg/m³) concentration under the assumption of a standarized particle. Returns a negative number if there is no data
float getPM10_STD();
Get the last received PM10 (µg/m³) concentration under the assumption of a standarized particle. Returns a negative number if there is no data
float getPM100();
Get the last received PM10, (µg/m³) concentration under the assumption of a standarized particle. Returns a negative number if there is no data
NovaFitness::FirmwareVersion getVersion();
Get the last received sensor firmware version. Returns a negative number if there is no data. (Only newer devices return a version)
uint16_t getID();
Get the last received sensor id
NovaFitness::ReportingMode getReportingMode();
Get the actual reporting mode
NovaFitness::WorkMode getWorkMode();
Get the actual working mode
- Write tests