diff --git a/TinyGsmClientSIM800.h b/TinyGsmClientSIM800.h index 4083267..b33c2b9 100644 --- a/TinyGsmClientSIM800.h +++ b/TinyGsmClientSIM800.h @@ -512,6 +512,19 @@ public: /* * Battery functions */ + // Use: float vBatt = modem.getBattVoltage() / 1000.0; + uint16_t getBattVoltage() { + sendAT(GF("+CBC")); + if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { + return 0; + } + streamSkipUntil(','); // Skip + streamSkipUntil(','); // Skip + + uint16_t res = stream.readStringUntil(',').toInt(); + waitResponse(); + return res; + } private: int modemConnect(const char* host, uint16_t port, uint8_t mux) {