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

  1. /*
  2. EmonLiteESP
  3. Energy Monitor Library for ESP8266 based on EmonLib
  4. Currently only support current sensing
  5. */
  6. #ifndef EmonLiteESP_h
  7. #define EmonLiteESP_h
  8. #define ADC_BITS 10
  9. #define ADC_COUNTS (1<<ADC_BITS)
  10. typedef unsigned int (*current_c)();
  11. class EnergyMonitor {
  12. public:
  13. void initCurrent(current_c callback, double ref, double ratio);
  14. double getCurrent(unsigned int samples);
  15. byte getPrecision();
  16. void setPrecision(byte precision);
  17. void setReference(double ref);
  18. void setCurrentRatio(double ratio);
  19. void calculatePrecision();
  20. private:
  21. current_c _currentCallback;
  22. double _referenceVoltage;
  23. double _currentRatio;
  24. double _currentMidPoint;
  25. double _currentFactor;
  26. byte _precision;
  27. double _multiplier;
  28. };
  29. #endif