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]
|
|
|
|
|
2024-03-26 13:44:41 +00:00
|
|
|
//#define RAINGAUGE_FLIPAMOUNT 0.38888 //how much mm rain (L/m^2) per gauge flip. (rain to flip) [L] / A (opening area) [m^2]
|
2021-11-08 19:09:59 +00:00
|
|
|
//was 0.69292 until 201702
|
2024-03-26 13:44:41 +00:00
|
|
|
/* Calibration 2018:
|
2021-11-08 19:09:59 +00:00
|
|
|
* Test1: 1000mL -> 259 Flips
|
|
|
|
* Test2: 1000mL -> 256 in ca 10min
|
2024-03-26 13:44:41 +00:00
|
|
|
* -> 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
|
2021-11-08 19:09:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
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
|
|
|
|
|