Done
## What type of issues is this?
[ ] Request to support a new module
[ ] Bug or problem compiling the library
[ x] Bug or issue with library functionality (ie, sending data over TCP/IP)
What are you working with?
Main processor board: ESP32
Modem: SIM808
TinyGSM version: 0.10.1
Code:
volt=modem.getBattVoltage(); // -> returns garbage value in volt variable
The problem lies in TinyGsmBattery.tpp module, procedure getBatVoltageImpl()
uint16_t getBattVoltageImpl() {
thisModem().sendAT(GF("+CBC"));
if (thisModem().waitResponse(GF("+CBC:")) != 1) { return 0; }
thisModem().streamSkipUntil(','); // Skip battery charge status
thisModem().streamSkipUntil(','); // Skip battery charge level
// return voltage in mV
//***** Here is the Problem ****
uint16_t res = thisModem().streamGetIntBefore(',');
//**** Should be changed by : ****
uint16_t res = thisModem().streamGetIntBefore('\n');
// At least for SIM800 and 900 series, dunno for other modems
// Wait for final OK
thisModem().waitResponse();
return res;
}
Scenario, steps to reproduce
With proposed change I get it. However, the change must be checked with other modems
### Expected result
[ ] Bug or problem compiling the library [ x] Bug or issue with library functionality (ie, sending data over TCP/IP)
What are you working with?
Main processor board: ESP32 Modem: SIM808 TinyGSM version: 0.10.1 Code: volt=modem.getBattVoltage(); // -> returns garbage value in volt variable
The problem lies in TinyGsmBattery.tpp module, procedure getBatVoltageImpl() uint16_t getBattVoltageImpl() { thisModem().sendAT(GF("+CBC")); if (thisModem().waitResponse(GF("+CBC:")) != 1) { return 0; } thisModem().streamSkipUntil(','); // Skip battery charge status thisModem().streamSkipUntil(','); // Skip battery charge level // return voltage in mV //***** Here is the Problem **** uint16_t res = thisModem().streamGetIntBefore(',');
//**** Should be changed by : **** uint16_t res = thisModem().streamGetIntBefore('\n');
// At least for SIM800 and 900 series, dunno for other modems
}
Scenario, steps to reproduce
With proposed change I get it. However, the change must be checked with other modems ### Expected resultCorrect value of VBat
Actual result
Incorrect value, like 55537 ### AT command logAT+CBC AT+CBC:0,40,3974