sensoresp/include/sensor_raingauge.h

55 lines
1.2 KiB
C
Raw Normal View History

2021-11-08 19:09:59 +00:00
#ifndef SENSOR_Raingauge_H
#define SENSOR_Raingauge_H
#include "sensordata.h"
#include <Homie.h>
class Sensor_Raingauge
{
private:
HomieNode *sensorNode; //reference to HomieNode
int pin;
struct sensordata data; //struct values are changed in setup()
unsigned long raingauge_lasttimereset=0;
bool raingauge_idleflag=true;
#define RAINGAUGE_DEBOUNCETIME 1000
bool init_ok;
//value in [mm] or [L/m^2]
//#define RAINGAUGE_FLIPAMOUNT 0.38888 //how much mm rain (L/m^2) per gauge flip. mL (rain to flip) / A (opening area)
//was 0.69292 until 201702
/* Calibration:
* Test1: 1000mL -> 259 Flips
* Test2: 1000mL -> 256 in ca 10min
* -> 3,9mL per Flip, opening diameter =113mm -> A=0,010028749
*/
void updateRaingauge();
public:
Sensor_Raingauge(int p);
void init();
void setSettings(float minchange, unsigned long senddelaymax, unsigned long readdelay);
void advertise(HomieNode& p_sensorNode);
void sensorloop();
uint16_t raingauge_pulsecounter=0; //counted pulses since last reset
unsigned long raingauge_lastpulse_fordebounce=0;
};
#endif