Fork of the espurna firmware for `mhsw` switches
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.
 
 
 
 
 
 

40 lines
789 B

/*
EmonLiteESP
Energy Monitor Library for ESP8266 based on EmonLib
Currently only support current sensing
*/
#ifndef EmonLiteESP_h
#define EmonLiteESP_h
#define ADC_BITS 10
#define ADC_COUNTS (1<<ADC_BITS)
typedef unsigned int (*current_c)();
class EnergyMonitor {
public:
void initCurrent(current_c callback, double ref, double ratio);
double getCurrent(unsigned int samples);
byte getPrecision();
void setPrecision(byte precision);
void setReference(double ref);
void setCurrentRatio(double ratio);
void calculatePrecision();
private:
current_c _currentCallback;
double _referenceVoltage;
double _currentRatio;
double _currentMidPoint;
double _currentFactor;
byte _precision;
double _multiplier;
};
#endif