openenergymonitor / EmonLib

Electricity monitoring library - install in Arduino IDE's libraries folder then restart the IDE
openenergymonitor.org
GNU Affero General Public License v3.0
589 stars 419 forks source link

Externalize readVcc calibration constant #13

Closed dcarter closed 9 years ago

dcarter commented 9 years ago

Allow user code to override the hard-coded reference voltage calibration constant in function EnergyMonitor::readVcc without them needing to modify EmonLib directly. Per "Calibrating the internal reference voltage" at http://openenergymonitor.org/emon/buildingblocks/calibration.

To use, define your calculated calibration constant in your program prior to importing EmonLib.h. Existing programs will continue to work unchanged, since EmonLib.h will define default value if constant is not already defined.

Example:

define READVCC_CALIBRATION_CONST 1113108L // calculated for a specific Arduino board, update this if using code on a different board

include "EmonLib.h"

glynhudson commented 9 years ago

Great, thanks!