combined sourcode for mostly esp8266 sensor iot nodes.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.2 KiB

#ifndef SENSOR_Raingauge_H
#define SENSOR_Raingauge_H
#include "sensordata.h"
#include <Homie.h>
class Sensor_Raingauge
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;
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();
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;