2021-11-06 18:38:54 +00:00
|
|
|
#ifndef SENSOR_MHZ19B_H
|
|
|
|
#define SENSOR_MHZ19B_H
|
|
|
|
|
|
|
|
#include "sensordata.h"
|
|
|
|
#include <Homie.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <SoftwareSerial.h>
|
|
|
|
#include <MHZ19.h>
|
|
|
|
|
|
|
|
|
|
|
|
class Sensor_MHZ19B
|
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
|
|
|
HomieNode *sensorNode; //reference to HomieNode
|
|
|
|
|
|
|
|
struct sensordata data; //struct values are changed in setup()
|
|
|
|
|
|
|
|
int pin_rx;
|
|
|
|
int pin_tx;
|
|
|
|
|
|
|
|
bool init_ok;
|
|
|
|
|
|
|
|
int mhz19_readValue_reimplemented(Stream *_streamRef, MHZ19 *_mhz19Ref);
|
|
|
|
byte mhz19_getCheckSum(byte* packet);
|
|
|
|
|
|
|
|
bool mhz19_ready;
|
|
|
|
|
|
|
|
MHZ19 *mhz19;
|
|
|
|
SoftwareSerial *mhz19_swSerial;
|
|
|
|
#define BAUD_RATE_MHZ19 9600
|
|
|
|
|
|
|
|
|
2021-11-08 19:21:50 +00:00
|
|
|
#define MHZ19CALIBRATIONTOPIC
|
2021-11-06 18:38:54 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
Sensor_MHZ19B(int prx, int ptx);
|
|
|
|
|
|
|
|
void init();
|
|
|
|
void setSettings(float minchange, unsigned long senddelaymax, unsigned long readdelay);
|
|
|
|
void advertise(HomieNode& p_sensorNode);
|
2021-11-08 19:21:50 +00:00
|
|
|
void sensorloop();
|
2021-11-06 18:38:54 +00:00
|
|
|
|
2021-11-08 19:21:50 +00:00
|
|
|
void calibrateZero();
|
2021-11-06 18:38:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|