sensoresp/include/sensor_raingauge.h

60 lines
1.3 KiB
C++

#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. (rain to flip) [L] / A (opening area) [m^2]
//was 0.69292 until 201702
/* Calibration 2018:
* Test1: 1000mL -> 259 Flips
* Test2: 1000mL -> 256 in ca 10min
* -> 3,9mL per Flip, opening diameter =113mm -> A=0,010028749 m²
* -D RAINGAUGE_FLIPAMOUNT=0.29914
*
* Calibration 2024:
* 60 Flips = 100mL => 1.66mL / Flip. Opening area 110mm*50mm = 0,005 m²
* -D RAINGAUGE_FLIPAMOUNT=0.332
*/
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