diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp index f5ce161..d9f230c 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp @@ -84,6 +84,9 @@ void CurrentTransformerCard::saveEnergy(){ } void CurrentTransformerCard::loadEnergy(){ this->fram->read(this->framAddress, (uint8_t*)&this->energy, sizeof(this->energy)); + if (this->energy < 0 || isnan(this->energy)) { + this->energy = 0; + } } void CurrentTransformerCard::setEnergyAutoSave(bool autoSave){