void setup()
{
// Set console baud rate
SerialMon.begin(115200);
delay(10);
// Set GSM module baud rate
SerialAT.begin(UART_BAUD, SERIAL_8N1, MODEM_RX, MODEM_TX);
/*
The indicator light of the board can be controlled
*/
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
/*
MODEM_PWRKEY IO:4 The power-on signal of the modulator must be given to it,
otherwise the modulator will not reply when the command is sent
*/
pinMode(MODEM_PWRKEY, OUTPUT);
digitalWrite(MODEM_PWRKEY, HIGH);
delay(300); //Need delay
digitalWrite(MODEM_PWRKEY, LOW);
/*
MODEM_FLIGHT IO:25 Modulator flight mode control,
need to enable modulator, this pin must be set to high
*/
pinMode(MODEM_FLIGHT, OUTPUT);
digitalWrite(MODEM_FLIGHT, HIGH);
// Restart takes quite some time
// To skip it, call init() instead of restart()
DBG("Initializing modem...");
if (!modem.init()) {
DBG("Failed to restart modem, delaying 10s and retrying");
return;
}
if TINY_GSM_TEST_GPRS
/* Preferred mode selection : AT+CNMP
2 – Automatic
13 – GSM Only
14 – WCDMA Only
38 – LTE Only
59 – TDS-CDMA Only
9 – CDMA Only
10 – EVDO Only
19 – GSM+WCDMA Only
22 – CDMA+EVDO Only
48 – Any but LTE
60 – GSM+TDSCDMA Only
63 – GSM+WCDMA+TDSCDMA Only
67 – CDMA+EVDO+GSM+WCDMA+TDSCDMA Only
39 – GSM+WCDMA+LTE Only
51 – GSM+LTE Only
54 – WCDMA+LTE Only
*/
String ret;
ret= modem.setNetworkMode(2);
DBG("setNetworkMode:", ret);
//https://github.com/vshymanskyy/TinyGSM/pull/405
uint8_t mode = modem.getGNSSMode();
DBG("GNSS Mode:", mode);
/**
* CGNSSMODE: <gnss_mode>,<dpo_mode>
* This command is used to configure GPS, GLONASS, BEIDOU and QZSS support mode.
* gnss_mode:
* 0 : GLONASS
* 1 : BEIDOU
* 2 : GALILEO
* 3 : QZSS
* dpo_mode :
* 0 disable
* 1 enable
*/
modem.setGNSSMode(2, 1);
light_sleep(1);
String name = modem.getModemName();
DBG("Modem Name:", name);
String modemInfo = modem.getModemInfo();
DBG("Modem Info:", modemInfo);
// Unlock your SIM card with a PIN if needed
if (GSM_PIN && modem.getSimStatus() != 3) {
modem.simUnlock(GSM_PIN);
}
DBG("Waiting for network...");
if (!modem.waitForNetwork(600000L)) {
light_sleep(10);
return;
}
if (modem.isNetworkConnected()) {
DBG("Network connected");
}
modem.sleepEnable();
delay(100);
// test modem response , res == 0 , modem is sleep
res = modem.testAT();
Serial.print(" Test AT result -> ");
Serial.println(res);
delay(1000);
Serial.println("Use DTR Pin Wakeup");
pinMode(MODEM_DTR, OUTPUT);
//Set DTR Pin low , wakeup modem .
digitalWrite(MODEM_DTR, LOW);
// test modem response , res == 1 , modem is wakeup
res = modem.testAT();
Serial.print(" Test AT result -> ");
Serial.println(res);
endif
if TINY_GSM_POWERDOWN
// Try to power-off (modem may decide to restart automatically)
// To turn off modem completely, please use Reset/Enable pins
modem.poweroff();
DBG("Poweroff.");
endif
SerialMon.printf("End of tests. Enable deep sleep , Will wake up in %d seconds", TIME_TO_SLEEP);
//Wait moden power off
light_sleep(5);
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
delay(200);
esp_deep_sleep_start();
while (1);
`
but i get negative coordinate and strangely i get zero satellite visible which is not possible because i get the correct location if i delete the minus sign:
Hi i'm testing this modem with gps with this code:
`/** *
define TINY_GSM_MODEM_SIM7600
// Set serial for debug console (to the Serial Monitor, default speed 115200)
define SerialMon Serial
// Set serial for AT commands (to the module) // Use Hardware Serial on Mega, Leonardo, Micro
define SerialAT Serial1
// See all AT commands, if wanted
define DUMP_AT_COMMANDS
// Define the serial console for debug prints, if needed
define TINY_GSM_DEBUG SerialMon
/*
define TINY_GSM_TEST_GPRS true
define TINY_GSM_TEST_TCP true
define TINY_GSM_TEST_GPS true
// powerdown modem after tests
define TINY_GSM_POWERDOWN true
// set GSM PIN, if any
define GSM_PIN ""
// Your GPRS credentials, if any const char apn[] = ""; const char gprsUser[] = ""; const char gprsPass[] = "";
// Server details to test TCP/SSL const char server[] = "vsh.pp.ua"; const char resource[] = "/TinyGSM/logo.txt";
include "utilities.h"
include
include
ifdef DUMP_AT_COMMANDS
include
StreamDebugger debugger(SerialAT, SerialMon); TinyGsm modem(debugger);
else
TinyGsm modem(SerialAT);
endif
void setup() { // Set console baud rate SerialMon.begin(115200); delay(10);
}
void light_sleep(uint32_t sec ) { esp_sleep_enable_timer_wakeup(sec * 1000000ULL); esp_light_sleep_start(); }
void loop() { bool res ;
if TINY_GSM_TEST_GPRS
endif
if TINY_GSM_TEST_GPRS
endif
if TINY_GSM_TEST_TCP && defined TINY_GSM_MODEM_HAS_TCP
endif
if TINY_GSM_TEST_GPS && defined TINY_GSM_MODEM_HAS_GPS
endif
if TINY_GSM_TEST_GPRS
endif
ifdef MODEM_DTR1
endif
if TINY_GSM_POWERDOWN
endif
`
but i get negative coordinate and strangely i get zero satellite visible which is not possible because i get the correct location if i delete the minus sign:
[30374] Latitude: -44.59538651 Longitude: -8.44853134 10:56:29.026 -> [30374] Speed: 0.00 Altitude: 205.20 10:56:29.026 -> [30374] Visible Satellites: 0 Used Satellites: 0 10:56:29.026 -> [30375] Accuracy: 1.30 10:56:29.026 -> [30377] Year: 2021 Month: 8 Day: 10 10:56:29.026 -> [30381] Hour: 8 Minute: 55 Second: 36
the gpsraw request instead is correct:
10:56:29.026 -> [30384] Retrieving GPS/GNSS/GLONASS location again as a string 10:56:29.026 -> AT+CGNSSINFO 10:56:29.026 -> 10:56:29.026 -> +CGNSSINFO: 2,05,00,00,4435.722450,N,00844.911711,E,100821,085540.0,208.1,0.0,0.0,1.6,1.3,0.9