diff --git a/README.md b/README.md index 47a631a..f8b68dd 100644 --- a/README.md +++ b/README.md @@ -67,13 +67,15 @@ GPS/GNSS | ✔¹ | 🅧 | ◌¹ | 🅧 | - SIMCom SIM800 series (SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868) - SIMCom SIM900 series (SIM900A, SIM900D, SIM908, SIM968) - AI-Thinker A6, A6C, A7, A20 -- U-blox SARA U201 (*alpha*) - ESP8266 (AT commands interface, similar to GSM modems) - Digi XBee WiFi and Cellular (using XBee command mode) - Neoway M590 +- U-blox SARA U201 ***(alpha)*** +- Quectel BG96 ***(alpha)*** ### Supported boards/modules -- Arduino MKR GSM 1400 (*alpha*) +- Arduino MKR GSM 1400 ***(alpha)*** +- RAK WisLTE ***(alpha)*** - GPRSbee - Microduino GSM - Adafruit FONA (Mini Cellular GSM Breakout) @@ -82,7 +84,8 @@ GPS/GNSS | ✔¹ | 🅧 | ◌¹ | 🅧 | - ... other modules, based on supported modems More modems may be supported later: -- [ ] Quectel M10, M95, UG95 +- [ ] Quectel M10, M35, M95, UG95 +- [ ] Sequans Monarch LTE Cat M1/NB1 - [ ] SIMCom SIM5320, SIM5360, SIM5216, SIM7xxx - [ ] Telit GL865 - [ ] ZTE MG2639 @@ -113,6 +116,13 @@ If you have found TinyGSM to be useful in your work, research or company, please 3. Check if serial connection is working (Hardware Serial is recommended) Send an ```AT``` command using [this sketch](tools/AT_Debug/AT_Debug.ino) 4. Ensure that GSM antenna is firmly attached + +If you have any issues: + + 1. Read the whole README (you're looking at it!) + 2. Try running the Diagnostics sketch + 3. Check for [**highlighted topics here**](https://github.com/vshymanskyy/TinyGSM/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22for+reference%22+) + 4. If you have a question, post it in [Gitter chat](https://gitter.im/tinygsm) ## How does it work? @@ -133,8 +143,9 @@ Use this sketch to diagnose your SIM card and GPRS connection: ### Ensure stable data & power connection -This actually solves stability problems in **many** cases: -- Provide a good, [stable power supply](https://github.com/vshymanskyy/TinyGSM/wiki/Powering-GSM-module) (up to 2A and specific voltage according to your module documentation) +Most modules require up to 2A and specific voltage - according to the module documentation. +So this actually solves stability problems in **many** cases: +- Provide a good stable power supply. Read about [**powering your module**](https://github.com/vshymanskyy/TinyGSM/wiki/Powering-GSM-module). - Keep your wires as short as possible - Consider soldering them for a stable connection - Do not put your wires next to noisy signal sources (buck converters, antennas, oscillators etc.) @@ -143,6 +154,7 @@ This actually solves stability problems in **many** cases: When using ```SoftwareSerial``` (on Uno, Nano, etc), the speed **115200** may not work. Try selecting **57600**, **38400**, or even lower - the one that works best for you. +In some cases **9600** is unstable, but using **38400** helps, etc. Be sure to set correct TX/RX pins in the sketch. Please note that not every Arduino pin can serve as TX or RX pin. **Read more about SoftSerial options and configuration [here](https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html) and [here](https://www.arduino.cc/en/Reference/SoftwareSerial).** diff --git a/examples/AllFunctions/AllFunctions.ino b/examples/AllFunctions/AllFunctions.ino index 38cb365..d175ec2 100644 --- a/examples/AllFunctions/AllFunctions.ino +++ b/examples/AllFunctions/AllFunctions.ino @@ -126,6 +126,12 @@ void loop() { String gsmLoc = modem.getGsmLocation(); DBG("GSM location:", gsmLoc); + // This is only supported on SIMxxx series + String gsmTime = modem.getGSMDateTime(DATE_TIME); + DBG("GSM Time:", gsmTime); + String gsmDate = modem.getGSMDateTime(DATE_DATE); + DBG("GSM Date:", gsmDate); + String ussd_balance = modem.sendUSSD("*111#"); DBG("Balance (USSD):", ussd_balance); diff --git a/keywords.txt b/keywords.txt index 33f98c4..b6b4b10 100644 --- a/keywords.txt +++ b/keywords.txt @@ -24,3 +24,6 @@ factoryReset KEYWORD2 ####################################### # Literals (LITERAL1) ####################################### +DATE_FULL LITERAL1 +DATE_TIME LITERAL1 +DATE_DATE LITERAL1 diff --git a/src/TinyGsmClientSIM800.h b/src/TinyGsmClientSIM800.h index 13a62a9..a841a66 100644 --- a/src/TinyGsmClientSIM800.h +++ b/src/TinyGsmClientSIM800.h @@ -39,6 +39,11 @@ enum RegStatus { REG_UNKNOWN = 4, }; +enum DateTime { + DATE_FULL = 0, + DATE_TIME = 1, + DATE_DATE = 2 +}; class TinyGsmSim800 { @@ -307,6 +312,13 @@ public: if (!testAT()) { return false; } + //Enable Local Time Stamp for getting network time + sendAT(GF("+CLTS=1")); + if (waitResponse(10000L) != 1) { + return false; + } + sendAT(GF("&W")); + waitResponse(); sendAT(GF("+CFUN=0")); if (waitResponse(10000L) != 1) { return false; @@ -719,6 +731,32 @@ public: return res; } + /* + * Time functions + */ + String getGSMDateTime(DateTime format) { + sendAT(GF("+CCLK?")); + if (waitResponse(2000L, GF(GSM_NL "+CCLK: \"")) != 1) { + return ""; + } + + String res; + + switch(format) { + case DATE_FULL: + res = stream.readStringUntil('"'); + break; + case DATE_TIME: + streamSkipUntil(','); + res = stream.readStringUntil('"'); + break; + case DATE_DATE: + res = stream.readStringUntil(','); + break; + } + return res; + } + /* * Battery functions */