diff --git a/examples/GPS_NMEA_Output/GPS_NMEA_Output.ino b/examples/GPS_NMEA_Output/GPS_NMEA_Output.ino new file mode 100644 index 0000000..8c8eebf --- /dev/null +++ b/examples/GPS_NMEA_Output/GPS_NMEA_Output.ino @@ -0,0 +1,132 @@ +/** + * @file GPS_NMEA_Output.ino + * @author Lewis He (lewishe@outlook.com) + * @license MIT + * @copyright Copyright (c) 2024 Shenzhen Xin Yuan Electronic Technology Co., Ltd + * @date 2024-08-13 + * + */ +#include "utilities.h" + +#define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb +#define SerialAT Serial1 + +// See all AT commands, if wanted +#define DUMP_AT_COMMANDS + +#include +#include +#ifdef DUMP_AT_COMMANDS // if enabled it requires the streamDebugger lib +#include +StreamDebugger debugger(SerialAT, Serial); +TinyGsm modem(debugger); +#else +TinyGsm modem(SerialAT); +#endif + + +uint32_t check_interval = 0; + +void displayInfo(); + +void setup() +{ + Serial.begin(115200); + // Turn on DC boost to power on the modem +#ifdef BOARD_POWERON_PIN + pinMode(BOARD_POWERON_PIN, OUTPUT); + digitalWrite(BOARD_POWERON_PIN, HIGH); +#endif + + // Set modem reset pin ,reset modem + pinMode(MODEM_RESET_PIN, OUTPUT); + digitalWrite(MODEM_RESET_PIN, !MODEM_RESET_LEVEL); delay(100); + digitalWrite(MODEM_RESET_PIN, MODEM_RESET_LEVEL); delay(2600); + digitalWrite(MODEM_RESET_PIN, !MODEM_RESET_LEVEL); + + // Turn on modem + pinMode(BOARD_PWRKEY_PIN, OUTPUT); + digitalWrite(BOARD_PWRKEY_PIN, LOW); + delay(100); + digitalWrite(BOARD_PWRKEY_PIN, HIGH); + delay(1000); + digitalWrite(BOARD_PWRKEY_PIN, LOW); + + // Set modem baud + SerialAT.begin(115200, SERIAL_8N1, MODEM_RX_PIN, MODEM_TX_PIN); + + Serial.println("Start modem..."); + delay(3000); + + /* + * During testing, it was found that there may be a power outage. + Add a loop detection here. When the GPS timeout does not start, + resend the AT to check if the modem is online + * */ + Serial.print("Modem starting..."); + int retry = 0; + while (!modem.testAT(1000)) { + Serial.println("."); + if (retry++ > 10) { + digitalWrite(BOARD_PWRKEY_PIN, LOW); + delay(100); + digitalWrite(BOARD_PWRKEY_PIN, HIGH); + delay(1000); //Ton = 1000ms ,Min = 500ms, Max 2000ms + digitalWrite(BOARD_PWRKEY_PIN, LOW); + retry = 0; + } + } + Serial.println(); + + delay(200); + + + Serial.println("Before running, please check whether the version you purchased supports the GPS function. Regardless of whether the PCB contains an antenna connector, the A7670G does not include a built-in GPS function. If the A7670G you purchased claims to support GPS, then please run examples/GPSShield\n\n"); + Serial.println("Before running, please check whether the version you purchased supports the GPS function. Regardless of whether the PCB contains an antenna connector, the A7670G does not include a built-in GPS function. If the A7670G you purchased claims to support GPS, then please run examples/GPSShield\n\n"); + Serial.println("Before running, please check whether the version you purchased supports the GPS function. Regardless of whether the PCB contains an antenna connector, the A7670G does not include a built-in GPS function. If the A7670G you purchased claims to support GPS, then please run examples/GPSShield\n\n"); + + + retry = 15; + Serial.println("Enabling GPS/GNSS/GLONASS"); + while (!modem.enableGPS(MODEM_GPS_ENABLE_GPIO)) { + Serial.print("."); + if (retry-- <= 0) { + Serial.println("GPS startup failed. Please check whether the board you ordered contains GPS function."); delay(1000); + } + } + + Serial.println(); + Serial.println("GPS Enabled"); + + modem.setGPSBaud(115200); + + modem.setGPSMode(3); //GPS + BD + + modem.configNMEASentence(1, 1, 1, 1, 1, 1); + + modem.setGPSOutputRate(1); + + modem.enableNMEA(); + + Serial.println("Next you should see NMEA sentences in the serial monitor"); + +} + +void loop() +{ + if (millis() > check_interval) { + if (modem.isEnableGPS() == false) { + Serial.println("Restart GPS!"); + modem.enableGPS(); + delay(3000); + } + check_interval = millis() + 15000; + } + + while (SerialAT.available()) { + int ch = SerialAT.read(); + Serial.write(ch); + } + +} + diff --git a/examples/GPS_NMEA_Output/utilities.h b/examples/GPS_NMEA_Output/utilities.h new file mode 100644 index 0000000..9f71d3e --- /dev/null +++ b/examples/GPS_NMEA_Output/utilities.h @@ -0,0 +1,243 @@ +/** + * @file utilities.h + * @author Lewis He (lewishe@outlook.com) + * @license MIT + * @copyright Copyright (c) 2023 Shenzhen Xin Yuan Electronic Technology Co., Ltd + * @date 2023-11-15 + * + */ + +#pragma once + +// Note: +// When using ArduinoIDE, you must select a corresponding board type. +// If you don’t know which board type you have, please click on the link to view it. +// 使用ArduinoIDE ,必须选择一个对应的板型 ,如果你不知道你的板型是哪种,请点击链接进行查看 + +// Products Link:https://www.lilygo.cc/products/t-sim-a7670e +// #define LILYGO_T_A7670 + + +// T-Call-A767X V1.0 and V1.1 have different Pinmaps and cannot be used universally. +// #define LILYGO_T_CALL_A7670_V1_0 + +// T-Call-A767X V1.0 and V1.1 have different Pinmaps and cannot be used universally. +// #define LILYGO_T_CALL_A7670_V1_1 + +//! SIM7672G and SIM7670G are exactly the same, except for the name change +// #define LILYGO_T_SIM767XG_S3 + +// #define LILYGO_T_A7608X + +// #define LILYGO_T_A7608X_S3 + +// #define LILYGO_T_A7608X_DC_S3 + + + + + +#if defined(LILYGO_T_A7670) + +#define MODEM_BAUDRATE (115200) +#define MODEM_DTR_PIN (25) +#define MODEM_TX_PIN (26) +#define MODEM_RX_PIN (27) +// The modem boot pin needs to follow the startup sequence. +#define BOARD_PWRKEY_PIN (4) +#define BOARD_ADC_PIN (35) +// The modem power switch must be set to HIGH for the modem to supply power. +#define BOARD_POWERON_PIN (12) +#define MODEM_RING_PIN (33) +#define MODEM_RESET_PIN (5) +#define BOARD_MISO_PIN (2) +#define BOARD_MOSI_PIN (15) +#define BOARD_SCK_PIN (14) +#define BOARD_SD_CS_PIN (13) +#define BOARD_BAT_ADC_PIN (35) +#define MODEM_RESET_LEVEL HIGH +#define SerialAT Serial1 + +#define MODEM_GPS_ENABLE_GPIO (-1) + + +#ifndef TINY_GSM_MODEM_A7670 +#define TINY_GSM_MODEM_A7670 +#endif + +// It is only available in V1.4 version. In other versions, IO36 is not connected. +#define BOARD_SOLAR_ADC_PIN (36) + + +#elif defined(LILYGO_T_CALL_A7670_V1_0) +#define MODEM_BAUDRATE (115200) +#define MODEM_DTR_PIN (14) +#define MODEM_TX_PIN (26) +#define MODEM_RX_PIN (25) +// The modem boot pin needs to follow the startup sequence. +#define BOARD_PWRKEY_PIN (4) +#define BOARD_LED_PIN (12) +// There is no modem power control, the LED Pin is used as a power indicator here. +#define BOARD_POWERON_PIN (BOARD_LED_PIN) +#define MODEM_RING_PIN (13) +#define MODEM_RESET_PIN (27) +#define MODEM_RESET_LEVEL LOW +#define SerialAT Serial1 + + +#define MODEM_GPS_ENABLE_GPIO (-1) + + +#ifndef TINY_GSM_MODEM_A7670 +#define TINY_GSM_MODEM_A7670 +#endif + +#elif defined(LILYGO_T_CALL_A7670_V1_1) + +#define MODEM_BAUDRATE (115200) +#define MODEM_DTR_PIN (32) +#define MODEM_TX_PIN (27) +#define MODEM_RX_PIN (26) +// The modem boot pin needs to follow the startup sequence. +#define BOARD_PWRKEY_PIN (4) +#define BOARD_LED_PIN (13) +// There is no modem power control, the LED Pin is used as a power indicator here. +#define BOARD_POWERON_PIN (BOARD_LED_PIN) +#define MODEM_RING_PIN (33) +#define MODEM_RESET_PIN (5) +#define MODEM_RESET_LEVEL LOW +#define SerialAT Serial1 + +#define MODEM_GPS_ENABLE_GPIO (-1) + +#ifndef TINY_GSM_MODEM_A7670 +#define TINY_GSM_MODEM_A7670 +#endif + +#elif defined(LILYGO_T_SIM767XG_S3) +#define MODEM_BAUDRATE (115200) +#define MODEM_DTR_PIN (9) +#define MODEM_TX_PIN (11) +#define MODEM_RX_PIN (10) +// The modem boot pin needs to follow the startup sequence. +#define BOARD_PWRKEY_PIN (18) +#define BOARD_LED_PIN (12) +// There is no modem power control, the LED Pin is used as a power indicator here. +#define BOARD_POWERON_PIN (BOARD_LED_PIN) +#define MODEM_RING_PIN (3) +#define MODEM_RESET_PIN (17) +#define MODEM_RESET_LEVEL LOW +#define SerialAT Serial1 + +#define BOARD_BAT_ADC_PIN (4) +#define BOARD_SOLAR_ADC_PIN (5) +#define BOARD_MISO_PIN (47) +#define BOARD_MOSI_PIN (14) +#define BOARD_SCK_PIN (21) +#define BOARD_SD_CS_PIN (13) + +#ifndef TINY_GSM_MODEM_SIM7672 +#define TINY_GSM_MODEM_SIM7672 +#endif + +#define MODEM_GPS_ENABLE_GPIO (4) + + +#elif defined(LILYGO_T_A7608X) + +#define MODEM_BAUDRATE (115200) +#define MODEM_DTR_PIN (25) +#define MODEM_TX_PIN (26) +#define MODEM_RX_PIN (27) +// The modem boot pin needs to follow the startup sequence. +#define BOARD_PWRKEY_PIN (4) +#define BOARD_BAT_ADC_PIN (35) +// The modem power switch must be set to HIGH for the modem to supply power. +#define BOARD_POWERON_PIN (12) //T-A7608-V2 is onboard led +#define MODEM_RING_PIN (33) +#define MODEM_RESET_PIN (5) //T-A7608-V2 no connection +#define BOARD_MISO_PIN (2) +#define BOARD_MOSI_PIN (15) +#define BOARD_SCK_PIN (14) +#define BOARD_SD_CS_PIN (13) + +#define MODEM_RESET_LEVEL HIGH +#define SerialAT Serial1 + + +#ifndef TINY_GSM_MODEM_A7608 +#define TINY_GSM_MODEM_A7608 +#endif + +// only version v1.1 or V2 has solar adc pin +#define BOARD_SOLAR_ADC_PIN (34) + + +// 127 is defined in GSM as the AUXVDD index +#define MODEM_GPS_ENABLE_GPIO (127) + +#elif defined(LILYGO_T_A7608X_S3) + +#define MODEM_BAUDRATE (115200) +#define MODEM_DTR_PIN (7) +#define MODEM_TX_PIN (17) +#define MODEM_RX_PIN (18) +// The modem boot pin needs to follow the startup sequence. +#define BOARD_PWRKEY_PIN (15) +#define BOARD_BAT_ADC_PIN (4) +// The modem power switch must be set to HIGH for the modem to supply power. +// #define BOARD_POWERON_PIN (12) +#define MODEM_RING_PIN (6) +#define MODEM_RESET_PIN (16) +#define BOARD_MISO_PIN (47) +#define BOARD_MOSI_PIN (14) +#define BOARD_SCK_PIN (21) +#define BOARD_SD_CS_PIN (13) + +#define MODEM_RESET_LEVEL LOW +#define SerialAT Serial1 + +#ifndef TINY_GSM_MODEM_A7608 +#define TINY_GSM_MODEM_A7608 +#endif + +// only version v1.1 has solar adc pin +#define BOARD_SOLAR_ADC_PIN (3) + +// 127 is defined in GSM as the AUXVDD index +#define MODEM_GPS_ENABLE_GPIO (127) + +#elif defined(LILYGO_T_A7608X_DC_S3) + +#define MODEM_DTR_PIN (5) +#define MODEM_RX_PIN (42) +#define MODEM_TX_PIN (41) +// The modem boot pin needs to follow the startup sequence. +#define BOARD_PWRKEY_PIN (38) +#define MODEM_RING_PIN (6) +#define MODEM_RESET_PIN (40) +#define MODEM_RTS_PIN (1) +#define MODEM_CTS_PIN (2) + +#define MODEM_RESET_LEVEL LOW +#define SerialAT Serial1 + +#ifndef TINY_GSM_MODEM_A7608 +#define TINY_GSM_MODEM_A7608 +#endif + +// 127 is defined in GSM as the AUXVDD index +#define MODEM_GPS_ENABLE_GPIO (127) + +#else +#error "Use ArduinoIDE, please open the macro definition corresponding to the board above " +#endif + + + + + + + + + diff --git a/firmware/README.MD b/firmware/README.MD index 9de8145..9b9f87c 100644 --- a/firmware/README.MD +++ b/firmware/README.MD @@ -7,14 +7,14 @@ # 1️⃣ Quickly diagnose hardware -| Product | GPS Test Firmware | Network Test Firmware | -| ------------------ | ----------------------------------------------- | ---------------------------------------- | -| [T-A7670X][1] | [firmware](./T-A7670X_GPS_NMEA_Parse.bin) | [firmware](./T-A7670X_Network.bin) | -| [T-Call-A7670X][2] | [firmware](./T-Call-A7670X_GPS_NMEA_Parse.bin) | [firmware](./T-Call-A7670X_Network.bin) | -| [T-A7608][3] | [firmware](./T-A7608X_GPS_NMEA_Parse.bin) | [firmware](./T-A7608X_Network.bin) | -| [T-A7608-DC-S3][4] | [firmware](./T-A7608X-DC-S3_GPS_NMEA_Parse.bin) | [firmware](./T-A7608X-DC-S3_Network.bin) | -| [T-A7608-S3][5] | [firmware](./T-A7608X-S3_GPS_NMEA_Parse.bin) | [firmware](./T-A7608X-S3_Network.bin) | -| [T-SIM7672G-S3][6] | [firmware](./T-SIM7672G_GPS_NMEA_Parse.bin) | [firmware](./T-SIM7672G_Network.bin) | +| Product | GPS Test Firmware | Network Test Firmware | NMEA Output | +| ----------------------- | ----------------------------------------------- | ---------------------------------------- | ------------------------------------------------------------- | +| [T-A7670X][1] | [firmware](./T-A7670X_GPS_NMEA_Parse.bin) | [firmware](./T-A7670X_Network.bin) | [firmware](./GPS_NMEA_Output_T-A7608X-DC-S3_20240813.bin) | +| [T-Call-A7670X V1.1][2] | [firmware](./T-Call-A7670X_GPS_NMEA_Parse.bin) | [firmware](./T-Call-A7670X_Network.bin) | [firmware](./GPS_NMEA_Output_T-Call-A7670X-V1-1_20240813.bin) | +| [T-A7608][3] | [firmware](./T-A7608X_GPS_NMEA_Parse.bin) | [firmware](./T-A7608X_Network.bin) | [firmware](./GPS_NMEA_Output_T-A7608X_20240813.bin) | +| [T-A7608-DC-S3][4] | [firmware](./T-A7608X-DC-S3_GPS_NMEA_Parse.bin) | [firmware](./T-A7608X-DC-S3_Network.bin) | [firmware](./GPS_NMEA_Output_T-A7608X-DC-S3_20240813.bin) | +| [T-A7608-S3][5] | [firmware](./T-A7608X-S3_GPS_NMEA_Parse.bin) | [firmware](./T-A7608X-S3_Network.bin) | [firmware](./GPS_NMEA_Output_T-A7608X-S3_20240813.bin) | +| [T-SIM7672G-S3][6] | [firmware](./T-SIM7672G_GPS_NMEA_Parse.bin) | [firmware](./T-SIM7672G_Network.bin) | [firmware](./GPS_NMEA_Output_T-SIM7672G_20240813.bin) | [1]: https://www.lilygo.cc/products/t-sim-a7670e [2]: https://www.lilygo.cc diff --git a/platformio.ini b/platformio.ini index 67255c9..fec645a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -17,7 +17,7 @@ ; !default_envs 必须选择一个对应的板型 ,如果你不知道你的板型是哪种,请点击链接进行查看 ; https://www.lilygo.cc/products/t-sim-a7670e -default_envs = T-A7670X +; default_envs = T-A7670X ; https://www.lilygo.cc/products/t-call-v1-4 ; default_envs = T-Call-A7670X-V1-0 @@ -45,13 +45,14 @@ default_envs = T-A7670X ; !src_dir 必须选择一个需要进行编译的示例,只能有一行有效,其余需要注释 ; src_dir = examples/ATdebug -src_dir = examples/ModemPowerOff +; src_dir = examples/ModemPowerOff ; src_dir = examples/Blynk_Console ; src_dir = examples/GPSShield ; src_dir = examples/HttpClient ; src_dir = examples/HttpsClient ; src_dir = examples/GPS_BuiltIn ; src_dir = examples/GPS_NMEA_Parse +src_dir = examples/GPS_NMEA_Output ; src_dir = examples/MqttClient ; src_dir = examples/VoiceCalls ; src_dir = examples/ModemSleep