Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getBattVoltage returning wrong value - SIM808 and others #369

Closed
Alan2git opened this issue Mar 11, 2020 · 1 comment
Closed

getBattVoltage returning wrong value - SIM808 and others #369

Alan2git opened this issue Mar 11, 2020 · 1 comment

Comments

@Alan2git
Copy link

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

Correct value of VBat

Actual result

Incorrect value, like 55537

AT command log

AT+CBC
AT+CBC:0,40,3974

@SRGDamia1
Copy link
Collaborator

Oops, yup, that's definitely a problem and probably the correct fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants