mirror of
				https://github.com/KevinMidboe/TinyGSM.git
				synced 2025-10-29 18:00:18 +00:00 
			
		
		
		
	Minor example update
This commit is contained in:
		| @@ -10,11 +10,13 @@ | ||||
|  **************************************************************/ | ||||
|  | ||||
| // Select your modem: | ||||
| //#define TINY_GSM_MODEM_SIM800 | ||||
| #define TINY_GSM_MODEM_SIM800 | ||||
| // #define TINY_GSM_MODEM_SIM808 | ||||
| // #define TINY_GSM_MODEM_SIM868 | ||||
| // #define TINY_GSM_MODEM_SIM900 | ||||
| #define TINY_GSM_MODEM_SIM7000 | ||||
| // #define TINY_GSM_MODEM_SIM7000 | ||||
| // #define TINY_GSM_MODEM_UBLOX | ||||
| // #define TINY_GSM_MODEM_SARAR4 | ||||
| // #define TINY_GSM_MODEM_M95 | ||||
| // #define TINY_GSM_MODEM_BG96 | ||||
| // #define TINY_GSM_MODEM_A6 | ||||
| @@ -24,8 +26,9 @@ | ||||
| // #define TINY_GSM_MODEM_MC60E | ||||
| // #define TINY_GSM_MODEM_ESP8266 | ||||
| // #define TINY_GSM_MODEM_XBEE | ||||
| // #define TINY_GSM_MODEM_SEQUANS_MONARCH | ||||
|  | ||||
| // Set serial for debug console (to the Serial Monitor, speed 115200) | ||||
| // Set serial for debug console (to the Serial Monitor, default speed 115200) | ||||
| #define SerialMon Serial | ||||
|  | ||||
| // Set serial for AT commands (to the module) | ||||
| @@ -36,10 +39,13 @@ | ||||
| //#include <SoftwareSerial.h> | ||||
| //SoftwareSerial SerialAT(2, 3); // RX, TX | ||||
|  | ||||
|  | ||||
| // See all AT commands, if wanted | ||||
| //#define DUMP_AT_COMMANDS | ||||
|  | ||||
| // See the debugging, if wanted | ||||
| #define TINY_GSM_DEBUG SerialMon | ||||
|  | ||||
| // Range to attempt to autobaud | ||||
| #define GSM_AUTOBAUD_MIN 9600 | ||||
| #define GSM_AUTOBAUD_MAX 38400 | ||||
|  | ||||
| @@ -47,6 +53,7 @@ | ||||
|  * Test enabled | ||||
|  */ | ||||
| #define TINY_GSM_USE_GPRS true | ||||
| #define TINY_GSM_USE_WIFI false | ||||
| #define TINY_GSM_USE_CALL true | ||||
| #define TINY_GSM_USE_SMS true | ||||
| #define TINY_GSM_USE_USSD true | ||||
| @@ -65,6 +72,8 @@ | ||||
| const char apn[]  = "YourAPN"; | ||||
| const char user[] = ""; | ||||
| const char pass[] = ""; | ||||
| const char wifiSSID[]  = "YourSSID"; | ||||
| const char wifiPass[] = "SSIDpw"; | ||||
|  | ||||
| #include <TinyGsmClient.h> | ||||
|  | ||||
| @@ -82,11 +91,18 @@ void setup() { | ||||
|   delay(10); | ||||
|  | ||||
|   // Set your reset, enable, power pins here | ||||
|   pinMode(20, OUTPUT); | ||||
|   digitalWrite(20, HIGH); | ||||
|  | ||||
|   pinMode(23, OUTPUT); | ||||
|   digitalWrite(23, HIGH); | ||||
|  | ||||
|   DBG("Wait..."); | ||||
|   delay(3000); | ||||
|  | ||||
|   // Set GSM module baud rate | ||||
|   TinyGsmAutoBaud(SerialAT,GSM_AUTOBAUD_MIN,GSM_AUTOBAUD_MAX); | ||||
|   // SerialAT.begin(9600); | ||||
| } | ||||
|  | ||||
| void loop() { | ||||
| @@ -111,6 +127,16 @@ void loop() { | ||||
|     modem.simUnlock(GSM_PIN); | ||||
|   } | ||||
|  | ||||
| #if TINY_GSM_USE_WIFI | ||||
|   SerialMon.print(F("Setting SSID/password...")); | ||||
|   if (!modem.networkConnect(wifiSSID, wifiPass)) { | ||||
|     SerialMon.println(" fail"); | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|   SerialMon.println(" OK"); | ||||
| #endif | ||||
|  | ||||
|   DBG("Waiting for network..."); | ||||
|   if (!modem.waitForNetwork()) { | ||||
|     delay(10000); | ||||
| @@ -221,6 +247,11 @@ void loop() { | ||||
|   } | ||||
| #endif | ||||
|  | ||||
| #if TINY_GSM_USE_WIFI | ||||
|   modem.networkDisconnect(); | ||||
|   DBG("WiFi disconnected"); | ||||
| #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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user