fix nan value from eeprom

This commit is contained in:
MkLHX
2019-07-17 17:40:57 +02:00
parent 18912a9184
commit 28422510c9
4 changed files with 5 additions and 5 deletions

View File

@@ -14,7 +14,7 @@
"type": "git",
"url": "https://github.com/GreenPonik/DFRobot_ESP_PH_WITH_ADC_BY_GREENPONIK.git"
},
"version": "1.2.2",
"version": "1.2.3",
"license": "LGPL-2.1",
"frameworks": ["arduino"],
"platforms": ["espressif32"]

View File

@@ -10,7 +10,7 @@
"type": "git",
"url": "https://github.com/GreenPonik/DFRobot_ESP_PH_WITH_ADC_BY_GREENPONIK.git"
},
"version": "1.2.2",
"version": "1.2.3",
"license": "LGPL-2.1",
"frameworks": "arduino",
"platforms": "espressif32"

View File

@@ -1,5 +1,5 @@
name=DFRobot_ESP_PH_WITH_ADC_BY_GREENPONIK
version=1.2.2
version=1.2.3
author=GREENPONIK
maintainer=Greenponik <contact@greenponik.com>
sentence=Update from DFROBOT library for ESP32+ADC compatibility

View File

@@ -40,7 +40,7 @@ void DFRobot_ESP_PH_WITH_ADC::begin(int EepromStartAddress)
this->_eepromStartAddress = EepromStartAddress;
//check if calibration values (neutral and acid) are stored in eeprom
this->_neutralVoltage = EEPROM.readFloat(this->_eepromStartAddress); //load the neutral (pH = 7.0)voltage of the pH board from the EEPROM
if (this->_neutralVoltage == float())
if (this->_neutralVoltage == float() || isnan(this->_neutralVoltage))
{
this->_neutralVoltage = PH_7_AT_25; // new EEPROM, write typical voltage
EEPROM.writeFloat(this->_eepromStartAddress, this->_neutralVoltage);
@@ -48,7 +48,7 @@ void DFRobot_ESP_PH_WITH_ADC::begin(int EepromStartAddress)
}
this->_acidVoltage = EEPROM.readFloat(this->_eepromStartAddress + (int)sizeof(float)); //load the acid (pH = 4.0) voltage of the pH board from the EEPROM
if (this->_acidVoltage == float())
if (this->_acidVoltage == float() || isnan(this->_acidVoltage))
{
this->_acidVoltage = PH_4_AT_25; // new EEPROM, write typical voltage
EEPROM.writeFloat(this->_eepromStartAddress + (int)sizeof(float), this->_acidVoltage);