Browse Source

Added battery and temperature functions

v_master
Sara Damiano 5 years ago
parent
commit
880c4614e4
14 changed files with 332 additions and 38 deletions
  1. +3
    -0
      examples/AllFunctions/AllFunctions.ino
  2. +1
    -0
      examples/WebClient/WebClient.ino
  3. +31
    -2
      src/TinyGsmClientA6.h
  4. +35
    -5
      src/TinyGsmClientBG96.h
  5. +11
    -0
      src/TinyGsmClientESP8266.h
  6. +4
    -2
      src/TinyGsmClientM590.h
  7. +47
    -5
      src/TinyGsmClientM95.h
  8. +35
    -5
      src/TinyGsmClientMC60.h
  9. +32
    -4
      src/TinyGsmClientSIM7000.h
  10. +35
    -5
      src/TinyGsmClientSIM800.h
  11. +31
    -3
      src/TinyGsmClientSaraR4.h
  12. +41
    -4
      src/TinyGsmClientSequansMonarch.h
  13. +11
    -1
      src/TinyGsmClientUBLOX.h
  14. +15
    -2
      src/TinyGsmClientXBee.h

+ 3
- 0
examples/AllFunctions/AllFunctions.ino View File

@ -111,6 +111,7 @@ void loop() {
// To skip it, call init() instead of restart() // To skip it, call init() instead of restart()
DBG("Initializing modem..."); DBG("Initializing modem...");
if (!modem.restart()) { if (!modem.restart()) {
// if (!modem.init()) {
DBG("Failed to restart modem, delaying 10s and retrying"); DBG("Failed to restart modem, delaying 10s and retrying");
delay(3000); delay(3000);
// restart autobaud in case GSM just rebooted // restart autobaud in case GSM just rebooted
@ -122,10 +123,12 @@ void loop() {
String modemInfo = modem.getModemInfo(); String modemInfo = modem.getModemInfo();
DBG("Modem:", modemInfo); DBG("Modem:", modemInfo);
#if TINY_GSM_USE_GPRS
// Unlock your SIM card with a PIN if needed // Unlock your SIM card with a PIN if needed
if ( GSM_PIN && modem.getSimStatus() != 3 ) { if ( GSM_PIN && modem.getSimStatus() != 3 ) {
modem.simUnlock(GSM_PIN); modem.simUnlock(GSM_PIN);
} }
#endif
#if TINY_GSM_USE_WIFI #if TINY_GSM_USE_WIFI
SerialMon.print(F("Setting SSID/password...")); SerialMon.print(F("Setting SSID/password..."));


+ 1
- 0
examples/WebClient/WebClient.ino View File

@ -116,6 +116,7 @@ void setup() {
// To skip it, call init() instead of restart() // To skip it, call init() instead of restart()
SerialMon.println("Initializing modem..."); SerialMon.println("Initializing modem...");
modem.restart(); modem.restart();
// modem.init();
String modemInfo = modem.getModemInfo(); String modemInfo = modem.getModemInfo();
SerialMon.print("Modem: "); SerialMon.print("Modem: ");


+ 31
- 2
src/TinyGsmClientA6.h View File

@ -482,7 +482,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE; String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Battery functions
* Battery & temperature functions
*/ */
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE;
@ -492,12 +492,41 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
} }
stream.readStringUntil(',');
streamSkipUntil(','); // Skip battery charge status
// Read battery charge level
int res = stream.readStringUntil('\n').toInt(); int res = stream.readStringUntil('\n').toInt();
// Wait for final OK
waitResponse();
return res;
}
uint8_t getBattChargeState()
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
// Read battery charge status
int res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse(); waitResponse();
return res; return res;
} }
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
chargeState = stream.readStringUntil(',').toInt();
percent = stream.readStringUntil('\n').toInt();
// Wait for final OK
waitResponse();
return true;
}
float getTemperature() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Client related functions * Client related functions
*/ */


+ 35
- 5
src/TinyGsmClientBG96.h View File

@ -436,7 +436,7 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE; String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Battery functions
* Battery & temperature functions
*/ */
// Use: float vBatt = modem.getBattVoltage() / 1000.0; // Use: float vBatt = modem.getBattVoltage() / 1000.0;
@ -445,10 +445,11 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return 0; return 0;
} }
streamSkipUntil(','); // Skip
streamSkipUntil(','); // Skip
streamSkipUntil(','); // Skip battery charge status
streamSkipUntil(','); // Skip battery charge level
// return voltage in mV
uint16_t res = stream.readStringUntil(',').toInt(); uint16_t res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse(); waitResponse();
return res; return res;
} }
@ -458,12 +459,41 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
} }
stream.readStringUntil(',');
streamSkipUntil(','); // Skip battery charge status
// Read battery charge level
int res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse();
return res;
}
uint8_t getBattChargeState()
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
// Read battery charge status
int res = stream.readStringUntil(',').toInt(); int res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse(); waitResponse();
return res; return res;
} }
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
chargeState = stream.readStringUntil(',').toInt();
percent = stream.readStringUntil(',').toInt();
milliVolts = stream.readStringUntil('\n').toInt();
// Wait for final OK
waitResponse();
return true;
}
float getTemperature() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Client related functions * Client related functions
*/ */


+ 11
- 0
src/TinyGsmClientESP8266.h View File

@ -325,6 +325,17 @@ TINY_GSM_MODEM_MAINTAIN_LISTEN()
return TinyGsmIpFromString(getLocalIP()); return TinyGsmIpFromString(getLocalIP());
} }
/*
* Battery & temperature functions
*/
// Use: float vBatt = modem.getBattVoltage() / 1000.0;
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE;
int8_t getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE;
uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE;
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) TINY_GSM_ATTR_NOT_AVAILABLE;
float getTemperature() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Client related functions * Client related functions
*/ */


+ 4
- 2
src/TinyGsmClientM590.h View File

@ -400,12 +400,14 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE; String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Battery functions
* Battery & temperature functions
*/ */
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE;
int8_t getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE; int8_t getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE;
uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE;
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) TINY_GSM_ATTR_NOT_AVAILABLE;
float getTemperature() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Client related functions * Client related functions


+ 47
- 5
src/TinyGsmClientM95.h View File

@ -484,7 +484,7 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE; String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Battery functions
* Battery & temperature functions
*/ */
// Use: float vBatt = modem.getBattVoltage() / 1000.0; // Use: float vBatt = modem.getBattVoltage() / 1000.0;
@ -493,10 +493,11 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return 0; return 0;
} }
streamSkipUntil(','); // Skip
streamSkipUntil(','); // Skip
streamSkipUntil(','); // Skip battery charge status
streamSkipUntil(','); // Skip battery charge level
// return voltage in mV
uint16_t res = stream.readStringUntil(',').toInt(); uint16_t res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse(); waitResponse();
return res; return res;
} }
@ -506,12 +507,53 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
} }
stream.readStringUntil(',');
streamSkipUntil(','); // Skip battery charge status
// Read battery charge level
int res = stream.readStringUntil(',').toInt(); int res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse(); waitResponse();
return res; return res;
} }
uint8_t getBattChargeState()
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
// Read battery charge status
int res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse();
return res;
}
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
chargeState = stream.readStringUntil(',').toInt();
percent = stream.readStringUntil(',').toInt();
milliVolts = stream.readStringUntil('\n').toInt();
// Wait for final OK
waitResponse();
return true;
}
float getTemperature(uint16_t &milliVolts = 0) {
sendAT(GF("+QTEMP"));
if (waitResponse(GF(GSM_NL "+QTEMP:")) != 1) {
return (float)-9999;
}
streamSkipUntil(','); // Skip mode
// Read charge of thermistor
milliVolts = stream.readStringUntil(',').toInt();
float temp = stream.readStringUntil('\n').toFloat();
// Wait for final OK
waitResponse();
return temp;
}
/* /*
* Client related functions * Client related functions
*/ */


+ 35
- 5
src/TinyGsmClientMC60.h View File

@ -503,7 +503,7 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
} }
/* /*
* Battery functions
* Battery & temperature functions
*/ */
// Use: float vBatt = modem.getBattVoltage() / 1000.0; // Use: float vBatt = modem.getBattVoltage() / 1000.0;
@ -512,10 +512,11 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return 0; return 0;
} }
streamSkipUntil(','); // Skip
streamSkipUntil(','); // Skip
streamSkipUntil(','); // Skip battery charge status
streamSkipUntil(','); // Skip battery charge level
// return voltage in mV
uint16_t res = stream.readStringUntil(',').toInt(); uint16_t res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse(); waitResponse();
return res; return res;
} }
@ -525,12 +526,41 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
} }
stream.readStringUntil(',');
streamSkipUntil(','); // Skip battery charge status
// Read battery charge level
int res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse();
return res;
}
uint8_t getBattChargeState()
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
// Read battery charge status
int res = stream.readStringUntil(',').toInt(); int res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse(); waitResponse();
return res; return res;
} }
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
chargeState = stream.readStringUntil(',').toInt();
percent = stream.readStringUntil(',').toInt();
milliVolts = stream.readStringUntil('\n').toInt();
// Wait for final OK
waitResponse();
return true;
}
float getTemperature() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Client related functions * Client related functions
*/ */


+ 32
- 4
src/TinyGsmClientSIM7000.h View File

@ -735,9 +735,9 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return 0; return 0;
} }
streamSkipUntil(','); // Skip
streamSkipUntil(','); // Skip
streamSkipUntil(','); // Skip battery charge status
streamSkipUntil(','); // Skip battery charge level
// return voltage in mV
uint16_t res = stream.readStringUntil(',').toInt(); uint16_t res = stream.readStringUntil(',').toInt();
waitResponse(); waitResponse();
return res; return res;
@ -748,12 +748,40 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
} }
stream.readStringUntil(',');
streamSkipUntil(','); // Skip battery charge status
// Read battery charge level
int res = stream.readStringUntil(',').toInt();
waitResponse();
return res;
}
uint8_t getBattChargeState()
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
// Read battery charge status
int res = stream.readStringUntil(',').toInt(); int res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse(); waitResponse();
return res; return res;
} }
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
chargeState = stream.readStringUntil(',').toInt();
percent = stream.readStringUntil(',').toInt();
milliVolts = stream.readStringUntil('\n').toInt();
// Wait for final OK
waitResponse();
return true;
}
float getTemperature() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Client related functions * Client related functions
*/ */


+ 35
- 5
src/TinyGsmClientSIM800.h View File

@ -647,7 +647,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
} }
/* /*
* Battery functions
* Battery & temperature functions
*/ */
// Use: float vBatt = modem.getBattVoltage() / 1000.0; // Use: float vBatt = modem.getBattVoltage() / 1000.0;
@ -656,10 +656,11 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return 0; return 0;
} }
streamSkipUntil(','); // Skip
streamSkipUntil(','); // Skip
streamSkipUntil(','); // Skip battery charge status
streamSkipUntil(','); // Skip battery charge level
// return voltage in mV
uint16_t res = stream.readStringUntil(',').toInt(); uint16_t res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse(); waitResponse();
return res; return res;
} }
@ -669,12 +670,41 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) { if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false; return false;
} }
stream.readStringUntil(',');
streamSkipUntil(','); // Skip battery charge status
// Read battery charge level
int res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse();
return res;
}
uint8_t getBattChargeState()
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
// Read battery charge status
int res = stream.readStringUntil(',').toInt(); int res = stream.readStringUntil(',').toInt();
// Wait for final OK
waitResponse(); waitResponse();
return res; return res;
} }
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
sendAT(GF("+CBC?"));
if (waitResponse(GF(GSM_NL "+CBC:")) != 1) {
return false;
}
chargeState = stream.readStringUntil(',').toInt();
percent = stream.readStringUntil(',').toInt();
milliVolts = stream.readStringUntil('\n').toInt();
// Wait for final OK
waitResponse();
return true;
}
float getTemperature() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Client related functions * Client related functions
*/ */


+ 31
- 3
src/TinyGsmClientSaraR4.h View File

@ -490,7 +490,7 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
} }
/* /*
* Battery functions
* Battery & temperature functions
*/ */
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE;
@ -501,9 +501,37 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
return 0; return 0;
} }
int res = stream.readStringUntil(',').toInt();
int8_t res = stream.readStringUntil(',').toInt();
int8_t percent = res*20; // return is 0-5
// Wait for final OK
waitResponse(); waitResponse();
return res;
return percent;
}
uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE;
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
percent = getBattPercent();
return true;
}
float getTemperature() {
// First make sure the temperature is set to be in celsius
sendAT(GF("+UTEMP=0")); // Would use 1 for Fahrenheit
if (waitResponse() != 1) {
return (float)-9999;
}
sendAT(GF("+UTEMP?"));
if (waitResponse(GF(GSM_NL "+UTEMP:")) != 1) {
return (float)-9999;
}
streamSkipUntil(','); // Skip units (C/F)
int16_t res = stream.readStringUntil('\n').toInt();
float temp = -9999;
if (res != 655355) {
temp = ((float)res)/10;
}
return temp;
} }
/* /*


+ 41
- 4
src/TinyGsmClientSequansMonarch.h View File

@ -422,7 +422,6 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
String getLocalIP() { String getLocalIP() {
sendAT(GF("+CGPADDR=3")); sendAT(GF("+CGPADDR=3"));
if (waitResponse(10000L, GF("+CGPADDR: 3,\"")) != 1) { if (waitResponse(10000L, GF("+CGPADDR: 3,\"")) != 1) {
return ""; return "";
} }
@ -476,12 +475,28 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
/* /*
* Battery functions
* Battery & temperature functions
*/ */
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE;
int getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE;
int8_t getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE;
uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE;
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) TINY_GSM_ATTR_NOT_AVAILABLE;
float getTemperature() {
sendAT(GF("+SMDTH"));
if (waitResponse(10000L, GF("+SMDTH: ")) != 1) {
return (float)-9999;
}
String res;
if (waitResponse(1000L, res) != 1) {
return (float)-9999;
}
if (res.indexOf("ERROR") >=0) {
return (float)-9999;
}
return res.toFloat();
}
protected: protected:
@ -569,6 +584,28 @@ protected:
return 0; return 0;
} }
return len; return len;
// uint8_t nAttempts = 5;
// bool gotPrompt = false;
// while (nAttempts > 0 && !gotPrompt) {
// sendAT(GF("+SQNSSEND="), mux);
// if (waitResponse(5000, GF(GSM_NL "> ")) == 1) {
// gotPrompt = true;
// }
// nAttempts--;
// delay(50);
// }
// if (gotPrompt) {
// stream.write((uint8_t*)buff, len);
// stream.write((char)0x1A);
// stream.flush();
// if (waitResponse() != 1) {
// DBG("### no OK after send");
// return 0;
// }
// return len;
// }
// return 0;
} }


+ 11
- 1
src/TinyGsmClientUBLOX.h View File

@ -489,7 +489,7 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
} }
/* /*
* Battery functions
* Battery & temperature functions
*/ */
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE;
@ -505,6 +505,16 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED()
return res; return res;
} }
uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE;
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) {
percent = getBattPercent();
return true;
}
// This would only available for a small number of modules in this group (TOBY-L)
float getTemperature() TINY_GSM_ATTR_NOT_IMPLEMENTED;
/* /*
* Client related functions * Client related functions
*/ */


+ 15
- 2
src/TinyGsmClientXBee.h View File

@ -782,12 +782,25 @@ public:
String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE; String getGsmLocation() TINY_GSM_ATTR_NOT_AVAILABLE;
/* /*
* Battery functions
* Battery & temperature functions
*/ */
// Use: float vBatt = modem.getBattVoltage() / 1000.0;
uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE; uint16_t getBattVoltage() TINY_GSM_ATTR_NOT_AVAILABLE;
int8_t getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE; int8_t getBattPercent() TINY_GSM_ATTR_NOT_AVAILABLE;
uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE;
bool getBattStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) TINY_GSM_ATTR_NOT_AVAILABLE;
float getTemperature() {
String res = sendATGetString(GF("TP"));
if (res == "") {
return (float)-9999;
}
char buf[5] = {0,};
res.toCharArray(buf, 5);
int8_t intRes = (int8_t)strtol(buf, 0, 16); // degrees Celsius displayed in 8-bit two's complement format.
return (float)intRes;
}
/* /*
* Client related functions * Client related functions


Loading…
Cancel
Save