sensoresp/include/sensor_sds018.h

53 lines
1.0 KiB
C
Raw Normal View History

2021-11-07 09:51:27 +00:00
#ifndef SENSOR_SDS018_H
#define SENSOR_SDS018_H
#include "sensordata.h"
#include <Homie.h>
#include <SoftwareSerial.h>
class Sensor_SDS018
{
private:
HomieNode *sensorNode; //reference to HomieNode
struct sensordata data_pm25;
struct sensordata data_pm10;
int pin_rx;
int pin_tx;
bool init_ok;
#define BAUD_RATE_SDS018 9600
SoftwareSerial *sds018_swSerial;
bool sds018_dustok;
unsigned long lastread_sds018=0; //to save last read time for both readings
void readSDS018();
void loop_pm25();
void loop_pm10();
void readSDS018();
public:
Sensor_SDS018(int prx, int ptx);
void init();
void setSettings_pm10(float minchange, unsigned long senddelaymax, unsigned long readdelay);
void setSettings_pm25(float minchange, unsigned long senddelaymax, unsigned long readdelay);
void advertise(HomieNode& p_sensorNode);
void sensorloop();
bool mhz19calibrationHandler(const HomieRange& range, const String& value);
};
#endif