├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── auto-github-actions.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── changelog.md ├── examples ├── ESP32_GSM │ ├── Credentials.h │ ├── ESP32_GSM.ino │ ├── defines.h │ └── dynamicParams.h ├── ESP32_GSM_SHT3x │ ├── Credentials.h │ ├── ESP32_GSM_SHT3x.ino │ ├── defines.h │ └── dynamicParams.h ├── ESP32_MRD_GSM │ ├── Credentials.h │ ├── ESP32_MRD_GSM.ino │ ├── defines.h │ └── dynamicParams.h ├── ESP8266_GSM │ ├── Credentials.h │ ├── ESP8266_GSM.ino │ ├── defines.h │ └── dynamicParams.h ├── ESP8266_GSM_SHT3x │ ├── Credentials.h │ ├── ESP8266_GSM_SHT3x.ino │ ├── defines.h │ └── dynamicParams.h ├── ESP8266_MRD_GSM │ ├── Credentials.h │ ├── ESP8266_MRD_GSM.ino │ ├── defines.h │ └── dynamicParams.h ├── TTGO_TCALL_GSM │ ├── Credentials.h │ ├── TTGO_TCALL_GSM.ino │ ├── defines.h │ └── dynamicParams.h ├── TTGO_TCALL_MRD_GSM │ ├── Credentials.h │ ├── TTGO_TCALL_MRD_GSM.ino │ ├── defines.h │ └── dynamicParams.h └── TTGO_TCALL_SHT3x │ ├── Credentials.h │ ├── TTGO_TCALL_SHT3x.ino │ ├── defines.h │ └── dynamicParams.h ├── keywords.txt ├── library.json ├── library.properties ├── pics ├── Selection_1.jpg ├── Selection_2.png └── Selection_3.png ├── platformio └── platformio.ini └── src ├── Adapters ├── BlynkGsm_ESP32M.h └── BlynkGsm_ESP8266M.h ├── BlynkSimpleEsp32_GSM_WF.h ├── BlynkSimpleEsp32_GSM_WFM.h ├── BlynkSimpleEsp8266_GSM_WF.h ├── BlynkSimpleEsp8266_GSM_WFM.h └── BlynkSimpleTinyGSM_M.h /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Describe the bug 11 | 12 | A clear and concise description of what the bug is. 13 | 14 | ### Steps to Reproduce 15 | 16 | Steps to reproduce the behavior. Including the [MRE](https://stackoverflow.com/help/minimal-reproducible-example) sketches 17 | 18 | ### Expected behavior 19 | 20 | A clear and concise description of what you expected to happen. 21 | 22 | ### Actual behavior 23 | 24 | A clear and concise description of what you expected to happen. 25 | 26 | ### Debug and AT-command log (if applicable) 27 | 28 | A clear and concise description of what you expected to happen. 29 | 30 | ### Screenshots 31 | 32 | If applicable, add screenshots to help explain your problem. 33 | 34 | ### Information 35 | 36 | Please ensure to specify the following: 37 | 38 | * Arduino IDE version (e.g. 1.8.13) or Platform.io version 39 | * `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v2.7.4, ESP32 v1.0.5 or STM32 v1.9.0) 40 | * Contextual information (e.g. what you were trying to achieve) 41 | * Simplest possible steps to reproduce 42 | * Anything that might be relevant in your opinion, such as: 43 | * Operating system (Windows, Ubuntu, etc.) and the output of `uname -a` 44 | * Network configuration 45 | 46 | ### Example 47 | 48 | ``` 49 | Arduino IDE version: 1.8.13 50 | ESP32 Core Version 1.0.5 51 | OS: Ubuntu 20.04 LTS 52 | Linux xy-Inspiron-3593 5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux 53 | 54 | Context: 55 | I encountered an endless loop while trying to connect to Local WiFi. 56 | 57 | Steps to reproduce: 58 | 1. ... 59 | 2. ... 60 | 3. ... 61 | 4. ... 62 | ``` 63 | 64 | ### Additional context 65 | 66 | Add any other context about the problem here. 67 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/auto-github-actions.yml: -------------------------------------------------------------------------------- 1 | name: auto-github-actions 2 | on: [push] 3 | jobs: 4 | check-bats-version: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v2 8 | - uses: actions/setup-node@v2 9 | with: 10 | node-version: '14' 11 | - run: npm install -g bats 12 | - run: bats -v 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to BlynkGSM_Manager 2 | 3 | ### Reporting Bugs 4 | 5 | Please report bugs in BlynkGSM_Manager if you find them. 6 | 7 | However, before reporting a bug please check through the following: 8 | 9 | * [Existing Open Issues](https://github.com/khoih-prog/BlynkGSM_Manager/issues) - someone might have already encountered this. 10 | 11 | If you don't find anything, please [open a new issue](https://github.com/khoih-prog/BlynkGSM_Manager/issues/new). 12 | 13 | ### How to submit a bug report 14 | 15 | Please ensure to specify the following: 16 | 17 | * Arduino IDE version (e.g. 1.8.16) or Platform.io version 18 | * `ESP8266` or `ESP32` Core Version (e.g. ESP8266 core v3.0.2 or ESP32 v2.0.0) 19 | * Contextual information (e.g. what you were trying to achieve) 20 | * Simplest possible steps to reproduce 21 | * Anything that might be relevant in your opinion, such as: 22 | * Operating system (Windows, Ubuntu, etc.) and the output of `uname -a` 23 | * Network configuration 24 | 25 | 26 | ### Example 27 | 28 | ``` 29 | Arduino IDE version: 1.8.16 30 | ESP8266 Core Version 3.0.2 31 | OS: Ubuntu 20.04 LTS 32 | Linux Inspiron 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux 33 | 34 | Context: 35 | The board couldn't autoreconnect to Local Blynk Server after router power recycling. 36 | 37 | Steps to reproduce: 38 | 1. ... 39 | 2. ... 40 | 3. ... 41 | 4. ... 42 | ``` 43 | ### Sending Feature Requests 44 | 45 | Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful. 46 | 47 | There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/BlynkGSM_Manager/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them. 48 | 49 | ### Sending Pull Requests 50 | 51 | Pull Requests with changes and fixes are also welcome! 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Khoi Hoang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | ## BlynkGSM_Manager 2 | 3 | [![arduino-library-badge](https://www.ardu-badge.com/badge/BlynkGSM_Manager.svg?)](https://www.ardu-badge.com/BlynkGSM_Manager) 4 | [![GitHub release](https://img.shields.io/github/release/khoih-prog/BlynkGSM_Manager.svg)](https://github.com/khoih-prog/BlynkGSM_Manager/releases) 5 | [![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/BlynkGSM_Manager/blob/master/LICENSE) 6 | [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing) 7 | [![GitHub issues](https://img.shields.io/github/issues/khoih-prog/BlynkGSM_Manager.svg)](http://github.com/khoih-prog/BlynkGSM_Manager/issues) 8 | 9 | --- 10 | --- 11 | 12 | ## Table of Contents 13 | 14 | * [Changelog](#changelog) 15 | * [Releases v1.2.1](#releases-v121) 16 | * [Major Releases v1.2.0](#major-releases-v120) 17 | * [Major Releases v1.1.0](#major-releases-v110) 18 | * [Releases v1.0.10](#releases-v1010) 19 | * [Major Releases v1.0.9](#major-releases-v109) 20 | 21 | --- 22 | --- 23 | 24 | ## Changelog 25 | 26 | ### Releases v1.2.1 27 | 28 | 1. Update `platform.ini` and `library.json` to use original `khoih-prog` instead of `khoih.prog` after PIO fix 29 | 30 | ### Major Releases v1.2.0 31 | 32 | 1. To permit autoreset after configurable timeout if DRD/MRD or non-persistent forced-CP. Check [**Good new feature: Blynk.resetAndEnterConfigPortal() Thanks & question #27**](https://github.com/khoih-prog/Blynk_WM/issues/27) 33 | 2. Fix rare Config Portal bug not updating Config and dynamic Params data successfully in very noisy or weak WiFi situation 34 | 3. Add functions to control Config Portal from software or Virtual Switches. Check [How to trigger a Config Portal from code #25](https://github.com/khoih-prog/Blynk_WM/issues/25) 35 | 4. Add the new Virtual ConfigPortal SW feature to examples. 36 | 5. Disable the GSM/GPRS modem initialization which blocks the operation of Config Portal when using Config Portal. 37 | 38 | ### Major Releases v1.1.0 39 | 40 | 1. Add support to LittleFS for ESP32 using [LittleFS_esp32](https://github.com/lorol/LITTLEFS) Library 41 | 2. Add support to MultiDetectDetector. **MultiDetectDetector** feature to force Config Portal when configurable multi-reset is detected within predetermined time. 42 | 3. Clean-up all compiler warnings possible. 43 | 4. Add Table of Contents 44 | 5. Add Version String 45 | 6. Add MRD-related examples. 46 | 47 | ### Releases v1.0.10 48 | 49 | 1. Use ESP8266/ESP32 MultiWiFi feature to autoconnect to the best and available WiFi SSID. 50 | 2. Auto format SPIFFS/LittleFS for first time usage. 51 | 3. Fix bug and logic of USE_DEFAULT_CONFIG_DATA. 52 | 53 | #### Major Releases v1.0.9 54 | 55 | 1. Add MultiWiFi/Blynk features for WiFi 56 | 2. Add MultiBlynk feature for GPRS/GSM 57 | 3. Add DoubleResetDetector (DRD) feature. 58 | 4. Update to use LittleFS for ESP8266 core 2.7.1+ to replace deprecated SPIFFS on ESP8266 59 | 5. Add Configurable Config Portal Title 60 | 6. Add Default Config Data. 61 | 62 | 63 | -------------------------------------------------------------------------------- /examples/ESP32_GSM/Credentials.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | Credentials.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef Credentials_h 13 | #define Credentials_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | /// Start Default Config Data ////////////////// 18 | 19 | /* 20 | // Defined in 21 | 22 | #define SSID_MAX_LEN 32 23 | //From v1.0.10, WPA2 passwords can be up to 63 characters long. 24 | #define PASS_MAX_LEN 64 25 | 26 | typedef struct 27 | { 28 | char wifi_ssid[SSID_MAX_LEN]; 29 | char wifi_pw [PASS_MAX_LEN]; 30 | } WiFi_Credentials; 31 | 32 | #define BLYNK_SERVER_MAX_LEN 32 33 | #define BLYNK_TOKEN_MAX_LEN 36 34 | 35 | typedef struct 36 | { 37 | char blynk_server [BLYNK_SERVER_MAX_LEN]; 38 | char wifi_blynk_token [BLYNK_TOKEN_MAX_LEN]; 39 | char gsm_blynk_token [BLYNK_TOKEN_MAX_LEN]; 40 | } Blynk_Credentials; 41 | 42 | #define NUM_WIFI_CREDENTIALS 2 43 | #define NUM_BLYNK_CREDENTIALS 2 44 | 45 | // Configurable items besides fixed Header 46 | #define NUM_CONFIGURABLE_ITEMS ( 6 + (2 * NUM_WIFI_CREDENTIALS) + (3 * NUM_BLYNK_CREDENTIALS) ) 47 | #define DEFAULT_GPRS_PIN "1234" 48 | 49 | typedef struct Configuration 50 | { 51 | char header [16]; 52 | WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS]; 53 | Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 54 | int blynk_port; 55 | // YOUR GSM / GPRS RELATED 56 | char apn [32]; 57 | char gprsUser [32]; 58 | char gprsPass [32]; 59 | char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 60 | // END OF YOUR GSM / GPRS RELATED 61 | char board_name [24]; 62 | int checkSum; 63 | } Blynk_WF_Configuration; 64 | 65 | */ 66 | 67 | //bool LOAD_DEFAULT_CONFIG_DATA = true; 68 | bool LOAD_DEFAULT_CONFIG_DATA = false; 69 | 70 | Blynk_WF_Configuration defaultConfig = 71 | { 72 | //char header[16], dummy, not used 73 | "GSM", 74 | //WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS] 75 | //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw 76 | "SSID1", "password1", 77 | "SSID2", "password2", 78 | // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 79 | // Blynk_Creds.blynk_server, Blynk_Creds.wifi_blynk_token and Blynk_Creds.gsm_blynk_token 80 | "account.ddns.net", "wifi_token", "gsm_token", 81 | "account.duckdns.org", "wifi_token1", "gsm_token1", 82 | //int blynk_port; 83 | 8080, 84 | // YOUR GSM / GPRS RELATED 85 | //char apn [32]; 86 | "rogers-core-appl1.apn", 87 | //char gprsUser [32]; 88 | "wapuser1", 89 | //char gprsPass [32]; 90 | "wap", 91 | //char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 92 | "1245678", 93 | // END OF YOUR GSM / GPRS RELATED 94 | //char board_name [24]; 95 | "ESP32-GSM-WiFi", 96 | //int checkSum, dummy, not used 97 | 0 98 | }; 99 | 100 | /////////// End Default Config Data ///////////// 101 | 102 | #endif // #if USE_BLYNK_WM 103 | 104 | #endif //Credentials_h 105 | -------------------------------------------------------------------------------- /examples/ESP32_GSM/ESP32_GSM.ino: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | ESP32_GSM.ino 3 | For ESP32 to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #include "defines.h" 12 | 13 | #if USE_BLYNK_WM 14 | #include "Credentials.h" 15 | #include "dynamicParams.h" 16 | 17 | #define BLYNK_PIN_FORCED_CONFIG V10 18 | #define BLYNK_PIN_FORCED_PERS_CONFIG V20 19 | 20 | // Use button V10 (BLYNK_PIN_FORCED_CONFIG) to forced Config Portal 21 | BLYNK_WRITE(BLYNK_PIN_FORCED_CONFIG) 22 | { 23 | if (param.asInt()) 24 | { 25 | Serial.println( F("\nCP Button Hit. Rebooting") ); 26 | 27 | // This will keep CP once, clear after reset, even you didn't enter CP at all. 28 | Blynk.resetAndEnterConfigPortal(); 29 | } 30 | } 31 | 32 | // Use button V20 (BLYNK_PIN_FORCED_PERS_CONFIG) to forced Persistent Config Portal 33 | BLYNK_WRITE(BLYNK_PIN_FORCED_PERS_CONFIG) 34 | { 35 | if (param.asInt()) 36 | { 37 | Serial.println( F("\nPersistent CP Button Hit. Rebooting") ); 38 | 39 | // This will keep CP forever, until you successfully enter CP, and Save data to clear the flag. 40 | Blynk.resetAndEnterConfigPortalPersistent(); 41 | } 42 | } 43 | #endif 44 | 45 | void heartBeatPrint() 46 | { 47 | static int num = 1; 48 | 49 | if (Blynk_WF.connected()) 50 | { 51 | Serial.print(F("B")); 52 | } 53 | else 54 | { 55 | Serial.print(F("F")); 56 | } 57 | 58 | if (Blynk_GSM.connected()) 59 | { 60 | Serial.print(F("G")); 61 | } 62 | else 63 | { 64 | Serial.print(F("F")); 65 | } 66 | 67 | if (num == 40) 68 | { 69 | Serial.println(); 70 | num = 1; 71 | } 72 | else if (num++ % 10 == 0) 73 | { 74 | Serial.print(F(" ")); 75 | } 76 | } 77 | 78 | void check_status() 79 | { 80 | static unsigned long checkstatus_timeout = 0; 81 | 82 | #define STATUS_CHECK_INTERVAL 60000L 83 | 84 | // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. 85 | if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) 86 | { 87 | // report status to Blynk 88 | heartBeatPrint(); 89 | 90 | checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; 91 | } 92 | } 93 | 94 | bool valid_apn = false; 95 | bool GSM_CONNECT_OK = false; 96 | 97 | void setup() 98 | { 99 | // Set console baud rate 100 | SerialMon.begin(115200); 101 | while (!SerialMon); 102 | 103 | delay(200); 104 | 105 | SerialMon.print(F("\nStart ESP32_GSM (Simultaneous WiFi+GSM) using ")); 106 | SerialMon.print(CurrentFileFS); 107 | SerialMon.print(F(" on ")); SerialMon.println(ARDUINO_BOARD); 108 | SerialMon.println(BLYNK_GSM_MANAGER_VERSION); 109 | 110 | #if USE_BLYNK_WM 111 | Serial.println(ESP_DOUBLE_RESET_DETECTOR_VERSION); 112 | #endif 113 | 114 | // Set-up modem reset, enable, power pins 115 | pinMode(MODEM_PWKEY, OUTPUT); 116 | pinMode(MODEM_RST, OUTPUT); 117 | pinMode(MODEM_POWER_ON, OUTPUT); 118 | 119 | digitalWrite(MODEM_PWKEY, LOW); 120 | digitalWrite(MODEM_RST, HIGH); 121 | digitalWrite(MODEM_POWER_ON, HIGH); 122 | 123 | SerialMon.println(F("Set GSM module baud rate")); 124 | 125 | // Set GSM module baud rate 126 | //SerialAT.begin(115200); 127 | SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX); 128 | delay(3000); 129 | 130 | Serial.println(F("Use WiFi to connect Blynk")); 131 | 132 | #if USE_BLYNK_WM 133 | 134 | // Set config portal SSID and Password 135 | Blynk_WF.setConfigPortal("TestPortal-ESP32", "TestPortalPass"); 136 | 137 | // Use configurable AP IP, instead of default IP 192.168.4.1 138 | Blynk_WF.setConfigPortalIP(IPAddress(192, 168, 232, 1)); 139 | // Set config portal channel, default = 1. Use 0 => random channel from 1-12 to avoid conflict 140 | Blynk_WF.setConfigPortalChannel(0); 141 | 142 | // Select either one of these to set static IP + DNS 143 | Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0)); 144 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 145 | // IPAddress(192, 168, 2, 1), IPAddress(8, 8, 8, 8)); 146 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 147 | // IPAddress(4, 4, 4, 4), IPAddress(8, 8, 8, 8)); 148 | 149 | // Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX 150 | //Blynk_WF.begin(); 151 | // Use this to personalize DHCP hostname (RFC952 conformed) 152 | // 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char 153 | Blynk_WF.begin("ESP32-WiFi-GSM"); 154 | 155 | #else 156 | Blynk_WF.begin(wifi_blynk_tok, ssid, pass, blynk_server, BLYNK_HARDWARE_PORT); 157 | 158 | Blynk_GSM.config(modem, gsm_blynk_tok, blynk_server, BLYNK_HARDWARE_PORT); 159 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(apn, gprsUser, gprsPass); 160 | 161 | if (GSM_CONNECT_OK) 162 | Blynk_GSM.connect(); 163 | #endif 164 | 165 | #if USE_BLYNK_WM 166 | Blynk_WF_Configuration localBlynkGSM_ESP32_config; 167 | 168 | Blynk_WF.getFullConfigData(&localBlynkGSM_ESP32_config); 169 | 170 | Serial.print(F("gprs apn = ")); 171 | Serial.println(localBlynkGSM_ESP32_config.apn); 172 | 173 | if ( Blynk.inConfigPortal() || (String(localBlynkGSM_ESP32_config.apn) == NO_CONFIG) ) 174 | { 175 | Serial.println(F("DRD/MRD, Forced Config Portal or No valid stored apn. Must run only WiFi to Open config portal")); 176 | valid_apn = false; 177 | } 178 | else 179 | { 180 | valid_apn = true; 181 | 182 | for (uint16_t index = 0; index < NUM_BLYNK_CREDENTIALS; index++) 183 | { 184 | Blynk_GSM.config(modem, localBlynkGSM_ESP32_config.Blynk_Creds[index].gsm_blynk_token, 185 | localBlynkGSM_ESP32_config.Blynk_Creds[index].blynk_server, localBlynkGSM_ESP32_config.blynk_port); 186 | 187 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(localBlynkGSM_ESP32_config.apn, localBlynkGSM_ESP32_config.gprsUser, 188 | localBlynkGSM_ESP32_config.gprsPass); 189 | 190 | if (GSM_CONNECT_OK) 191 | { 192 | if ( Blynk_GSM.connect() == true ) 193 | break; 194 | } 195 | } 196 | } 197 | #endif 198 | } 199 | 200 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 201 | void displayCredentials() 202 | { 203 | Serial.println(F("\nYour stored Credentials :")); 204 | 205 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 206 | { 207 | Serial.print(myMenuItems[i].displayName); 208 | Serial.print(F(" = ")); 209 | Serial.println(myMenuItems[i].pdata); 210 | } 211 | } 212 | #endif 213 | 214 | void loop() 215 | { 216 | Blynk_WF.run(); 217 | 218 | #if USE_BLYNK_WM 219 | if (valid_apn) 220 | #endif 221 | { 222 | if (GSM_CONNECT_OK) 223 | Blynk_GSM.run(); 224 | } 225 | 226 | check_status(); 227 | 228 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 229 | static bool displayedCredentials = false; 230 | 231 | if (!displayedCredentials) 232 | { 233 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 234 | { 235 | if (!strlen(myMenuItems[i].pdata)) 236 | { 237 | break; 238 | } 239 | 240 | if ( i == (NUM_MENU_ITEMS - 1) ) 241 | { 242 | displayedCredentials = true; 243 | displayCredentials(); 244 | } 245 | } 246 | } 247 | #endif 248 | } 249 | -------------------------------------------------------------------------------- /examples/ESP32_GSM/defines.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | defines.h 3 | For ESP32 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #ifndef defines_h 12 | #define defines_h 13 | 14 | #ifndef ESP32 15 | #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting. 16 | #endif 17 | 18 | #define BLYNK_PRINT Serial 19 | #define BLYNK_HEARTBEAT 60 20 | 21 | #define DOUBLERESETDETECTOR_DEBUG true //false 22 | #define BLYNK_WM_DEBUG 1 23 | 24 | // Not use #define USE_LITTLEFS and #define USE_SPIFFS => using SPIFFS for configuration data in WiFiManager 25 | // (USE_LITTLEFS == false) and (USE_SPIFFS == false) => using EEPROM for configuration data in WiFiManager 26 | // (USE_LITTLEFS == true) and (USE_SPIFFS == false) => using LITTLEFS for configuration data in WiFiManager 27 | // (USE_LITTLEFS == true) and (USE_SPIFFS == true) => using LITTLEFS for configuration data in WiFiManager 28 | // (USE_LITTLEFS == false) and (USE_SPIFFS == true) => using SPIFFS for configuration data in WiFiManager 29 | // Those above #define's must be placed before #include 30 | 31 | #define USE_LITTLEFS true 32 | #define USE_SPIFFS false 33 | 34 | #if USE_LITTLEFS 35 | #define CurrentFileFS F("LittleFS") 36 | #elif USE_SPIFFS 37 | #define CurrentFileFS F("SPIFFS") 38 | #else 39 | #define CurrentFileFS F("EEPROM") 40 | 41 | // EEPROM_SIZE must be <= 2048 and >= CONFIG_DATA_SIZE (currently 172 bytes) 42 | #define EEPROM_SIZE (2 * 1024) 43 | // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE 44 | #define EEPROM_START 0 45 | #endif 46 | 47 | // Force some params in Blynk, only valid for library version 1.0.1 and later 48 | #define TIMEOUT_RECONNECT_WIFI 10000L 49 | #define RESET_IF_CONFIG_TIMEOUT true 50 | #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5 51 | 52 | // Config Timeout 120s (default 60s) 53 | #define CONFIG_TIMEOUT 120000L 54 | // Those above #define's must be placed before #include 55 | 56 | // TTGO T-Call pin definitions 57 | #define MODEM_RST 5 58 | #define MODEM_PWKEY 4 59 | #define MODEM_POWER_ON 23 60 | 61 | #define MODEM_TX 27 62 | #define MODEM_RX 26 63 | 64 | #define I2C_SDA 21 65 | #define I2C_SCL 22 66 | 67 | // Select your modem: 68 | #define TINY_GSM_MODEM_SIM800 69 | //#define TINY_GSM_MODEM_SIM808 70 | //#define TINY_GSM_MODEM_SIM868 71 | //#define TINY_GSM_MODEM_SIM900 72 | //#define TINY_GSM_MODEM_SIM5300 73 | //#define TINY_GSM_MODEM_SIM5320 74 | //#define TINY_GSM_MODEM_SIM5360 75 | //#define TINY_GSM_MODEM_SIM7000 76 | //#define TINY_GSM_MODEM_SIM7100 77 | //#define TINY_GSM_MODEM_SIM7500 78 | //#define TINY_GSM_MODEM_SIM7600 79 | //#define TINY_GSM_MODEM_SIM7800 80 | //#define TINY_GSM_MODEM_UBLOX 81 | //#define TINY_GSM_MODEM_SARAR4 82 | //#define TINY_GSM_MODEM_M95 83 | //#define TINY_GSM_MODEM_BG96 84 | //#define TINY_GSM_MODEM_A6 85 | //#define TINY_GSM_MODEM_A7 86 | //#define TINY_GSM_MODEM_M590 87 | //#define TINY_GSM_MODEM_MC60 88 | //#define TINY_GSM_MODEM_MC60E 89 | //#define TINY_GSM_MODEM_XBEE 90 | //#define TINY_GSM_MODEM_SEQUANS_MONARCH 91 | 92 | // Increase RX buffer if needed 93 | #define TINY_GSM_RX_BUFFER 1024 94 | 95 | #include 96 | 97 | //#define USE_BLYNK_WM false 98 | #define USE_BLYNK_WM true 99 | 100 | #include 101 | 102 | #if USE_BLYNK_WM 103 | #define USE_DYNAMIC_PARAMETERS true 104 | 105 | #include 106 | 107 | #else 108 | #include 109 | 110 | // Your WiFi credentials. 111 | #define ssid "****" 112 | #define pass "****" 113 | 114 | #define USE_LOCAL_SERVER true 115 | //#define USE_LOCAL_SERVER false 116 | 117 | #if USE_LOCAL_SERVER 118 | #define wifi_blynk_tok "****" 119 | #define gsm_blynk_tok "****" 120 | //#define blynk_server "account.duckdns.org" 121 | // Use direct IPAddress in case GPRS can't use DDNS fast enough and can't connect 122 | #define blynk_server "xxx.xxx.xxx.xxx" 123 | #else 124 | #define wifi_blynk_tok "****" 125 | #define gsm_blynk_tok "****" 126 | #define blynk_server "blynk-cloud.com" 127 | #endif 128 | 129 | #define apn "rogers-core-appl1.apn" 130 | #define gprsUser "" //"wapuser1" 131 | #define gprsPass "" //"wap" 132 | 133 | #endif //USE_BLYNK_WM 134 | 135 | #define BLYNK_HARDWARE_PORT 8080 136 | 137 | // Set serial for debug console (to the Serial Monitor, default speed 115200) 138 | #define SerialMon Serial 139 | 140 | #define RXD2 16 141 | #define TXD2 17 142 | 143 | // Use ESP32 Serial2 for GSM 144 | #define SerialAT Serial2 145 | 146 | // Uncomment this if you want to see all AT commands 147 | #define DUMP_AT_COMMANDS false 148 | 149 | #if DUMP_AT_COMMANDS 150 | #include 151 | StreamDebugger debugger(SerialAT, SerialMon); 152 | TinyGsm modem(debugger); 153 | #else 154 | TinyGsm modem(SerialAT); 155 | #endif 156 | 157 | #define HOST_NAME "ESP32-GSM-WiFi" 158 | 159 | #endif //defines_h 160 | -------------------------------------------------------------------------------- /examples/ESP32_GSM/dynamicParams.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | dynamicParams.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef dynamicParams_h 13 | #define dynamicParams_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | #if (USE_DYNAMIC_PARAMETERS) 18 | #warning USE_DYNAMIC_PARAMETERS 19 | #endif 20 | 21 | // USE_DYNAMIC_PARAMETERS defined in defined.h 22 | 23 | /////////////// Start dynamic Credentials /////////////// 24 | 25 | //Defined in 26 | /************************************** 27 | #define MAX_ID_LEN 5 28 | #define MAX_DISPLAY_NAME_LEN 16 29 | 30 | typedef struct 31 | { 32 | char id [MAX_ID_LEN + 1]; 33 | char displayName [MAX_DISPLAY_NAME_LEN + 1]; 34 | char *pdata; 35 | uint8_t maxlen; 36 | } MenuItem; 37 | **************************************/ 38 | 39 | #if USE_DYNAMIC_PARAMETERS 40 | 41 | #define MAX_MQTT_SERVER_LEN 34 42 | char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.ddns.net"; 43 | 44 | #define MAX_MQTT_PORT_LEN 6 45 | char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "1883"; 46 | 47 | #define MAX_MQTT_USERNAME_LEN 34 48 | char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "mqtt-user"; 49 | 50 | #define MAX_MQTT_PW_LEN 34 51 | char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "mqtt-pass"; 52 | 53 | #define MAX_MQTT_SUBS_TOPIC_LEN 34 54 | char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "SubTopic_ESP32_GSM"; 55 | 56 | #define MAX_MQTT_PUB_TOPIC_LEN 34 57 | char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "PubTopic_ESP32_GSM"; 58 | 59 | MenuItem myMenuItems [] = 60 | { 61 | { "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN }, 62 | { "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN }, 63 | { "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN }, 64 | { "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN }, 65 | { "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN }, 66 | { "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN }, 67 | }; 68 | 69 | uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; 70 | 71 | #else 72 | 73 | MenuItem myMenuItems [] = {}; 74 | 75 | uint16_t NUM_MENU_ITEMS = 0; 76 | #endif 77 | 78 | 79 | /////// // End dynamic Credentials /////////// 80 | 81 | #endif // #if USE_BLYNK_WM 82 | 83 | #endif //dynamicParams_h 84 | -------------------------------------------------------------------------------- /examples/ESP32_GSM_SHT3x/Credentials.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | Credentials.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef Credentials_h 13 | #define Credentials_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | /// Start Default Config Data ////////////////// 18 | 19 | /* 20 | // Defined in 21 | 22 | #define SSID_MAX_LEN 32 23 | //From v1.0.10, WPA2 passwords can be up to 63 characters long. 24 | #define PASS_MAX_LEN 64 25 | 26 | typedef struct 27 | { 28 | char wifi_ssid[SSID_MAX_LEN]; 29 | char wifi_pw [PASS_MAX_LEN]; 30 | } WiFi_Credentials; 31 | 32 | #define BLYNK_SERVER_MAX_LEN 32 33 | #define BLYNK_TOKEN_MAX_LEN 36 34 | 35 | typedef struct 36 | { 37 | char blynk_server [BLYNK_SERVER_MAX_LEN]; 38 | char wifi_blynk_token [BLYNK_TOKEN_MAX_LEN]; 39 | char gsm_blynk_token [BLYNK_TOKEN_MAX_LEN]; 40 | } Blynk_Credentials; 41 | 42 | #define NUM_WIFI_CREDENTIALS 2 43 | #define NUM_BLYNK_CREDENTIALS 2 44 | 45 | // Configurable items besides fixed Header 46 | #define NUM_CONFIGURABLE_ITEMS ( 6 + (2 * NUM_WIFI_CREDENTIALS) + (3 * NUM_BLYNK_CREDENTIALS) ) 47 | #define DEFAULT_GPRS_PIN "1234" 48 | 49 | typedef struct Configuration 50 | { 51 | char header [16]; 52 | WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS]; 53 | Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 54 | int blynk_port; 55 | // YOUR GSM / GPRS RELATED 56 | char apn [32]; 57 | char gprsUser [32]; 58 | char gprsPass [32]; 59 | char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 60 | // END OF YOUR GSM / GPRS RELATED 61 | char board_name [24]; 62 | int checkSum; 63 | } Blynk_WF_Configuration; 64 | 65 | */ 66 | 67 | //bool LOAD_DEFAULT_CONFIG_DATA = true; 68 | bool LOAD_DEFAULT_CONFIG_DATA = false; 69 | 70 | Blynk_WF_Configuration defaultConfig = 71 | { 72 | //char header[16], dummy, not used 73 | "GSM", 74 | //WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS] 75 | //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw 76 | "SSID1", "password1", 77 | "SSID2", "password2", 78 | // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 79 | // Blynk_Creds.blynk_server, Blynk_Creds.wifi_blynk_token and Blynk_Creds.gsm_blynk_token 80 | "account.ddns.net", "wifi_token", "gsm_token", 81 | "account.duckdns.org", "wifi_token1", "gsm_token1", 82 | //int blynk_port; 83 | 8080, 84 | // YOUR GSM / GPRS RELATED 85 | //char apn [32]; 86 | "rogers-core-appl1.apn", 87 | //char gprsUser [32]; 88 | "wapuser1", 89 | //char gprsPass [32]; 90 | "wap", 91 | //char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 92 | "1245678", 93 | // END OF YOUR GSM / GPRS RELATED 94 | //char board_name [24]; 95 | "ESP32-GSM-WiFi", 96 | //int checkSum, dummy, not used 97 | 0 98 | }; 99 | 100 | /////////// End Default Config Data ///////////// 101 | 102 | #endif // #if USE_BLYNK_WM 103 | 104 | #endif //Credentials_h 105 | -------------------------------------------------------------------------------- /examples/ESP32_GSM_SHT3x/defines.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | defines.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef defines_h 13 | #define defines_h 14 | 15 | #ifndef ESP32 16 | #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting. 17 | #endif 18 | 19 | #define BLYNK_PRINT Serial 20 | #define BLYNK_HEARTBEAT 60 21 | 22 | #define DOUBLERESETDETECTOR_DEBUG true //false 23 | #define BLYNK_WM_DEBUG 1 24 | 25 | // Not use #define USE_LITTLEFS and #define USE_SPIFFS => using SPIFFS for configuration data in WiFiManager 26 | // (USE_LITTLEFS == false) and (USE_SPIFFS == false) => using EEPROM for configuration data in WiFiManager 27 | // (USE_LITTLEFS == true) and (USE_SPIFFS == false) => using LITTLEFS for configuration data in WiFiManager 28 | // (USE_LITTLEFS == true) and (USE_SPIFFS == true) => using LITTLEFS for configuration data in WiFiManager 29 | // (USE_LITTLEFS == false) and (USE_SPIFFS == true) => using SPIFFS for configuration data in WiFiManager 30 | // Those above #define's must be placed before #include 31 | 32 | #define USE_LITTLEFS true 33 | #define USE_SPIFFS false 34 | 35 | #if USE_LITTLEFS 36 | #define CurrentFileFS F("LittleFS") 37 | #elif USE_SPIFFS 38 | #define CurrentFileFS F("SPIFFS") 39 | #else 40 | #define CurrentFileFS F("EEPROM") 41 | 42 | // EEPROM_SIZE must be <= 2048 and >= CONFIG_DATA_SIZE (currently 172 bytes) 43 | #define EEPROM_SIZE (2 * 1024) 44 | // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE 45 | #define EEPROM_START 0 46 | #endif 47 | 48 | // Force some params in Blynk, only valid for library version 1.0.1 and later 49 | #define TIMEOUT_RECONNECT_WIFI 10000L 50 | #define RESET_IF_CONFIG_TIMEOUT true 51 | #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5 52 | 53 | // Config Timeout 120s (default 60s) 54 | #define CONFIG_TIMEOUT 120000L 55 | // Those above #define's must be placed before #include 56 | 57 | // TTGO T-Call pin definitions 58 | #define MODEM_RST 5 59 | #define MODEM_PWKEY 4 60 | #define MODEM_POWER_ON 23 61 | 62 | #define MODEM_TX 27 63 | #define MODEM_RX 26 64 | 65 | #define I2C_SDA 21 66 | #define I2C_SCL 22 67 | 68 | // Select your modem: 69 | #define TINY_GSM_MODEM_SIM800 70 | //#define TINY_GSM_MODEM_SIM808 71 | //#define TINY_GSM_MODEM_SIM868 72 | //#define TINY_GSM_MODEM_SIM900 73 | //#define TINY_GSM_MODEM_SIM5300 74 | //#define TINY_GSM_MODEM_SIM5320 75 | //#define TINY_GSM_MODEM_SIM5360 76 | //#define TINY_GSM_MODEM_SIM7000 77 | //#define TINY_GSM_MODEM_SIM7100 78 | //#define TINY_GSM_MODEM_SIM7500 79 | //#define TINY_GSM_MODEM_SIM7600 80 | //#define TINY_GSM_MODEM_SIM7800 81 | //#define TINY_GSM_MODEM_UBLOX 82 | //#define TINY_GSM_MODEM_SARAR4 83 | //#define TINY_GSM_MODEM_M95 84 | //#define TINY_GSM_MODEM_BG96 85 | //#define TINY_GSM_MODEM_A6 86 | //#define TINY_GSM_MODEM_A7 87 | //#define TINY_GSM_MODEM_M590 88 | //#define TINY_GSM_MODEM_MC60 89 | //#define TINY_GSM_MODEM_MC60E 90 | //#define TINY_GSM_MODEM_XBEE 91 | //#define TINY_GSM_MODEM_SEQUANS_MONARCH 92 | 93 | // Increase RX buffer if needed 94 | #define TINY_GSM_RX_BUFFER 1024 95 | 96 | #include 97 | 98 | //#define USE_BLYNK_WM false 99 | #define USE_BLYNK_WM true 100 | 101 | #include 102 | 103 | #if USE_BLYNK_WM 104 | #define USE_DYNAMIC_PARAMETERS true 105 | 106 | #include 107 | 108 | #else 109 | #include 110 | 111 | // Your WiFi credentials. 112 | #define ssid "****" 113 | #define pass "****" 114 | 115 | #define USE_LOCAL_SERVER true 116 | //#define USE_LOCAL_SERVER false 117 | 118 | #if USE_LOCAL_SERVER 119 | #define wifi_blynk_tok "****" 120 | #define gsm_blynk_tok "****" 121 | //#define blynk_server "account.duckdns.org" 122 | // Use direct IPAddress in case GPRS can't use DDNS fast enough and can't connect 123 | #define blynk_server "xxx.xxx.xxx.xxx" 124 | #else 125 | #define wifi_blynk_tok "****" 126 | #define gsm_blynk_tok "****" 127 | #define blynk_server "blynk-cloud.com" 128 | #endif 129 | 130 | #define apn "rogers-core-appl1.apn" 131 | #define gprsUser "" //"wapuser1" 132 | #define gprsPass "" //"wap" 133 | 134 | #endif //USE_BLYNK_WM 135 | 136 | #define BLYNK_HARDWARE_PORT 8080 137 | 138 | // Set serial for debug console (to the Serial Monitor, default speed 115200) 139 | #define SerialMon Serial 140 | 141 | #define RXD2 16 142 | #define TXD2 17 143 | 144 | // Use ESP32 Serial2 for GSM 145 | #define SerialAT Serial2 146 | 147 | // Uncomment this if you want to see all AT commands 148 | #define DUMP_AT_COMMANDS false 149 | 150 | #if DUMP_AT_COMMANDS 151 | #include 152 | StreamDebugger debugger(SerialAT, SerialMon); 153 | TinyGsm modem(debugger); 154 | #else 155 | TinyGsm modem(SerialAT); 156 | #endif 157 | 158 | #define HOST_NAME "ESP32-GSM-WiFi" 159 | 160 | #endif //defines_h 161 | -------------------------------------------------------------------------------- /examples/ESP32_GSM_SHT3x/dynamicParams.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | dynamicParams.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef dynamicParams_h 13 | #define dynamicParams_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | #if (USE_DYNAMIC_PARAMETERS) 18 | #warning USE_DYNAMIC_PARAMETERS 19 | #endif 20 | 21 | // USE_DYNAMIC_PARAMETERS defined in defined.h 22 | 23 | /////////////// Start dynamic Credentials /////////////// 24 | 25 | //Defined in 26 | /************************************** 27 | #define MAX_ID_LEN 5 28 | #define MAX_DISPLAY_NAME_LEN 16 29 | 30 | typedef struct 31 | { 32 | char id [MAX_ID_LEN + 1]; 33 | char displayName [MAX_DISPLAY_NAME_LEN + 1]; 34 | char *pdata; 35 | uint8_t maxlen; 36 | } MenuItem; 37 | **************************************/ 38 | 39 | #if USE_DYNAMIC_PARAMETERS 40 | 41 | #define MAX_MQTT_SERVER_LEN 34 42 | char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.ddns.net"; 43 | 44 | #define MAX_MQTT_PORT_LEN 6 45 | char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "1883"; 46 | 47 | #define MAX_MQTT_USERNAME_LEN 34 48 | char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "mqtt-user"; 49 | 50 | #define MAX_MQTT_PW_LEN 34 51 | char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "mqtt-pass"; 52 | 53 | #define MAX_MQTT_SUBS_TOPIC_LEN 34 54 | char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "SubTopic_ESP32_GSM"; 55 | 56 | #define MAX_MQTT_PUB_TOPIC_LEN 34 57 | char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "PubTopic_ESP32_GSM"; 58 | 59 | MenuItem myMenuItems [] = 60 | { 61 | { "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN }, 62 | { "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN }, 63 | { "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN }, 64 | { "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN }, 65 | { "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN }, 66 | { "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN }, 67 | }; 68 | 69 | uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; 70 | 71 | #else 72 | 73 | MenuItem myMenuItems [] = {}; 74 | 75 | uint16_t NUM_MENU_ITEMS = 0; 76 | #endif 77 | 78 | 79 | /////// // End dynamic Credentials /////////// 80 | 81 | #endif // #if USE_BLYNK_WM 82 | 83 | #endif //dynamicParams_h 84 | -------------------------------------------------------------------------------- /examples/ESP32_MRD_GSM/Credentials.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | Credentials.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef Credentials_h 13 | #define Credentials_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | /// Start Default Config Data ////////////////// 18 | 19 | /* 20 | // Defined in 21 | 22 | #define SSID_MAX_LEN 32 23 | //From v1.0.10, WPA2 passwords can be up to 63 characters long. 24 | #define PASS_MAX_LEN 64 25 | 26 | typedef struct 27 | { 28 | char wifi_ssid[SSID_MAX_LEN]; 29 | char wifi_pw [PASS_MAX_LEN]; 30 | } WiFi_Credentials; 31 | 32 | #define BLYNK_SERVER_MAX_LEN 32 33 | #define BLYNK_TOKEN_MAX_LEN 36 34 | 35 | typedef struct 36 | { 37 | char blynk_server [BLYNK_SERVER_MAX_LEN]; 38 | char wifi_blynk_token [BLYNK_TOKEN_MAX_LEN]; 39 | char gsm_blynk_token [BLYNK_TOKEN_MAX_LEN]; 40 | } Blynk_Credentials; 41 | 42 | #define NUM_WIFI_CREDENTIALS 2 43 | #define NUM_BLYNK_CREDENTIALS 2 44 | 45 | // Configurable items besides fixed Header 46 | #define NUM_CONFIGURABLE_ITEMS ( 6 + (2 * NUM_WIFI_CREDENTIALS) + (3 * NUM_BLYNK_CREDENTIALS) ) 47 | #define DEFAULT_GPRS_PIN "1234" 48 | 49 | typedef struct Configuration 50 | { 51 | char header [16]; 52 | WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS]; 53 | Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 54 | int blynk_port; 55 | // YOUR GSM / GPRS RELATED 56 | char apn [32]; 57 | char gprsUser [32]; 58 | char gprsPass [32]; 59 | char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 60 | // END OF YOUR GSM / GPRS RELATED 61 | char board_name [24]; 62 | int checkSum; 63 | } Blynk_WF_Configuration; 64 | 65 | */ 66 | 67 | //bool LOAD_DEFAULT_CONFIG_DATA = true; 68 | bool LOAD_DEFAULT_CONFIG_DATA = false; 69 | 70 | Blynk_WF_Configuration defaultConfig = 71 | { 72 | //char header[16], dummy, not used 73 | "GSM", 74 | //WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS] 75 | //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw 76 | "SSID1", "password1", 77 | "SSID2", "password2", 78 | // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 79 | // Blynk_Creds.blynk_server, Blynk_Creds.wifi_blynk_token and Blynk_Creds.gsm_blynk_token 80 | "account.ddns.net", "wifi_token", "gsm_token", 81 | "account.duckdns.org", "wifi_token1", "gsm_token1", 82 | //int blynk_port; 83 | 8080, 84 | // YOUR GSM / GPRS RELATED 85 | //char apn [32]; 86 | "rogers-core-appl1.apn", 87 | //char gprsUser [32]; 88 | "wapuser1", 89 | //char gprsPass [32]; 90 | "wap", 91 | //char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 92 | "1245678", 93 | // END OF YOUR GSM / GPRS RELATED 94 | //char board_name [24]; 95 | "ESP32-GSM-WiFi", 96 | //int checkSum, dummy, not used 97 | 0 98 | }; 99 | 100 | /////////// End Default Config Data ///////////// 101 | 102 | #endif // #if USE_BLYNK_WM 103 | 104 | #endif //Credentials_h 105 | -------------------------------------------------------------------------------- /examples/ESP32_MRD_GSM/ESP32_MRD_GSM.ino: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | ESP32_MRD_GSM.ino 3 | For ESP32 to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #include "defines.h" 12 | 13 | #if USE_BLYNK_WM 14 | #include "Credentials.h" 15 | #include "dynamicParams.h" 16 | 17 | #define BLYNK_PIN_FORCED_CONFIG V10 18 | #define BLYNK_PIN_FORCED_PERS_CONFIG V20 19 | 20 | // Use button V10 (BLYNK_PIN_FORCED_CONFIG) to forced Config Portal 21 | BLYNK_WRITE(BLYNK_PIN_FORCED_CONFIG) 22 | { 23 | if (param.asInt()) 24 | { 25 | Serial.println( F("\nCP Button Hit. Rebooting") ); 26 | 27 | // This will keep CP once, clear after reset, even you didn't enter CP at all. 28 | Blynk.resetAndEnterConfigPortal(); 29 | } 30 | } 31 | 32 | // Use button V20 (BLYNK_PIN_FORCED_PERS_CONFIG) to forced Persistent Config Portal 33 | BLYNK_WRITE(BLYNK_PIN_FORCED_PERS_CONFIG) 34 | { 35 | if (param.asInt()) 36 | { 37 | Serial.println( F("\nPersistent CP Button Hit. Rebooting") ); 38 | 39 | // This will keep CP forever, until you successfully enter CP, and Save data to clear the flag. 40 | Blynk.resetAndEnterConfigPortalPersistent(); 41 | } 42 | } 43 | #endif 44 | 45 | void heartBeatPrint() 46 | { 47 | static int num = 1; 48 | 49 | if (Blynk_WF.connected()) 50 | { 51 | Serial.print(F("B")); 52 | } 53 | else 54 | { 55 | Serial.print(F("F")); 56 | } 57 | 58 | if (Blynk_GSM.connected()) 59 | { 60 | Serial.print(F("G")); 61 | } 62 | else 63 | { 64 | Serial.print(F("F")); 65 | } 66 | 67 | if (num == 40) 68 | { 69 | Serial.println(); 70 | num = 1; 71 | } 72 | else if (num++ % 10 == 0) 73 | { 74 | Serial.print(F(" ")); 75 | } 76 | } 77 | 78 | void check_status() 79 | { 80 | static unsigned long checkstatus_timeout = 0; 81 | 82 | #define STATUS_CHECK_INTERVAL 60000L 83 | 84 | // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. 85 | if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) 86 | { 87 | // report status to Blynk 88 | heartBeatPrint(); 89 | 90 | checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; 91 | } 92 | } 93 | 94 | bool valid_apn = false; 95 | bool GSM_CONNECT_OK = false; 96 | 97 | void setup() 98 | { 99 | // Set console baud rate 100 | SerialMon.begin(115200); 101 | while (!SerialMon); 102 | 103 | delay(200); 104 | 105 | SerialMon.print(F("\nStart ESP32_MRD_GSM (Simultaneous WiFi+GSM) using ")); 106 | SerialMon.print(CurrentFileFS); 107 | SerialMon.print(F(" on ")); SerialMon.println(ARDUINO_BOARD); 108 | SerialMon.println(BLYNK_GSM_MANAGER_VERSION); 109 | 110 | #if USE_BLYNK_WM 111 | #if USING_MRD 112 | Serial.println(ESP_MULTI_RESET_DETECTOR_VERSION); 113 | #else 114 | Serial.println(ESP_DOUBLE_RESET_DETECTOR_VERSION); 115 | #endif 116 | #endif 117 | 118 | // Set-up modem reset, enable, power pins 119 | pinMode(MODEM_PWKEY, OUTPUT); 120 | pinMode(MODEM_RST, OUTPUT); 121 | pinMode(MODEM_POWER_ON, OUTPUT); 122 | 123 | digitalWrite(MODEM_PWKEY, LOW); 124 | digitalWrite(MODEM_RST, HIGH); 125 | digitalWrite(MODEM_POWER_ON, HIGH); 126 | 127 | SerialMon.println(F("Set GSM module baud rate")); 128 | 129 | // Set GSM module baud rate 130 | //SerialAT.begin(115200); 131 | SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX); 132 | delay(3000); 133 | 134 | Serial.println(F("Use WiFi to connect Blynk")); 135 | 136 | #if USE_BLYNK_WM 137 | 138 | // Set config portal SSID and Password 139 | Blynk_WF.setConfigPortal("TestPortal-ESP32", "TestPortalPass"); 140 | 141 | // Use configurable AP IP, instead of default IP 192.168.4.1 142 | Blynk_WF.setConfigPortalIP(IPAddress(192, 168, 232, 1)); 143 | // Set config portal channel, default = 1. Use 0 => random channel from 1-12 to avoid conflict 144 | Blynk_WF.setConfigPortalChannel(0); 145 | 146 | // Select either one of these to set static IP + DNS 147 | Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0)); 148 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 149 | // IPAddress(192, 168, 2, 1), IPAddress(8, 8, 8, 8)); 150 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 151 | // IPAddress(4, 4, 4, 4), IPAddress(8, 8, 8, 8)); 152 | 153 | // Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX 154 | //Blynk_WF.begin(); 155 | // Use this to personalize DHCP hostname (RFC952 conformed) 156 | // 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char 157 | Blynk_WF.begin("ESP32-WiFi-GSM"); 158 | 159 | #else 160 | Blynk_WF.begin(wifi_blynk_tok, ssid, pass, blynk_server, BLYNK_HARDWARE_PORT); 161 | 162 | Blynk_GSM.config(modem, gsm_blynk_tok, blynk_server, BLYNK_HARDWARE_PORT); 163 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(apn, gprsUser, gprsPass); 164 | 165 | if (GSM_CONNECT_OK) 166 | Blynk_GSM.connect(); 167 | #endif 168 | 169 | #if USE_BLYNK_WM 170 | Blynk_WF_Configuration localBlynkGSM_ESP32_config; 171 | 172 | Blynk_WF.getFullConfigData(&localBlynkGSM_ESP32_config); 173 | 174 | Serial.print(F("gprs apn = ")); 175 | Serial.println(localBlynkGSM_ESP32_config.apn); 176 | 177 | if ( Blynk.inConfigPortal() || (String(localBlynkGSM_ESP32_config.apn) == NO_CONFIG) ) 178 | { 179 | Serial.println(F("DRD/MRD, Forced Config Portal or No valid stored apn. Must run only WiFi to Open config portal")); 180 | valid_apn = false; 181 | } 182 | else 183 | { 184 | valid_apn = true; 185 | 186 | for (uint16_t index = 0; index < NUM_BLYNK_CREDENTIALS; index++) 187 | { 188 | Blynk_GSM.config(modem, localBlynkGSM_ESP32_config.Blynk_Creds[index].gsm_blynk_token, 189 | localBlynkGSM_ESP32_config.Blynk_Creds[index].blynk_server, localBlynkGSM_ESP32_config.blynk_port); 190 | 191 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(localBlynkGSM_ESP32_config.apn, localBlynkGSM_ESP32_config.gprsUser, 192 | localBlynkGSM_ESP32_config.gprsPass); 193 | 194 | if (GSM_CONNECT_OK) 195 | { 196 | if ( Blynk_GSM.connect() == true ) 197 | break; 198 | } 199 | } 200 | } 201 | #endif 202 | } 203 | 204 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 205 | void displayCredentials() 206 | { 207 | Serial.println(F("\nYour stored Credentials :")); 208 | 209 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 210 | { 211 | Serial.print(myMenuItems[i].displayName); 212 | Serial.print(F(" = ")); 213 | Serial.println(myMenuItems[i].pdata); 214 | } 215 | } 216 | #endif 217 | 218 | void loop() 219 | { 220 | Blynk_WF.run(); 221 | 222 | #if USE_BLYNK_WM 223 | if (valid_apn) 224 | #endif 225 | { 226 | if (GSM_CONNECT_OK) 227 | Blynk_GSM.run(); 228 | } 229 | 230 | check_status(); 231 | 232 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 233 | static bool displayedCredentials = false; 234 | 235 | if (!displayedCredentials) 236 | { 237 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 238 | { 239 | if (!strlen(myMenuItems[i].pdata)) 240 | { 241 | break; 242 | } 243 | 244 | if ( i == (NUM_MENU_ITEMS - 1) ) 245 | { 246 | displayedCredentials = true; 247 | displayCredentials(); 248 | } 249 | } 250 | } 251 | #endif 252 | } 253 | -------------------------------------------------------------------------------- /examples/ESP32_MRD_GSM/defines.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | defines.h 3 | For ESP32 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #ifndef defines_h 12 | #define defines_h 13 | 14 | #ifndef ESP32 15 | #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting. 16 | #endif 17 | 18 | #define BLYNK_PRINT Serial 19 | #define BLYNK_HEARTBEAT 60 20 | 21 | #define BLYNK_WM_DEBUG 1 22 | 23 | #define USING_MRD true 24 | 25 | #if USING_MRD 26 | // These definitions must be placed before #include to be used 27 | // Otherwise, default values (MRD_TIMES = 3, MRD_TIMEOUT = 10 seconds and MRD_ADDRESS = 0) will be used 28 | // Number of subsequent resets during MRD_TIMEOUT to activate 29 | #define MRD_TIMES 3 30 | 31 | // Number of seconds after reset during which a subseqent reset will be considered a mlti reset. 32 | #define MRD_TIMEOUT 10 33 | 34 | // RTC/EEPPROM Address for the MultiResetDetector to use 35 | #define MRD_ADDRESS 0 36 | 37 | #define MULTIRESETDETECTOR_DEBUG true 38 | 39 | #warning Using MultiResetDetector MRD 40 | #else 41 | // These definitions must be placed before #include to be used 42 | // Otherwise, default values (DRD_TIMEOUT = 10 seconds and DRD_ADDRESS = 0) will be used 43 | // Number of subsequent resets during DRD_TIMEOUT to activate 44 | 45 | // Number of seconds after reset during which a subseqent reset will be considered a mlti reset. 46 | #define DRD_TIMEOUT 10 47 | 48 | // RTC/EEPPROM Address for the DoubleResetDetector to use 49 | #define DRD_ADDRESS 0 50 | 51 | #define DOUBLERESETDETECTOR_DEBUG true 52 | 53 | #warning Using DoubleResetDetector DRD 54 | #endif 55 | 56 | // Not use #define USE_LITTLEFS and #define USE_SPIFFS => using SPIFFS for configuration data in WiFiManager 57 | // (USE_LITTLEFS == false) and (USE_SPIFFS == false) => using EEPROM for configuration data in WiFiManager 58 | // (USE_LITTLEFS == true) and (USE_SPIFFS == false) => using LITTLEFS for configuration data in WiFiManager 59 | // (USE_LITTLEFS == true) and (USE_SPIFFS == true) => using LITTLEFS for configuration data in WiFiManager 60 | // (USE_LITTLEFS == false) and (USE_SPIFFS == true) => using SPIFFS for configuration data in WiFiManager 61 | // Those above #define's must be placed before #include 62 | 63 | #define USE_LITTLEFS true 64 | #define USE_SPIFFS false 65 | 66 | #if USE_LITTLEFS 67 | #define CurrentFileFS F("LittleFS") 68 | #elif USE_SPIFFS 69 | #define CurrentFileFS F("SPIFFS") 70 | #else 71 | #define CurrentFileFS F("EEPROM") 72 | 73 | // EEPROM_SIZE must be <= 2048 and >= CONFIG_DATA_SIZE (currently 172 bytes) 74 | #define EEPROM_SIZE (2 * 1024) 75 | // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE 76 | #define EEPROM_START 0 77 | #endif 78 | 79 | // Force some params in Blynk, only valid for library version 1.0.1 and later 80 | #define TIMEOUT_RECONNECT_WIFI 10000L 81 | #define RESET_IF_CONFIG_TIMEOUT true 82 | #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5 83 | 84 | // Config Timeout 120s (default 60s) 85 | #define CONFIG_TIMEOUT 120000L 86 | // Those above #define's must be placed before #include 87 | 88 | // TTGO T-Call pin definitions 89 | #define MODEM_RST 5 90 | #define MODEM_PWKEY 4 91 | #define MODEM_POWER_ON 23 92 | 93 | #define MODEM_TX 27 94 | #define MODEM_RX 26 95 | 96 | #define I2C_SDA 21 97 | #define I2C_SCL 22 98 | 99 | // Select your modem: 100 | #define TINY_GSM_MODEM_SIM800 101 | //#define TINY_GSM_MODEM_SIM808 102 | //#define TINY_GSM_MODEM_SIM868 103 | //#define TINY_GSM_MODEM_SIM900 104 | //#define TINY_GSM_MODEM_SIM5300 105 | //#define TINY_GSM_MODEM_SIM5320 106 | //#define TINY_GSM_MODEM_SIM5360 107 | //#define TINY_GSM_MODEM_SIM7000 108 | //#define TINY_GSM_MODEM_SIM7100 109 | //#define TINY_GSM_MODEM_SIM7500 110 | //#define TINY_GSM_MODEM_SIM7600 111 | //#define TINY_GSM_MODEM_SIM7800 112 | //#define TINY_GSM_MODEM_UBLOX 113 | //#define TINY_GSM_MODEM_SARAR4 114 | //#define TINY_GSM_MODEM_M95 115 | //#define TINY_GSM_MODEM_BG96 116 | //#define TINY_GSM_MODEM_A6 117 | //#define TINY_GSM_MODEM_A7 118 | //#define TINY_GSM_MODEM_M590 119 | //#define TINY_GSM_MODEM_MC60 120 | //#define TINY_GSM_MODEM_MC60E 121 | //#define TINY_GSM_MODEM_XBEE 122 | //#define TINY_GSM_MODEM_SEQUANS_MONARCH 123 | 124 | // Increase RX buffer if needed 125 | #define TINY_GSM_RX_BUFFER 1024 126 | 127 | #include 128 | 129 | //#define USE_BLYNK_WM false 130 | #define USE_BLYNK_WM true 131 | 132 | #include 133 | 134 | #if USE_BLYNK_WM 135 | #define USE_DYNAMIC_PARAMETERS true 136 | 137 | #include 138 | 139 | #else 140 | #include 141 | 142 | // Your WiFi credentials. 143 | #define ssid "****" 144 | #define pass "****" 145 | 146 | #define USE_LOCAL_SERVER true 147 | //#define USE_LOCAL_SERVER false 148 | 149 | #if USE_LOCAL_SERVER 150 | #define wifi_blynk_tok "****" 151 | #define gsm_blynk_tok "****" 152 | //#define blynk_server "account.duckdns.org" 153 | // Use direct IPAddress in case GPRS can't use DDNS fast enough and can't connect 154 | #define blynk_server "xxx.xxx.xxx.xxx" 155 | #else 156 | #define wifi_blynk_tok "****" 157 | #define gsm_blynk_tok "****" 158 | #define blynk_server "blynk-cloud.com" 159 | #endif 160 | 161 | #define apn "rogers-core-appl1.apn" 162 | #define gprsUser "" //"wapuser1" 163 | #define gprsPass "" //"wap" 164 | 165 | #endif //USE_BLYNK_WM 166 | 167 | #define BLYNK_HARDWARE_PORT 8080 168 | 169 | // Set serial for debug console (to the Serial Monitor, default speed 115200) 170 | #define SerialMon Serial 171 | 172 | #define RXD2 16 173 | #define TXD2 17 174 | 175 | // Use ESP32 Serial2 for GSM 176 | #define SerialAT Serial2 177 | 178 | // Uncomment this if you want to see all AT commands 179 | #define DUMP_AT_COMMANDS false 180 | 181 | #if DUMP_AT_COMMANDS 182 | #include 183 | StreamDebugger debugger(SerialAT, SerialMon); 184 | TinyGsm modem(debugger); 185 | #else 186 | TinyGsm modem(SerialAT); 187 | #endif 188 | 189 | #define HOST_NAME "ESP32-GSM-WiFi" 190 | 191 | #endif //defines_h 192 | -------------------------------------------------------------------------------- /examples/ESP32_MRD_GSM/dynamicParams.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | dynamicParams.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef dynamicParams_h 13 | #define dynamicParams_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | #if (USE_DYNAMIC_PARAMETERS) 18 | #warning USE_DYNAMIC_PARAMETERS 19 | #endif 20 | 21 | // USE_DYNAMIC_PARAMETERS defined in defined.h 22 | 23 | /////////////// Start dynamic Credentials /////////////// 24 | 25 | //Defined in 26 | /************************************** 27 | #define MAX_ID_LEN 5 28 | #define MAX_DISPLAY_NAME_LEN 16 29 | 30 | typedef struct 31 | { 32 | char id [MAX_ID_LEN + 1]; 33 | char displayName [MAX_DISPLAY_NAME_LEN + 1]; 34 | char *pdata; 35 | uint8_t maxlen; 36 | } MenuItem; 37 | **************************************/ 38 | 39 | #if USE_DYNAMIC_PARAMETERS 40 | 41 | #define MAX_MQTT_SERVER_LEN 34 42 | char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.ddns.net"; 43 | 44 | #define MAX_MQTT_PORT_LEN 6 45 | char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "1883"; 46 | 47 | #define MAX_MQTT_USERNAME_LEN 34 48 | char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "mqtt-user"; 49 | 50 | #define MAX_MQTT_PW_LEN 34 51 | char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "mqtt-pass"; 52 | 53 | #define MAX_MQTT_SUBS_TOPIC_LEN 34 54 | char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "SubTopic_ESP32_GSM"; 55 | 56 | #define MAX_MQTT_PUB_TOPIC_LEN 34 57 | char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "PubTopic_ESP32_GSM"; 58 | 59 | MenuItem myMenuItems [] = 60 | { 61 | { "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN }, 62 | { "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN }, 63 | { "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN }, 64 | { "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN }, 65 | { "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN }, 66 | { "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN }, 67 | }; 68 | 69 | uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; 70 | 71 | #else 72 | 73 | MenuItem myMenuItems [] = {}; 74 | 75 | uint16_t NUM_MENU_ITEMS = 0; 76 | #endif 77 | 78 | 79 | /////// // End dynamic Credentials /////////// 80 | 81 | #endif // #if USE_BLYNK_WM 82 | 83 | #endif //dynamicParams_h 84 | -------------------------------------------------------------------------------- /examples/ESP8266_GSM/Credentials.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | Credentials.h 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #ifndef Credentials_h 12 | #define Credentials_h 13 | 14 | /// Start Default Config Data ////////////////// 15 | 16 | /* 17 | // Defined in 18 | 19 | #define SSID_MAX_LEN 32 20 | //From v1.0.10, WPA2 passwords can be up to 63 characters long. 21 | #define PASS_MAX_LEN 64 22 | 23 | typedef struct 24 | { 25 | char wifi_ssid[SSID_MAX_LEN]; 26 | char wifi_pw [PASS_MAX_LEN]; 27 | } WiFi_Credentials; 28 | 29 | #define BLYNK_SERVER_MAX_LEN 32 30 | #define BLYNK_TOKEN_MAX_LEN 36 31 | 32 | typedef struct 33 | { 34 | char blynk_server [BLYNK_SERVER_MAX_LEN]; 35 | char wifi_blynk_token [BLYNK_TOKEN_MAX_LEN]; 36 | char gsm_blynk_token [BLYNK_TOKEN_MAX_LEN]; 37 | } Blynk_Credentials; 38 | 39 | #define NUM_WIFI_CREDENTIALS 2 40 | #define NUM_BLYNK_CREDENTIALS 2 41 | 42 | // Configurable items besides fixed Header 43 | #define NUM_CONFIGURABLE_ITEMS ( 6 + (2 * NUM_WIFI_CREDENTIALS) + (3 * NUM_BLYNK_CREDENTIALS) ) 44 | #define DEFAULT_GPRS_PIN "1234" 45 | 46 | typedef struct Configuration 47 | { 48 | char header [16]; 49 | WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS]; 50 | Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 51 | int blynk_port; 52 | // YOUR GSM / GPRS RELATED 53 | char apn [32]; 54 | char gprsUser [32]; 55 | char gprsPass [32]; 56 | char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 57 | // END OF YOUR GSM / GPRS RELATED 58 | char board_name [24]; 59 | int checkSum; 60 | } Blynk_WF_Configuration; 61 | 62 | */ 63 | 64 | //bool LOAD_DEFAULT_CONFIG_DATA = true; 65 | bool LOAD_DEFAULT_CONFIG_DATA = false; 66 | 67 | Blynk_WF_Configuration defaultConfig = 68 | { 69 | //char header[16], dummy, not used 70 | "GSM", 71 | //WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS] 72 | //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw 73 | "SSID1", "password1", 74 | "SSID2", "password2", 75 | // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 76 | // Blynk_Creds.blynk_server, Blynk_Creds.wifi_blynk_token and Blynk_Creds.gsm_blynk_token 77 | "account.ddns.net", "wifi_token", "gsm_token", 78 | "account.duckdns.org", "wifi_token1", "gsm_token1", 79 | //int blynk_port; 80 | 8080, 81 | // YOUR GSM / GPRS RELATED 82 | //char apn [32]; 83 | "rogers-core-appl1.apn", 84 | //char gprsUser [32]; 85 | "wapuser1", 86 | //char gprsPass [32]; 87 | "wap", 88 | //char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 89 | "1245678", 90 | // END OF YOUR GSM / GPRS RELATED 91 | //char board_name [24]; 92 | "8266-GSM-WiFi", 93 | //int checkSum, dummy, not used 94 | 0 95 | }; 96 | 97 | /////////// End Default Config Data ///////////// 98 | 99 | 100 | #endif //Credentials_h 101 | -------------------------------------------------------------------------------- /examples/ESP8266_GSM/ESP8266_GSM.ino: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | ESP8266_GSM.ino 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #include "defines.h" 12 | 13 | #if USE_BLYNK_WM 14 | #include "Credentials.h" 15 | #include "dynamicParams.h" 16 | 17 | #define BLYNK_PIN_FORCED_CONFIG V10 18 | #define BLYNK_PIN_FORCED_PERS_CONFIG V20 19 | 20 | // Use button V10 (BLYNK_PIN_FORCED_CONFIG) to forced Config Portal 21 | BLYNK_WRITE(BLYNK_PIN_FORCED_CONFIG) 22 | { 23 | if (param.asInt()) 24 | { 25 | Serial.println( F("\nCP Button Hit. Rebooting") ); 26 | 27 | // This will keep CP once, clear after reset, even you didn't enter CP at all. 28 | Blynk.resetAndEnterConfigPortal(); 29 | } 30 | } 31 | 32 | // Use button V20 (BLYNK_PIN_FORCED_PERS_CONFIG) to forced Persistent Config Portal 33 | BLYNK_WRITE(BLYNK_PIN_FORCED_PERS_CONFIG) 34 | { 35 | if (param.asInt()) 36 | { 37 | Serial.println( F("\nPersistent CP Button Hit. Rebooting") ); 38 | 39 | // This will keep CP forever, until you successfully enter CP, and Save data to clear the flag. 40 | Blynk.resetAndEnterConfigPortalPersistent(); 41 | } 42 | } 43 | #endif 44 | 45 | void heartBeatPrint() 46 | { 47 | static int num = 1; 48 | 49 | if (Blynk_WF.connected()) 50 | { 51 | Serial.print(F("B")); 52 | } 53 | else 54 | { 55 | Serial.print(F("F")); 56 | } 57 | 58 | if (Blynk_GSM.connected()) 59 | { 60 | Serial.print(F("G")); 61 | } 62 | else 63 | { 64 | Serial.print(F("F")); 65 | } 66 | 67 | if (num == 40) 68 | { 69 | Serial.println(); 70 | num = 1; 71 | } 72 | else if (num++ % 10 == 0) 73 | { 74 | Serial.print(F(" ")); 75 | } 76 | } 77 | 78 | void check_status() 79 | { 80 | static unsigned long checkstatus_timeout = 0; 81 | 82 | #define STATUS_CHECK_INTERVAL 60000L 83 | 84 | // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. 85 | if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) 86 | { 87 | // report status to Blynk 88 | heartBeatPrint(); 89 | 90 | checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; 91 | } 92 | } 93 | 94 | bool valid_apn = false; 95 | bool GSM_CONNECT_OK = false; 96 | 97 | void setup() 98 | { 99 | // Set console baud rate 100 | SerialMon.begin(115200); 101 | while (!SerialMon); 102 | 103 | delay(200); 104 | 105 | SerialMon.print(F("\nStart ESP8266_GSM (Simultaneous WiFi+GSM) using ")); 106 | SerialMon.print(CurrentFileFS); 107 | SerialMon.print(F(" on ")); SerialMon.println(ARDUINO_BOARD); 108 | SerialMon.println(BLYNK_GSM_MANAGER_VERSION); 109 | 110 | // Set-up modem reset, enable, power pins 111 | pinMode(MODEM_PWKEY, OUTPUT); 112 | pinMode(MODEM_RST, OUTPUT); 113 | pinMode(MODEM_POWER_ON, OUTPUT); 114 | 115 | digitalWrite(MODEM_PWKEY, LOW); 116 | digitalWrite(MODEM_RST, HIGH); 117 | digitalWrite(MODEM_POWER_ON, HIGH); 118 | 119 | SerialMon.println(F("Set GSM module baud rate")); 120 | 121 | // Set GSM module baud rate 122 | SerialAT.begin(115200); 123 | 124 | delay(3000); 125 | 126 | Serial.println(F("Use WiFi to connect Blynk")); 127 | 128 | #if USE_BLYNK_WM 129 | 130 | // Set config portal SSID and Password 131 | Blynk_WF.setConfigPortal("TestPortal-ESP8266", "TestPortalPass"); 132 | 133 | // Use configurable AP IP, instead of default IP 192.168.4.1 134 | Blynk_WF.setConfigPortalIP(IPAddress(192, 168, 232, 1)); 135 | // Set config portal channel, default = 1. Use 0 => random channel from 1-12 to avoid conflict 136 | Blynk_WF.setConfigPortalChannel(0); 137 | 138 | // Select either one of these to set static IP + DNS 139 | Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0)); 140 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 141 | // IPAddress(192, 168, 2, 1), IPAddress(8, 8, 8, 8)); 142 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 143 | // IPAddress(4, 4, 4, 4), IPAddress(8, 8, 8, 8)); 144 | 145 | // Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX 146 | //Blynk_WF.begin(); 147 | // Use this to personalize DHCP hostname (RFC952 conformed) 148 | // 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char 149 | Blynk_WF.begin("ESP8266-WiFi-GSM"); 150 | 151 | #else 152 | Blynk_WF.begin(wifi_blynk_tok, ssid, pass, blynk_server, BLYNK_HARDWARE_PORT); 153 | 154 | Blynk_GSM.config(modem, gsm_blynk_tok, blynk_server, BLYNK_HARDWARE_PORT); 155 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(apn, gprsUser, gprsPass); 156 | 157 | if (GSM_CONNECT_OK) 158 | Blynk_GSM.connect(); 159 | #endif 160 | 161 | #if USE_BLYNK_WM 162 | Blynk_WF_Configuration localBlynkGSM_ESP8266_config; 163 | 164 | Blynk_WF.getFullConfigData(&localBlynkGSM_ESP8266_config); 165 | 166 | Serial.print(F("gprs apn = ")); 167 | Serial.println(localBlynkGSM_ESP8266_config.apn); 168 | 169 | if ( Blynk.inConfigPortal() || (String(localBlynkGSM_ESP8266_config.apn) == NO_CONFIG) ) 170 | { 171 | Serial.println(F("DRD/MRD, Forced Config Portal or No valid stored apn. Must run only WiFi to Open config portal")); 172 | valid_apn = false; 173 | } 174 | else 175 | { 176 | valid_apn = true; 177 | 178 | for (uint16_t index = 0; index < NUM_BLYNK_CREDENTIALS; index++) 179 | { 180 | Blynk_GSM.config(modem, localBlynkGSM_ESP8266_config.Blynk_Creds[index].gsm_blynk_token, 181 | localBlynkGSM_ESP8266_config.Blynk_Creds[index].blynk_server, localBlynkGSM_ESP8266_config.blynk_port); 182 | 183 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(localBlynkGSM_ESP8266_config.apn, localBlynkGSM_ESP8266_config.gprsUser, 184 | localBlynkGSM_ESP8266_config.gprsPass); 185 | 186 | if (GSM_CONNECT_OK) 187 | { 188 | if ( Blynk_GSM.connect() == true ) 189 | break; 190 | } 191 | } 192 | } 193 | #endif 194 | } 195 | 196 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 197 | void displayCredentials() 198 | { 199 | Serial.println(F("\nYour stored Credentials :")); 200 | 201 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 202 | { 203 | Serial.print(myMenuItems[i].displayName); 204 | Serial.print(F(" = ")); 205 | Serial.println(myMenuItems[i].pdata); 206 | } 207 | } 208 | #endif 209 | 210 | void loop() 211 | { 212 | Blynk_WF.run(); 213 | 214 | #if USE_BLYNK_WM 215 | if (valid_apn) 216 | #endif 217 | { 218 | if (GSM_CONNECT_OK) 219 | Blynk_GSM.run(); 220 | } 221 | 222 | check_status(); 223 | 224 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 225 | static bool displayedCredentials = false; 226 | 227 | if (!displayedCredentials) 228 | { 229 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 230 | { 231 | if (!strlen(myMenuItems[i].pdata)) 232 | { 233 | break; 234 | } 235 | 236 | if ( i == (NUM_MENU_ITEMS - 1) ) 237 | { 238 | displayedCredentials = true; 239 | displayCredentials(); 240 | } 241 | } 242 | } 243 | #endif 244 | } 245 | -------------------------------------------------------------------------------- /examples/ESP8266_GSM/defines.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | defines.h 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #ifndef defines_h 12 | #define defines_h 13 | 14 | #ifndef ESP8266 15 | #error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting. 16 | #endif 17 | 18 | #define BLYNK_PRINT Serial 19 | #define BLYNK_HEARTBEAT 60 20 | 21 | #define DOUBLERESETDETECTOR_DEBUG true //false 22 | #define BLYNK_WM_DEBUG 1 23 | 24 | // #define USE_SPIFFS and USE_LITTLEFS false => using EEPROM for configuration data in WiFiManager 25 | // #define USE_LITTLEFS true => using LITTLEFS for configuration data in WiFiManager 26 | // #define USE_LITTLEFS false and USE_SPIFFS true => using SPIFFS for configuration data in WiFiManager 27 | // Be sure to define USE_LITTLEFS and USE_SPIFFS before #include 28 | // From ESP8266 core 2.7.1, SPIFFS will be deprecated and to be replaced by LittleFS 29 | // Select USE_LITTLEFS (higher priority) or USE_SPIFFS 30 | 31 | #define USE_LITTLEFS true 32 | //#define USE_LITTLEFS false 33 | #define USE_SPIFFS false 34 | //#define USE_SPIFFS true 35 | 36 | #if USE_LITTLEFS 37 | //LittleFS has higher priority 38 | #define CurrentFileFS F("LittleFS") 39 | #ifdef USE_SPIFFS 40 | #undef USE_SPIFFS 41 | #endif 42 | #define USE_SPIFFS false 43 | #elif USE_SPIFFS 44 | #define CurrentFileFS F("SPIFFS") 45 | #else 46 | #define CurrentFileFS F("EEPROM") 47 | // EEPROM_SIZE must be <= 4096 and >= CONFIG_DATA_SIZE (currently 172 bytes) 48 | #define EEPROM_SIZE (4 * 1024) 49 | // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE 50 | #define EEPROM_START 0 51 | #endif 52 | 53 | // Force some params in Blynk, only valid for library version 1.0.1 and later 54 | #define TIMEOUT_RECONNECT_WIFI 10000L 55 | #define RESET_IF_CONFIG_TIMEOUT true 56 | #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5 57 | 58 | // Config Timeout 120s (default 60s) 59 | #define CONFIG_TIMEOUT 120000L 60 | // Those above #define's must be placed before #include 61 | 62 | 63 | #define MODEM_RST D0 // Pin D0 mapped to pin GPIO16/USER/WAKE of ESP8266. This pin is also used for Onboard-Blue LED. 64 | #define MODEM_PWKEY D5 // Pin D5 mapped to pin GPIO14/HSCLK of ESP8266 65 | #define MODEM_POWER_ON D6 // Pin D6 mapped to pin GPIO12/HMISO of ESP8266 66 | 67 | #define MODEM_TX D8 // Pin D8 mapped to pin GPIO15/TXD2/HCS of ESP8266 68 | #define MODEM_RX D7 // Pin D7 mapped to pin GPIO13/RXD2/HMOSI of ESP8266 69 | 70 | #define I2C_SDA D2 // Pin D2 mapped to pin GPIO4/SDA of ESP8266 71 | #define I2C_SCL D1 // Pin D1 mapped to pin GPIO5/SCL of ESP8266 72 | 73 | // Select your modem: 74 | #define TINY_GSM_MODEM_SIM800 75 | //#define TINY_GSM_MODEM_SIM808 76 | //#define TINY_GSM_MODEM_SIM868 77 | //#define TINY_GSM_MODEM_SIM900 78 | //#define TINY_GSM_MODEM_SIM5300 79 | //#define TINY_GSM_MODEM_SIM5320 80 | //#define TINY_GSM_MODEM_SIM5360 81 | //#define TINY_GSM_MODEM_SIM7000 82 | //#define TINY_GSM_MODEM_SIM7100 83 | //#define TINY_GSM_MODEM_SIM7500 84 | //#define TINY_GSM_MODEM_SIM7600 85 | //#define TINY_GSM_MODEM_SIM7800 86 | //#define TINY_GSM_MODEM_UBLOX 87 | //#define TINY_GSM_MODEM_SARAR4 88 | //#define TINY_GSM_MODEM_M95 89 | //#define TINY_GSM_MODEM_BG96 90 | //#define TINY_GSM_MODEM_A6 91 | //#define TINY_GSM_MODEM_A7 92 | //#define TINY_GSM_MODEM_M590 93 | //#define TINY_GSM_MODEM_MC60 94 | //#define TINY_GSM_MODEM_MC60E 95 | //#define TINY_GSM_MODEM_XBEE 96 | //#define TINY_GSM_MODEM_SEQUANS_MONARCH 97 | 98 | // Increase RX buffer if needed 99 | #define TINY_GSM_RX_BUFFER 1024 100 | 101 | #include 102 | 103 | //#define USE_BLYNK_WM false 104 | #define USE_BLYNK_WM true 105 | 106 | #include 107 | 108 | #if USE_BLYNK_WM 109 | #define USE_DYNAMIC_PARAMETERS true 110 | 111 | #include 112 | 113 | #else 114 | #include 115 | 116 | // Your WiFi credentials. 117 | #define ssid "****" 118 | #define pass "****" 119 | 120 | #define USE_LOCAL_SERVER true 121 | //#define USE_LOCAL_SERVER false 122 | 123 | #if USE_LOCAL_SERVER 124 | #define wifi_blynk_tok "****" 125 | #define gsm_blynk_tok "****" 126 | //#define blynk_server "account.duckdns.org" 127 | // Use direct IPAddress in case GPRS can't use DDNS fast enough and can't connect 128 | #define blynk_server "xxx.xxx.xxx.xxx" 129 | #else 130 | #define wifi_blynk_tok "****" 131 | #define gsm_blynk_tok "****" 132 | #define blynk_server "blynk-cloud.com" 133 | #endif 134 | 135 | #define apn "rogers-core-appl1.apn" 136 | #define gprsUser "" //"wapuser1" 137 | #define gprsPass "" //"wap" 138 | 139 | #endif //USE_BLYNK_WM 140 | 141 | #define BLYNK_HARDWARE_PORT 8080 142 | 143 | // Set serial for debug console (to the Serial Monitor, default speed 115200) 144 | #define SerialMon Serial 145 | 146 | #include 147 | SoftwareSerial SerialAT(MODEM_RX, MODEM_TX); // RX, TX 148 | 149 | // Uncomment this if you want to see all AT commands 150 | #define DUMP_AT_COMMANDS false 151 | 152 | #if DUMP_AT_COMMANDS 153 | #include 154 | StreamDebugger debugger(SerialAT, SerialMon); 155 | TinyGsm modem(debugger); 156 | #else 157 | TinyGsm modem(SerialAT); 158 | #endif 159 | 160 | #define HOST_NAME "8266-GSM-WiFi" 161 | 162 | #endif //defines_h 163 | -------------------------------------------------------------------------------- /examples/ESP8266_GSM/dynamicParams.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | dynamicParams.h for ESP8266_GSM.ino 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #ifndef dynamicParams_h 12 | #define dynamicParams_h 13 | 14 | #if (USE_DYNAMIC_PARAMETERS) 15 | #warning USE_DYNAMIC_PARAMETERS 16 | #endif 17 | 18 | // USE_DYNAMIC_PARAMETERS defined in defined.h 19 | 20 | /////////////// Start dynamic Credentials /////////////// 21 | 22 | //Defined in 23 | /************************************** 24 | #define MAX_ID_LEN 5 25 | #define MAX_DISPLAY_NAME_LEN 16 26 | 27 | typedef struct 28 | { 29 | char id [MAX_ID_LEN + 1]; 30 | char displayName [MAX_DISPLAY_NAME_LEN + 1]; 31 | char *pdata; 32 | uint8_t maxlen; 33 | } MenuItem; 34 | **************************************/ 35 | 36 | #if USE_DYNAMIC_PARAMETERS 37 | 38 | #define MAX_MQTT_SERVER_LEN 34 39 | char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.ddns.net"; 40 | 41 | #define MAX_MQTT_PORT_LEN 6 42 | char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "1883"; 43 | 44 | #define MAX_MQTT_USERNAME_LEN 34 45 | char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "mqtt-user"; 46 | 47 | #define MAX_MQTT_PW_LEN 34 48 | char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "mqtt-pass"; 49 | 50 | #define MAX_MQTT_SUBS_TOPIC_LEN 34 51 | char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "SubTopic_ESP8266_GSM"; 52 | 53 | #define MAX_MQTT_PUB_TOPIC_LEN 34 54 | char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "PubTopic_ESP8266_GSM"; 55 | 56 | MenuItem myMenuItems [] = 57 | { 58 | { "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN }, 59 | { "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN }, 60 | { "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN }, 61 | { "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN }, 62 | { "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN }, 63 | { "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN }, 64 | }; 65 | 66 | uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; 67 | 68 | #else 69 | 70 | MenuItem myMenuItems [] = {}; 71 | 72 | uint16_t NUM_MENU_ITEMS = 0; 73 | #endif 74 | 75 | 76 | /////// // End dynamic Credentials /////////// 77 | 78 | #endif //dynamicParams_h 79 | -------------------------------------------------------------------------------- /examples/ESP8266_GSM_SHT3x/Credentials.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | Credentials.h 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef Credentials_h 13 | #define Credentials_h 14 | 15 | /// Start Default Config Data ////////////////// 16 | 17 | /* 18 | // Defined in 19 | 20 | #define SSID_MAX_LEN 32 21 | //From v1.0.10, WPA2 passwords can be up to 63 characters long. 22 | #define PASS_MAX_LEN 64 23 | 24 | typedef struct 25 | { 26 | char wifi_ssid[SSID_MAX_LEN]; 27 | char wifi_pw [PASS_MAX_LEN]; 28 | } WiFi_Credentials; 29 | 30 | #define BLYNK_SERVER_MAX_LEN 32 31 | #define BLYNK_TOKEN_MAX_LEN 36 32 | 33 | typedef struct 34 | { 35 | char blynk_server [BLYNK_SERVER_MAX_LEN]; 36 | char wifi_blynk_token [BLYNK_TOKEN_MAX_LEN]; 37 | char gsm_blynk_token [BLYNK_TOKEN_MAX_LEN]; 38 | } Blynk_Credentials; 39 | 40 | #define NUM_WIFI_CREDENTIALS 2 41 | #define NUM_BLYNK_CREDENTIALS 2 42 | 43 | // Configurable items besides fixed Header 44 | #define NUM_CONFIGURABLE_ITEMS ( 6 + (2 * NUM_WIFI_CREDENTIALS) + (3 * NUM_BLYNK_CREDENTIALS) ) 45 | #define DEFAULT_GPRS_PIN "1234" 46 | 47 | typedef struct Configuration 48 | { 49 | char header [16]; 50 | WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS]; 51 | Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 52 | int blynk_port; 53 | // YOUR GSM / GPRS RELATED 54 | char apn [32]; 55 | char gprsUser [32]; 56 | char gprsPass [32]; 57 | char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 58 | // END OF YOUR GSM / GPRS RELATED 59 | char board_name [24]; 60 | int checkSum; 61 | } Blynk_WF_Configuration; 62 | 63 | */ 64 | 65 | //bool LOAD_DEFAULT_CONFIG_DATA = true; 66 | bool LOAD_DEFAULT_CONFIG_DATA = false; 67 | 68 | Blynk_WF_Configuration defaultConfig = 69 | { 70 | //char header[16], dummy, not used 71 | "GSM", 72 | //WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS] 73 | //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw 74 | "SSID1", "password1", 75 | "SSID2", "password2", 76 | // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 77 | // Blynk_Creds.blynk_server, Blynk_Creds.wifi_blynk_token and Blynk_Creds.gsm_blynk_token 78 | "account.ddns.net", "wifi_token", "gsm_token", 79 | "account.duckdns.org", "wifi_token1", "gsm_token1", 80 | //int blynk_port; 81 | 8080, 82 | // YOUR GSM / GPRS RELATED 83 | //char apn [32]; 84 | "rogers-core-appl1.apn", 85 | //char gprsUser [32]; 86 | "wapuser1", 87 | //char gprsPass [32]; 88 | "wap", 89 | //char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 90 | "1245678", 91 | // END OF YOUR GSM / GPRS RELATED 92 | //char board_name [24]; 93 | "8266-GSM-WiFi", 94 | //int checkSum, dummy, not used 95 | 0 96 | }; 97 | 98 | /////////// End Default Config Data ///////////// 99 | 100 | 101 | #endif //Credentials_h 102 | -------------------------------------------------------------------------------- /examples/ESP8266_GSM_SHT3x/defines.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | defines.h 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef defines_h 13 | #define defines_h 14 | 15 | 16 | #ifndef ESP8266 17 | #error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting. 18 | #endif 19 | 20 | #define BLYNK_PRINT Serial 21 | #define BLYNK_HEARTBEAT 60 22 | 23 | #define DOUBLERESETDETECTOR_DEBUG true //false 24 | #define BLYNK_WM_DEBUG 1 25 | 26 | // #define USE_SPIFFS and USE_LITTLEFS false => using EEPROM for configuration data in WiFiManager 27 | // #define USE_LITTLEFS true => using LITTLEFS for configuration data in WiFiManager 28 | // #define USE_LITTLEFS false and USE_SPIFFS true => using SPIFFS for configuration data in WiFiManager 29 | // Be sure to define USE_LITTLEFS and USE_SPIFFS before #include 30 | // From ESP8266 core 2.7.1, SPIFFS will be deprecated and to be replaced by LittleFS 31 | // Select USE_LITTLEFS (higher priority) or USE_SPIFFS 32 | 33 | #define USE_LITTLEFS true 34 | //#define USE_LITTLEFS false 35 | #define USE_SPIFFS false 36 | //#define USE_SPIFFS true 37 | 38 | #if USE_LITTLEFS 39 | //LittleFS has higher priority 40 | #define CurrentFileFS F("LittleFS") 41 | #ifdef USE_SPIFFS 42 | #undef USE_SPIFFS 43 | #endif 44 | #define USE_SPIFFS false 45 | #elif USE_SPIFFS 46 | #define CurrentFileFS F("SPIFFS") 47 | #else 48 | #define CurrentFileFS F("EEPROM") 49 | // EEPROM_SIZE must be <= 4096 and >= CONFIG_DATA_SIZE (currently 172 bytes) 50 | #define EEPROM_SIZE (4 * 1024) 51 | // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE 52 | #define EEPROM_START 0 53 | #endif 54 | 55 | // Force some params in Blynk, only valid for library version 1.0.1 and later 56 | #define TIMEOUT_RECONNECT_WIFI 10000L 57 | #define RESET_IF_CONFIG_TIMEOUT true 58 | #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5 59 | 60 | // Config Timeout 120s (default 60s) 61 | #define CONFIG_TIMEOUT 120000L 62 | // Those above #define's must be placed before #include 63 | 64 | 65 | #define MODEM_RST D0 // Pin D0 mapped to pin GPIO16/USER/WAKE of ESP8266. This pin is also used for Onboard-Blue LED. 66 | #define MODEM_PWKEY D5 // Pin D5 mapped to pin GPIO14/HSCLK of ESP8266 67 | #define MODEM_POWER_ON D6 // Pin D6 mapped to pin GPIO12/HMISO of ESP8266 68 | 69 | #define MODEM_TX D8 // Pin D8 mapped to pin GPIO15/TXD2/HCS of ESP8266 70 | #define MODEM_RX D7 // Pin D7 mapped to pin GPIO13/RXD2/HMOSI of ESP8266 71 | 72 | #define I2C_SDA D2 // Pin D2 mapped to pin GPIO4/SDA of ESP8266 73 | #define I2C_SCL D1 // Pin D1 mapped to pin GPIO5/SCL of ESP8266 74 | 75 | // Select your modem: 76 | #define TINY_GSM_MODEM_SIM800 77 | //#define TINY_GSM_MODEM_SIM808 78 | //#define TINY_GSM_MODEM_SIM868 79 | //#define TINY_GSM_MODEM_SIM900 80 | //#define TINY_GSM_MODEM_SIM5300 81 | //#define TINY_GSM_MODEM_SIM5320 82 | //#define TINY_GSM_MODEM_SIM5360 83 | //#define TINY_GSM_MODEM_SIM7000 84 | //#define TINY_GSM_MODEM_SIM7100 85 | //#define TINY_GSM_MODEM_SIM7500 86 | //#define TINY_GSM_MODEM_SIM7600 87 | //#define TINY_GSM_MODEM_SIM7800 88 | //#define TINY_GSM_MODEM_UBLOX 89 | //#define TINY_GSM_MODEM_SARAR4 90 | //#define TINY_GSM_MODEM_M95 91 | //#define TINY_GSM_MODEM_BG96 92 | //#define TINY_GSM_MODEM_A6 93 | //#define TINY_GSM_MODEM_A7 94 | //#define TINY_GSM_MODEM_M590 95 | //#define TINY_GSM_MODEM_MC60 96 | //#define TINY_GSM_MODEM_MC60E 97 | //#define TINY_GSM_MODEM_XBEE 98 | //#define TINY_GSM_MODEM_SEQUANS_MONARCH 99 | 100 | // Increase RX buffer if needed 101 | #define TINY_GSM_RX_BUFFER 1024 102 | 103 | #include 104 | 105 | //#define USE_BLYNK_WM false 106 | #define USE_BLYNK_WM true 107 | 108 | #include 109 | 110 | #if USE_BLYNK_WM 111 | #define USE_DYNAMIC_PARAMETERS true 112 | 113 | #include 114 | 115 | #else 116 | #include 117 | 118 | // Your WiFi credentials. 119 | #define ssid "****" 120 | #define pass "****" 121 | 122 | #define USE_LOCAL_SERVER true 123 | //#define USE_LOCAL_SERVER false 124 | 125 | #if USE_LOCAL_SERVER 126 | #define wifi_blynk_tok "****" 127 | #define gsm_blynk_tok "****" 128 | //#define blynk_server "account.duckdns.org" 129 | // Use direct IPAddress in case GPRS can't use DDNS fast enough and can't connect 130 | #define blynk_server "xxx.xxx.xxx.xxx" 131 | #else 132 | #define wifi_blynk_tok "****" 133 | #define gsm_blynk_tok "****" 134 | #define blynk_server "blynk-cloud.com" 135 | #endif 136 | 137 | #define apn "rogers-core-appl1.apn" 138 | #define gprsUser "" //"wapuser1" 139 | #define gprsPass "" //"wap" 140 | 141 | #endif //USE_BLYNK_WM 142 | 143 | #define BLYNK_HARDWARE_PORT 8080 144 | 145 | // Set serial for debug console (to the Serial Monitor, default speed 115200) 146 | #define SerialMon Serial 147 | 148 | #include 149 | SoftwareSerial SerialAT(MODEM_RX, MODEM_TX); // RX, TX 150 | 151 | // Uncomment this if you want to see all AT commands 152 | #define DUMP_AT_COMMANDS false 153 | 154 | #if DUMP_AT_COMMANDS 155 | #include 156 | StreamDebugger debugger(SerialAT, SerialMon); 157 | TinyGsm modem(debugger); 158 | #else 159 | TinyGsm modem(SerialAT); 160 | #endif 161 | 162 | #define HOST_NAME "8266-GSM-WiFi" 163 | 164 | #endif //defines_h 165 | -------------------------------------------------------------------------------- /examples/ESP8266_GSM_SHT3x/dynamicParams.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | dynamicParams.h for ESP8266_GSM_SHT3x.ino 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef dynamicParams_h 13 | #define dynamicParams_h 14 | 15 | #if (USE_DYNAMIC_PARAMETERS) 16 | #warning USE_DYNAMIC_PARAMETERS 17 | #endif 18 | 19 | // USE_DYNAMIC_PARAMETERS defined in defined.h 20 | 21 | /////////////// Start dynamic Credentials /////////////// 22 | 23 | //Defined in 24 | /************************************** 25 | #define MAX_ID_LEN 5 26 | #define MAX_DISPLAY_NAME_LEN 16 27 | 28 | typedef struct 29 | { 30 | char id [MAX_ID_LEN + 1]; 31 | char displayName [MAX_DISPLAY_NAME_LEN + 1]; 32 | char *pdata; 33 | uint8_t maxlen; 34 | } MenuItem; 35 | **************************************/ 36 | 37 | #if USE_DYNAMIC_PARAMETERS 38 | 39 | #define MAX_MQTT_SERVER_LEN 34 40 | char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.ddns.net"; 41 | 42 | #define MAX_MQTT_PORT_LEN 6 43 | char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "1883"; 44 | 45 | #define MAX_MQTT_USERNAME_LEN 34 46 | char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "mqtt-user"; 47 | 48 | #define MAX_MQTT_PW_LEN 34 49 | char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "mqtt-pass"; 50 | 51 | #define MAX_MQTT_SUBS_TOPIC_LEN 34 52 | char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "SubTopic_ESP8266_GSM"; 53 | 54 | #define MAX_MQTT_PUB_TOPIC_LEN 34 55 | char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "PubTopic_ESP8266_GSM"; 56 | 57 | MenuItem myMenuItems [] = 58 | { 59 | { "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN }, 60 | { "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN }, 61 | { "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN }, 62 | { "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN }, 63 | { "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN }, 64 | { "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN }, 65 | }; 66 | 67 | uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; 68 | 69 | #else 70 | 71 | MenuItem myMenuItems [] = {}; 72 | 73 | uint16_t NUM_MENU_ITEMS = 0; 74 | #endif 75 | 76 | 77 | /////// // End dynamic Credentials /////////// 78 | 79 | #endif //dynamicParams_h 80 | -------------------------------------------------------------------------------- /examples/ESP8266_MRD_GSM/Credentials.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | Credentials.h 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #ifndef Credentials_h 12 | #define Credentials_h 13 | 14 | /// Start Default Config Data ////////////////// 15 | 16 | /* 17 | // Defined in 18 | 19 | #define SSID_MAX_LEN 32 20 | //From v1.0.10, WPA2 passwords can be up to 63 characters long. 21 | #define PASS_MAX_LEN 64 22 | 23 | typedef struct 24 | { 25 | char wifi_ssid[SSID_MAX_LEN]; 26 | char wifi_pw [PASS_MAX_LEN]; 27 | } WiFi_Credentials; 28 | 29 | #define BLYNK_SERVER_MAX_LEN 32 30 | #define BLYNK_TOKEN_MAX_LEN 36 31 | 32 | typedef struct 33 | { 34 | char blynk_server [BLYNK_SERVER_MAX_LEN]; 35 | char wifi_blynk_token [BLYNK_TOKEN_MAX_LEN]; 36 | char gsm_blynk_token [BLYNK_TOKEN_MAX_LEN]; 37 | } Blynk_Credentials; 38 | 39 | #define NUM_WIFI_CREDENTIALS 2 40 | #define NUM_BLYNK_CREDENTIALS 2 41 | 42 | // Configurable items besides fixed Header 43 | #define NUM_CONFIGURABLE_ITEMS ( 6 + (2 * NUM_WIFI_CREDENTIALS) + (3 * NUM_BLYNK_CREDENTIALS) ) 44 | #define DEFAULT_GPRS_PIN "1234" 45 | 46 | typedef struct Configuration 47 | { 48 | char header [16]; 49 | WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS]; 50 | Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 51 | int blynk_port; 52 | // YOUR GSM / GPRS RELATED 53 | char apn [32]; 54 | char gprsUser [32]; 55 | char gprsPass [32]; 56 | char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 57 | // END OF YOUR GSM / GPRS RELATED 58 | char board_name [24]; 59 | int checkSum; 60 | } Blynk_WF_Configuration; 61 | 62 | */ 63 | 64 | //bool LOAD_DEFAULT_CONFIG_DATA = true; 65 | bool LOAD_DEFAULT_CONFIG_DATA = false; 66 | 67 | Blynk_WF_Configuration defaultConfig = 68 | { 69 | //char header[16], dummy, not used 70 | "GSM", 71 | //WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS] 72 | //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw 73 | "SSID1", "password1", 74 | "SSID2", "password2", 75 | // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 76 | // Blynk_Creds.blynk_server, Blynk_Creds.wifi_blynk_token and Blynk_Creds.gsm_blynk_token 77 | "account.ddns.net", "wifi_token", "gsm_token", 78 | "account.duckdns.org", "wifi_token1", "gsm_token1", 79 | //int blynk_port; 80 | 8080, 81 | // YOUR GSM / GPRS RELATED 82 | //char apn [32]; 83 | "rogers-core-appl1.apn", 84 | //char gprsUser [32]; 85 | "wapuser1", 86 | //char gprsPass [32]; 87 | "wap", 88 | //char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 89 | "1245678", 90 | // END OF YOUR GSM / GPRS RELATED 91 | //char board_name [24]; 92 | "8266-GSM-WiFi", 93 | //int checkSum, dummy, not used 94 | 0 95 | }; 96 | 97 | /////////// End Default Config Data ///////////// 98 | 99 | 100 | #endif //Credentials_h 101 | -------------------------------------------------------------------------------- /examples/ESP8266_MRD_GSM/ESP8266_MRD_GSM.ino: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | ESP8266_MRD_GSM.ino 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #include "defines.h" 12 | 13 | #if USE_BLYNK_WM 14 | #include "Credentials.h" 15 | #include "dynamicParams.h" 16 | 17 | #define BLYNK_PIN_FORCED_CONFIG V10 18 | #define BLYNK_PIN_FORCED_PERS_CONFIG V20 19 | 20 | // Use button V10 (BLYNK_PIN_FORCED_CONFIG) to forced Config Portal 21 | BLYNK_WRITE(BLYNK_PIN_FORCED_CONFIG) 22 | { 23 | if (param.asInt()) 24 | { 25 | Serial.println( F("\nCP Button Hit. Rebooting") ); 26 | 27 | // This will keep CP once, clear after reset, even you didn't enter CP at all. 28 | Blynk.resetAndEnterConfigPortal(); 29 | } 30 | } 31 | 32 | // Use button V20 (BLYNK_PIN_FORCED_PERS_CONFIG) to forced Persistent Config Portal 33 | BLYNK_WRITE(BLYNK_PIN_FORCED_PERS_CONFIG) 34 | { 35 | if (param.asInt()) 36 | { 37 | Serial.println( F("\nPersistent CP Button Hit. Rebooting") ); 38 | 39 | // This will keep CP forever, until you successfully enter CP, and Save data to clear the flag. 40 | Blynk.resetAndEnterConfigPortalPersistent(); 41 | } 42 | } 43 | #endif 44 | 45 | void heartBeatPrint() 46 | { 47 | static int num = 1; 48 | 49 | if (Blynk_WF.connected()) 50 | { 51 | Serial.print(F("B")); 52 | } 53 | else 54 | { 55 | Serial.print(F("F")); 56 | } 57 | 58 | if (Blynk_GSM.connected()) 59 | { 60 | Serial.print(F("G")); 61 | } 62 | else 63 | { 64 | Serial.print(F("F")); 65 | } 66 | 67 | if (num == 40) 68 | { 69 | Serial.println(); 70 | num = 1; 71 | } 72 | else if (num++ % 10 == 0) 73 | { 74 | Serial.print(F(" ")); 75 | } 76 | } 77 | 78 | void check_status() 79 | { 80 | static unsigned long checkstatus_timeout = 0; 81 | 82 | #define STATUS_CHECK_INTERVAL 60000L 83 | 84 | // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. 85 | if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) 86 | { 87 | // report status to Blynk 88 | heartBeatPrint(); 89 | 90 | checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; 91 | } 92 | } 93 | 94 | bool valid_apn = false; 95 | bool GSM_CONNECT_OK = false; 96 | 97 | void setup() 98 | { 99 | // Set console baud rate 100 | SerialMon.begin(115200); 101 | while (!SerialMon); 102 | 103 | delay(200); 104 | 105 | SerialMon.print(F("\nStart ESP8266_MRD_GSM (Simultaneous WiFi+GSM) using ")); 106 | SerialMon.print(CurrentFileFS); 107 | SerialMon.print(F(" on ")); SerialMon.println(ARDUINO_BOARD); 108 | SerialMon.println(BLYNK_GSM_MANAGER_VERSION); 109 | 110 | #if USE_BLYNK_WM 111 | #if USING_MRD 112 | Serial.println(ESP_MULTI_RESET_DETECTOR_VERSION); 113 | #else 114 | Serial.println(ESP_DOUBLE_RESET_DETECTOR_VERSION); 115 | #endif 116 | #endif 117 | 118 | // Set-up modem reset, enable, power pins 119 | pinMode(MODEM_PWKEY, OUTPUT); 120 | pinMode(MODEM_RST, OUTPUT); 121 | pinMode(MODEM_POWER_ON, OUTPUT); 122 | 123 | digitalWrite(MODEM_PWKEY, LOW); 124 | digitalWrite(MODEM_RST, HIGH); 125 | digitalWrite(MODEM_POWER_ON, HIGH); 126 | 127 | SerialMon.println(F("Set GSM module baud rate")); 128 | 129 | // Set GSM module baud rate 130 | SerialAT.begin(115200); 131 | 132 | delay(3000); 133 | 134 | Serial.println(F("Use WiFi to connect Blynk")); 135 | 136 | #if USE_BLYNK_WM 137 | 138 | // Set config portal SSID and Password 139 | Blynk_WF.setConfigPortal("TestPortal-ESP8266", "TestPortalPass"); 140 | 141 | // Use configurable AP IP, instead of default IP 192.168.4.1 142 | Blynk_WF.setConfigPortalIP(IPAddress(192, 168, 232, 1)); 143 | // Set config portal channel, default = 1. Use 0 => random channel from 1-12 to avoid conflict 144 | Blynk_WF.setConfigPortalChannel(0); 145 | 146 | // Select either one of these to set static IP + DNS 147 | Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0)); 148 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 149 | // IPAddress(192, 168, 2, 1), IPAddress(8, 8, 8, 8)); 150 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 151 | // IPAddress(4, 4, 4, 4), IPAddress(8, 8, 8, 8)); 152 | 153 | // Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX 154 | //Blynk_WF.begin(); 155 | // Use this to personalize DHCP hostname (RFC952 conformed) 156 | // 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char 157 | Blynk_WF.begin("ESP8266-WiFi-GSM"); 158 | 159 | #else 160 | Blynk_WF.begin(wifi_blynk_tok, ssid, pass, blynk_server, BLYNK_HARDWARE_PORT); 161 | 162 | Blynk_GSM.config(modem, gsm_blynk_tok, blynk_server, BLYNK_HARDWARE_PORT); 163 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(apn, gprsUser, gprsPass); 164 | 165 | if (GSM_CONNECT_OK) 166 | Blynk_GSM.connect(); 167 | #endif 168 | 169 | #if USE_BLYNK_WM 170 | Blynk_WF_Configuration localBlynkGSM_ESP8266_config; 171 | 172 | Blynk_WF.getFullConfigData(&localBlynkGSM_ESP8266_config); 173 | 174 | Serial.print(F("gprs apn = ")); 175 | Serial.println(localBlynkGSM_ESP8266_config.apn); 176 | 177 | if ( Blynk.inConfigPortal() || (String(localBlynkGSM_ESP8266_config.apn) == NO_CONFIG) ) 178 | { 179 | Serial.println(F("DRD/MRD, Forced Config Portal or No valid stored apn. Must run only WiFi to Open config portal")); 180 | valid_apn = false; 181 | } 182 | else 183 | { 184 | valid_apn = true; 185 | 186 | for (uint16_t index = 0; index < NUM_BLYNK_CREDENTIALS; index++) 187 | { 188 | Blynk_GSM.config(modem, localBlynkGSM_ESP8266_config.Blynk_Creds[index].gsm_blynk_token, 189 | localBlynkGSM_ESP8266_config.Blynk_Creds[index].blynk_server, localBlynkGSM_ESP8266_config.blynk_port); 190 | 191 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(localBlynkGSM_ESP8266_config.apn, localBlynkGSM_ESP8266_config.gprsUser, 192 | localBlynkGSM_ESP8266_config.gprsPass); 193 | 194 | if (GSM_CONNECT_OK) 195 | { 196 | if ( Blynk_GSM.connect() == true ) 197 | break; 198 | } 199 | } 200 | } 201 | #endif 202 | } 203 | 204 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 205 | void displayCredentials() 206 | { 207 | Serial.println(F("\nYour stored Credentials :")); 208 | 209 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 210 | { 211 | Serial.print(myMenuItems[i].displayName); 212 | Serial.print(F(" = ")); 213 | Serial.println(myMenuItems[i].pdata); 214 | } 215 | } 216 | #endif 217 | 218 | void loop() 219 | { 220 | Blynk_WF.run(); 221 | 222 | #if USE_BLYNK_WM 223 | if (valid_apn) 224 | #endif 225 | { 226 | if (GSM_CONNECT_OK) 227 | Blynk_GSM.run(); 228 | } 229 | 230 | check_status(); 231 | 232 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 233 | static bool displayedCredentials = false; 234 | 235 | if (!displayedCredentials) 236 | { 237 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 238 | { 239 | if (!strlen(myMenuItems[i].pdata)) 240 | { 241 | break; 242 | } 243 | 244 | if ( i == (NUM_MENU_ITEMS - 1) ) 245 | { 246 | displayedCredentials = true; 247 | displayCredentials(); 248 | } 249 | } 250 | } 251 | #endif 252 | } 253 | -------------------------------------------------------------------------------- /examples/ESP8266_MRD_GSM/defines.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | defines.h 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #ifndef defines_h 12 | #define defines_h 13 | 14 | #ifndef ESP8266 15 | #error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting. 16 | #endif 17 | 18 | #define BLYNK_PRINT Serial 19 | #define BLYNK_HEARTBEAT 60 20 | 21 | #define BLYNK_WM_DEBUG 1 22 | 23 | #define USING_MRD true 24 | 25 | #if USING_MRD 26 | // These definitions must be placed before #include to be used 27 | // Otherwise, default values (MRD_TIMES = 3, MRD_TIMEOUT = 10 seconds and MRD_ADDRESS = 0) will be used 28 | // Number of subsequent resets during MRD_TIMEOUT to activate 29 | #define MRD_TIMES 3 30 | 31 | // Number of seconds after reset during which a subseqent reset will be considered a mlti reset. 32 | #define MRD_TIMEOUT 10 33 | 34 | // RTC/EEPPROM Address for the MultiResetDetector to use 35 | #define MRD_ADDRESS 0 36 | 37 | #define MULTIRESETDETECTOR_DEBUG true 38 | 39 | #warning Using MultiResetDetector MRD 40 | #else 41 | // These definitions must be placed before #include to be used 42 | // Otherwise, default values (DRD_TIMEOUT = 10 seconds and DRD_ADDRESS = 0) will be used 43 | // Number of subsequent resets during DRD_TIMEOUT to activate 44 | 45 | // Number of seconds after reset during which a subseqent reset will be considered a mlti reset. 46 | #define DRD_TIMEOUT 10 47 | 48 | // RTC/EEPPROM Address for the DoubleResetDetector to use 49 | #define DRD_ADDRESS 0 50 | 51 | #define DOUBLERESETDETECTOR_DEBUG true 52 | 53 | #warning Using DoubleResetDetector DRD 54 | #endif 55 | 56 | // #define USE_SPIFFS and USE_LITTLEFS false => using EEPROM for configuration data in WiFiManager 57 | // #define USE_LITTLEFS true => using LITTLEFS for configuration data in WiFiManager 58 | // #define USE_LITTLEFS false and USE_SPIFFS true => using SPIFFS for configuration data in WiFiManager 59 | // Be sure to define USE_LITTLEFS and USE_SPIFFS before #include 60 | // From ESP8266 core 2.7.1, SPIFFS will be deprecated and to be replaced by LittleFS 61 | // Select USE_LITTLEFS (higher priority) or USE_SPIFFS 62 | 63 | #define USE_LITTLEFS true 64 | //#define USE_LITTLEFS false 65 | #define USE_SPIFFS false 66 | //#define USE_SPIFFS true 67 | 68 | #if USE_LITTLEFS 69 | //LittleFS has higher priority 70 | #define CurrentFileFS F("LittleFS") 71 | #ifdef USE_SPIFFS 72 | #undef USE_SPIFFS 73 | #endif 74 | #define USE_SPIFFS false 75 | #elif USE_SPIFFS 76 | #define CurrentFileFS F("SPIFFS") 77 | #else 78 | #define CurrentFileFS F("EEPROM") 79 | // EEPROM_SIZE must be <= 4096 and >= CONFIG_DATA_SIZE (currently 172 bytes) 80 | #define EEPROM_SIZE (4 * 1024) 81 | // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE 82 | #define EEPROM_START 0 83 | #endif 84 | 85 | // Force some params in Blynk, only valid for library version 1.0.1 and later 86 | #define TIMEOUT_RECONNECT_WIFI 10000L 87 | #define RESET_IF_CONFIG_TIMEOUT true 88 | #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5 89 | 90 | // Config Timeout 120s (default 60s) 91 | #define CONFIG_TIMEOUT 120000L 92 | // Those above #define's must be placed before #include 93 | 94 | 95 | #define MODEM_RST D0 // Pin D0 mapped to pin GPIO16/USER/WAKE of ESP8266. This pin is also used for Onboard-Blue LED. 96 | #define MODEM_PWKEY D5 // Pin D5 mapped to pin GPIO14/HSCLK of ESP8266 97 | #define MODEM_POWER_ON D6 // Pin D6 mapped to pin GPIO12/HMISO of ESP8266 98 | 99 | #define MODEM_TX D8 // Pin D8 mapped to pin GPIO15/TXD2/HCS of ESP8266 100 | #define MODEM_RX D7 // Pin D7 mapped to pin GPIO13/RXD2/HMOSI of ESP8266 101 | 102 | #define I2C_SDA D2 // Pin D2 mapped to pin GPIO4/SDA of ESP8266 103 | #define I2C_SCL D1 // Pin D1 mapped to pin GPIO5/SCL of ESP8266 104 | 105 | // Select your modem: 106 | #define TINY_GSM_MODEM_SIM800 107 | //#define TINY_GSM_MODEM_SIM808 108 | //#define TINY_GSM_MODEM_SIM868 109 | //#define TINY_GSM_MODEM_SIM900 110 | //#define TINY_GSM_MODEM_SIM5300 111 | //#define TINY_GSM_MODEM_SIM5320 112 | //#define TINY_GSM_MODEM_SIM5360 113 | //#define TINY_GSM_MODEM_SIM7000 114 | //#define TINY_GSM_MODEM_SIM7100 115 | //#define TINY_GSM_MODEM_SIM7500 116 | //#define TINY_GSM_MODEM_SIM7600 117 | //#define TINY_GSM_MODEM_SIM7800 118 | //#define TINY_GSM_MODEM_UBLOX 119 | //#define TINY_GSM_MODEM_SARAR4 120 | //#define TINY_GSM_MODEM_M95 121 | //#define TINY_GSM_MODEM_BG96 122 | //#define TINY_GSM_MODEM_A6 123 | //#define TINY_GSM_MODEM_A7 124 | //#define TINY_GSM_MODEM_M590 125 | //#define TINY_GSM_MODEM_MC60 126 | //#define TINY_GSM_MODEM_MC60E 127 | //#define TINY_GSM_MODEM_XBEE 128 | //#define TINY_GSM_MODEM_SEQUANS_MONARCH 129 | 130 | // Increase RX buffer if needed 131 | #define TINY_GSM_RX_BUFFER 1024 132 | 133 | #include 134 | 135 | //#define USE_BLYNK_WM false 136 | #define USE_BLYNK_WM true 137 | 138 | #include 139 | 140 | #if USE_BLYNK_WM 141 | #define USE_DYNAMIC_PARAMETERS true 142 | 143 | #include 144 | 145 | #else 146 | #include 147 | 148 | // Your WiFi credentials. 149 | #define ssid "****" 150 | #define pass "****" 151 | 152 | #define USE_LOCAL_SERVER true 153 | //#define USE_LOCAL_SERVER false 154 | 155 | #if USE_LOCAL_SERVER 156 | #define wifi_blynk_tok "****" 157 | #define gsm_blynk_tok "****" 158 | //#define blynk_server "account.duckdns.org" 159 | // Use direct IPAddress in case GPRS can't use DDNS fast enough and can't connect 160 | #define blynk_server "xxx.xxx.xxx.xxx" 161 | #else 162 | #define wifi_blynk_tok "****" 163 | #define gsm_blynk_tok "****" 164 | #define blynk_server "blynk-cloud.com" 165 | #endif 166 | 167 | #define apn "rogers-core-appl1.apn" 168 | #define gprsUser "" //"wapuser1" 169 | #define gprsPass "" //"wap" 170 | 171 | #endif //USE_BLYNK_WM 172 | 173 | #define BLYNK_HARDWARE_PORT 8080 174 | 175 | // Set serial for debug console (to the Serial Monitor, default speed 115200) 176 | #define SerialMon Serial 177 | 178 | #include 179 | SoftwareSerial SerialAT(MODEM_RX, MODEM_TX); // RX, TX 180 | 181 | // Uncomment this if you want to see all AT commands 182 | #define DUMP_AT_COMMANDS false 183 | 184 | #if DUMP_AT_COMMANDS 185 | #include 186 | StreamDebugger debugger(SerialAT, SerialMon); 187 | TinyGsm modem(debugger); 188 | #else 189 | TinyGsm modem(SerialAT); 190 | #endif 191 | 192 | #define HOST_NAME "8266-GSM-WiFi" 193 | 194 | #endif //defines_h 195 | -------------------------------------------------------------------------------- /examples/ESP8266_MRD_GSM/dynamicParams.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | dynamicParams.h for ESP8266_GSM.ino 3 | For ESP8266 boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #ifndef dynamicParams_h 12 | #define dynamicParams_h 13 | 14 | #if (USE_DYNAMIC_PARAMETERS) 15 | #warning USE_DYNAMIC_PARAMETERS 16 | #endif 17 | 18 | // USE_DYNAMIC_PARAMETERS defined in defined.h 19 | 20 | /////////////// Start dynamic Credentials /////////////// 21 | 22 | //Defined in 23 | /************************************** 24 | #define MAX_ID_LEN 5 25 | #define MAX_DISPLAY_NAME_LEN 16 26 | 27 | typedef struct 28 | { 29 | char id [MAX_ID_LEN + 1]; 30 | char displayName [MAX_DISPLAY_NAME_LEN + 1]; 31 | char *pdata; 32 | uint8_t maxlen; 33 | } MenuItem; 34 | **************************************/ 35 | 36 | #if USE_DYNAMIC_PARAMETERS 37 | 38 | #define MAX_MQTT_SERVER_LEN 34 39 | char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.ddns.net"; 40 | 41 | #define MAX_MQTT_PORT_LEN 6 42 | char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "1883"; 43 | 44 | #define MAX_MQTT_USERNAME_LEN 34 45 | char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "mqtt-user"; 46 | 47 | #define MAX_MQTT_PW_LEN 34 48 | char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "mqtt-pass"; 49 | 50 | #define MAX_MQTT_SUBS_TOPIC_LEN 34 51 | char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "SubTopic_ESP8266_GSM"; 52 | 53 | #define MAX_MQTT_PUB_TOPIC_LEN 34 54 | char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "PubTopic_ESP8266_GSM"; 55 | 56 | MenuItem myMenuItems [] = 57 | { 58 | { "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN }, 59 | { "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN }, 60 | { "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN }, 61 | { "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN }, 62 | { "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN }, 63 | { "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN }, 64 | }; 65 | 66 | uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; 67 | 68 | #else 69 | 70 | MenuItem myMenuItems [] = {}; 71 | 72 | uint16_t NUM_MENU_ITEMS = 0; 73 | #endif 74 | 75 | 76 | /////// // End dynamic Credentials /////////// 77 | 78 | #endif //dynamicParams_h 79 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_GSM/Credentials.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | Credentials.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef Credentials_h 13 | #define Credentials_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | /// Start Default Config Data ////////////////// 18 | 19 | /* 20 | // Defined in 21 | 22 | #define SSID_MAX_LEN 32 23 | //From v1.0.10, WPA2 passwords can be up to 63 characters long. 24 | #define PASS_MAX_LEN 64 25 | 26 | typedef struct 27 | { 28 | char wifi_ssid[SSID_MAX_LEN]; 29 | char wifi_pw [PASS_MAX_LEN]; 30 | } WiFi_Credentials; 31 | 32 | #define BLYNK_SERVER_MAX_LEN 32 33 | #define BLYNK_TOKEN_MAX_LEN 36 34 | 35 | typedef struct 36 | { 37 | char blynk_server [BLYNK_SERVER_MAX_LEN]; 38 | char wifi_blynk_token [BLYNK_TOKEN_MAX_LEN]; 39 | char gsm_blynk_token [BLYNK_TOKEN_MAX_LEN]; 40 | } Blynk_Credentials; 41 | 42 | #define NUM_WIFI_CREDENTIALS 2 43 | #define NUM_BLYNK_CREDENTIALS 2 44 | 45 | // Configurable items besides fixed Header 46 | #define NUM_CONFIGURABLE_ITEMS ( 6 + (2 * NUM_WIFI_CREDENTIALS) + (3 * NUM_BLYNK_CREDENTIALS) ) 47 | #define DEFAULT_GPRS_PIN "1234" 48 | 49 | typedef struct Configuration 50 | { 51 | char header [16]; 52 | WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS]; 53 | Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 54 | int blynk_port; 55 | // YOUR GSM / GPRS RELATED 56 | char apn [32]; 57 | char gprsUser [32]; 58 | char gprsPass [32]; 59 | char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 60 | // END OF YOUR GSM / GPRS RELATED 61 | char board_name [24]; 62 | int checkSum; 63 | } Blynk_WF_Configuration; 64 | 65 | */ 66 | 67 | //bool LOAD_DEFAULT_CONFIG_DATA = true; 68 | bool LOAD_DEFAULT_CONFIG_DATA = false; 69 | 70 | Blynk_WF_Configuration defaultConfig = 71 | { 72 | //char header[16], dummy, not used 73 | "GSM", 74 | //WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS] 75 | //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw 76 | "SSID1", "password1", 77 | "SSID2", "password2", 78 | // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 79 | // Blynk_Creds.blynk_server, Blynk_Creds.wifi_blynk_token and Blynk_Creds.gsm_blynk_token 80 | "account.ddns.net", "wifi_token", "gsm_token", 81 | "account.duckdns.org", "wifi_token1", "gsm_token1", 82 | //int blynk_port; 83 | 8080, 84 | // YOUR GSM / GPRS RELATED 85 | //char apn [32]; 86 | "rogers-core-appl1.apn", 87 | //char gprsUser [32]; 88 | "wapuser1", 89 | //char gprsPass [32]; 90 | "wap", 91 | //char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 92 | "1245678", 93 | // END OF YOUR GSM / GPRS RELATED 94 | //char board_name [24]; 95 | "ESP32-GSM-WiFi", 96 | //int checkSum, dummy, not used 97 | 0 98 | }; 99 | 100 | /////////// End Default Config Data ///////////// 101 | 102 | #endif // #if USE_BLYNK_WM 103 | 104 | #endif //Credentials_h 105 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_GSM/TTGO_TCALL_GSM.ino: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | TTGO-TCALL.ino 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #include "defines.h" 12 | 13 | #if USE_BLYNK_WM 14 | #include "Credentials.h" 15 | #include "dynamicParams.h" 16 | 17 | #define BLYNK_PIN_FORCED_CONFIG V10 18 | #define BLYNK_PIN_FORCED_PERS_CONFIG V20 19 | 20 | // Use button V10 (BLYNK_PIN_FORCED_CONFIG) to forced Config Portal 21 | BLYNK_WRITE(BLYNK_PIN_FORCED_CONFIG) 22 | { 23 | if (param.asInt()) 24 | { 25 | Serial.println( F("\nCP Button Hit. Rebooting") ); 26 | 27 | // This will keep CP once, clear after reset, even you didn't enter CP at all. 28 | Blynk.resetAndEnterConfigPortal(); 29 | } 30 | } 31 | 32 | // Use button V20 (BLYNK_PIN_FORCED_PERS_CONFIG) to forced Persistent Config Portal 33 | BLYNK_WRITE(BLYNK_PIN_FORCED_PERS_CONFIG) 34 | { 35 | if (param.asInt()) 36 | { 37 | Serial.println( F("\nPersistent CP Button Hit. Rebooting") ); 38 | 39 | // This will keep CP forever, until you successfully enter CP, and Save data to clear the flag. 40 | Blynk.resetAndEnterConfigPortalPersistent(); 41 | } 42 | } 43 | #endif 44 | 45 | void heartBeatPrint() 46 | { 47 | static int num = 1; 48 | 49 | if (Blynk_WF.connected()) 50 | { 51 | Serial.print(F("B")); 52 | } 53 | else 54 | { 55 | Serial.print(F("F")); 56 | } 57 | 58 | if (Blynk_GSM.connected()) 59 | { 60 | Serial.print(F("G")); 61 | } 62 | else 63 | { 64 | Serial.print(F("F")); 65 | } 66 | 67 | if (num == 40) 68 | { 69 | Serial.println(); 70 | num = 1; 71 | } 72 | else if (num++ % 10 == 0) 73 | { 74 | Serial.print(F(" ")); 75 | } 76 | } 77 | 78 | void check_status() 79 | { 80 | static unsigned long checkstatus_timeout = 0; 81 | 82 | #define STATUS_CHECK_INTERVAL 60000L 83 | 84 | // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. 85 | if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) 86 | { 87 | // report status to Blynk 88 | heartBeatPrint(); 89 | 90 | checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; 91 | } 92 | } 93 | 94 | bool valid_apn = false; 95 | bool GSM_CONNECT_OK = false; 96 | 97 | void setup() 98 | { 99 | // Set console baud rate 100 | SerialMon.begin(115200); 101 | while (!SerialMon); 102 | 103 | delay(200); 104 | 105 | SerialMon.print(F("\nStart TTGO_TCALL_GSM (Simultaneous WiFi+GSM) using ")); 106 | SerialMon.print(CurrentFileFS); 107 | SerialMon.print(F(" on ")); SerialMon.println(ARDUINO_BOARD); 108 | SerialMon.println(BLYNK_GSM_MANAGER_VERSION); 109 | 110 | #if USE_BLYNK_WM 111 | Serial.println(ESP_DOUBLE_RESET_DETECTOR_VERSION); 112 | #endif 113 | 114 | // Set-up modem reset, enable, power pins 115 | pinMode(MODEM_PWKEY, OUTPUT); 116 | pinMode(MODEM_RST, OUTPUT); 117 | pinMode(MODEM_POWER_ON, OUTPUT); 118 | 119 | digitalWrite(MODEM_PWKEY, LOW); 120 | digitalWrite(MODEM_RST, HIGH); 121 | digitalWrite(MODEM_POWER_ON, HIGH); 122 | 123 | SerialMon.println(F("Set GSM module baud rate")); 124 | 125 | // Set GSM module baud rate 126 | SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX); 127 | delay(3000); 128 | 129 | Serial.println(F("Use WiFi to connect Blynk")); 130 | 131 | #if USE_BLYNK_WM 132 | 133 | // Set config portal SSID and Password 134 | Blynk_WF.setConfigPortal("TestPortal-ESP32", "TestPortalPass"); 135 | 136 | // Use configurable AP IP, instead of default IP 192.168.4.1 137 | //Blynk_WF.setConfigPortalIP(IPAddress(192, 168, 232, 1)); 138 | // Set config portal channel, default = 1. Use 0 => random channel from 1-12 to avoid conflict 139 | Blynk_WF.setConfigPortalChannel(0); 140 | 141 | // Select either one of these to set static IP + DNS 142 | Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0)); 143 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 144 | // IPAddress(192, 168, 2, 1), IPAddress(8, 8, 8, 8)); 145 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 146 | // IPAddress(4, 4, 4, 4), IPAddress(8, 8, 8, 8)); 147 | 148 | // Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX 149 | //Blynk_WF.begin(); 150 | // Use this to personalize DHCP hostname (RFC952 conformed) 151 | // 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char 152 | Blynk_WF.begin("TTGO-TCALL-GSM"); 153 | #else 154 | Blynk_WF.begin(wifi_blynk_tok, ssid, pass, blynk_server, BLYNK_HARDWARE_PORT); 155 | 156 | Blynk_GSM.config(modem, gsm_blynk_tok, blynk_server, BLYNK_HARDWARE_PORT); 157 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(apn, gprsUser, gprsPass); 158 | 159 | if (GSM_CONNECT_OK) 160 | Blynk_GSM.connect(); 161 | #endif 162 | 163 | #if USE_BLYNK_WM 164 | Blynk_WF_Configuration localBlynkGSM_ESP32_config; 165 | 166 | Blynk_WF.getFullConfigData(&localBlynkGSM_ESP32_config); 167 | 168 | Serial.print(F("gprs apn = ")); 169 | Serial.println(localBlynkGSM_ESP32_config.apn); 170 | 171 | if ( Blynk.inConfigPortal() || (String(localBlynkGSM_ESP32_config.apn) == NO_CONFIG) ) 172 | { 173 | Serial.println(F("DRD/MRD, Forced Config Portal or No valid stored apn. Must run only WiFi to Open config portal")); 174 | valid_apn = false; 175 | } 176 | else 177 | { 178 | valid_apn = true; 179 | 180 | for (uint16_t index = 0; index < NUM_BLYNK_CREDENTIALS; index++) 181 | { 182 | Blynk_GSM.config(modem, localBlynkGSM_ESP32_config.Blynk_Creds[index].gsm_blynk_token, 183 | localBlynkGSM_ESP32_config.Blynk_Creds[index].blynk_server, localBlynkGSM_ESP32_config.blynk_port); 184 | 185 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(localBlynkGSM_ESP32_config.apn, localBlynkGSM_ESP32_config.gprsUser, 186 | localBlynkGSM_ESP32_config.gprsPass); 187 | 188 | if (GSM_CONNECT_OK) 189 | { 190 | if ( Blynk_GSM.connect() == true ) 191 | break; 192 | } 193 | } 194 | } 195 | #endif 196 | } 197 | 198 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 199 | void displayCredentials() 200 | { 201 | Serial.println(F("\nYour stored Credentials :")); 202 | 203 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 204 | { 205 | Serial.print(myMenuItems[i].displayName); 206 | Serial.print(F(" = ")); 207 | Serial.println(myMenuItems[i].pdata); 208 | } 209 | } 210 | #endif 211 | 212 | void loop() 213 | { 214 | Blynk_WF.run(); 215 | 216 | #if USE_BLYNK_WM 217 | if (valid_apn) 218 | Blynk_GSM.run(); 219 | #else 220 | Blynk_GSM.run(); 221 | #endif 222 | 223 | check_status(); 224 | 225 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 226 | static bool displayedCredentials = false; 227 | 228 | if (!displayedCredentials) 229 | { 230 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 231 | { 232 | if (!strlen(myMenuItems[i].pdata)) 233 | { 234 | break; 235 | } 236 | 237 | if ( i == (NUM_MENU_ITEMS - 1) ) 238 | { 239 | displayedCredentials = true; 240 | displayCredentials(); 241 | } 242 | } 243 | } 244 | #endif 245 | } 246 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_GSM/defines.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | defines.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #ifndef defines_h 12 | #define defines_h 13 | 14 | #ifndef ESP32 15 | #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting. 16 | #endif 17 | 18 | #define BLYNK_PRINT Serial 19 | #define BLYNK_HEARTBEAT 60 20 | 21 | #define DOUBLERESETDETECTOR_DEBUG true //false 22 | #define BLYNK_WM_DEBUG 1 23 | 24 | // Not use #define USE_LITTLEFS and #define USE_SPIFFS => using SPIFFS for configuration data in WiFiManager 25 | // (USE_LITTLEFS == false) and (USE_SPIFFS == false) => using EEPROM for configuration data in WiFiManager 26 | // (USE_LITTLEFS == true) and (USE_SPIFFS == false) => using LITTLEFS for configuration data in WiFiManager 27 | // (USE_LITTLEFS == true) and (USE_SPIFFS == true) => using LITTLEFS for configuration data in WiFiManager 28 | // (USE_LITTLEFS == false) and (USE_SPIFFS == true) => using SPIFFS for configuration data in WiFiManager 29 | // Those above #define's must be placed before #include 30 | 31 | #define USE_LITTLEFS true 32 | #define USE_SPIFFS false 33 | 34 | #if USE_LITTLEFS 35 | #define CurrentFileFS F("LittleFS") 36 | #elif USE_SPIFFS 37 | #define CurrentFileFS F("SPIFFS") 38 | #else 39 | #define CurrentFileFS F("EEPROM") 40 | 41 | // EEPROM_SIZE must be <= 2048 and >= CONFIG_DATA_SIZE (currently 172 bytes) 42 | #define EEPROM_SIZE (2 * 1024) 43 | // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE 44 | #define EEPROM_START 0 45 | #endif 46 | 47 | // Force some params in Blynk, only valid for library version 1.0.1 and later 48 | #define TIMEOUT_RECONNECT_WIFI 10000L 49 | #define RESET_IF_CONFIG_TIMEOUT true 50 | #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5 51 | 52 | // Config Timeout 120s (default 60s) 53 | #define CONFIG_TIMEOUT 120000L 54 | // Those above #define's must be placed before #include 55 | 56 | // TTGO T-Call pin definitions 57 | #define MODEM_RST 5 58 | #define MODEM_PWKEY 4 59 | #define MODEM_POWER_ON 23 60 | 61 | #define MODEM_TX 27 62 | #define MODEM_RX 26 63 | 64 | #define I2C_SDA 21 65 | #define I2C_SCL 22 66 | 67 | // Select your modem: 68 | #define TINY_GSM_MODEM_SIM800 69 | //#define TINY_GSM_MODEM_SIM808 70 | //#define TINY_GSM_MODEM_SIM868 71 | //#define TINY_GSM_MODEM_SIM900 72 | //#define TINY_GSM_MODEM_SIM5300 73 | //#define TINY_GSM_MODEM_SIM5320 74 | //#define TINY_GSM_MODEM_SIM5360 75 | //#define TINY_GSM_MODEM_SIM7000 76 | //#define TINY_GSM_MODEM_SIM7100 77 | //#define TINY_GSM_MODEM_SIM7500 78 | //#define TINY_GSM_MODEM_SIM7600 79 | //#define TINY_GSM_MODEM_SIM7800 80 | //#define TINY_GSM_MODEM_UBLOX 81 | //#define TINY_GSM_MODEM_SARAR4 82 | //#define TINY_GSM_MODEM_M95 83 | //#define TINY_GSM_MODEM_BG96 84 | //#define TINY_GSM_MODEM_A6 85 | //#define TINY_GSM_MODEM_A7 86 | //#define TINY_GSM_MODEM_M590 87 | //#define TINY_GSM_MODEM_MC60 88 | //#define TINY_GSM_MODEM_MC60E 89 | //#define TINY_GSM_MODEM_XBEE 90 | //#define TINY_GSM_MODEM_SEQUANS_MONARCH 91 | 92 | // Increase RX buffer if needed 93 | #define TINY_GSM_RX_BUFFER 1024 94 | 95 | #include 96 | 97 | //#define USE_BLYNK_WM false 98 | #define USE_BLYNK_WM true 99 | 100 | #include 101 | 102 | #if USE_BLYNK_WM 103 | #define USE_DYNAMIC_PARAMETERS true 104 | 105 | #include 106 | 107 | #else 108 | #include 109 | 110 | // Your WiFi credentials. 111 | #define ssid "****" 112 | #define pass "****" 113 | 114 | #define USE_LOCAL_SERVER true 115 | //#define USE_LOCAL_SERVER false 116 | 117 | #if USE_LOCAL_SERVER 118 | #define wifi_blynk_tok "****" 119 | #define gsm_blynk_tok "****" 120 | //#define blynk_server "account.duckdns.org" 121 | // Use direct IPAddress in case GPRS can't use DDNS fast enough and can't connect 122 | #define blynk_server "xxx.xxx.xxx.xxx" 123 | #else 124 | #define wifi_blynk_tok "****" 125 | #define gsm_blynk_tok "****" 126 | #define blynk_server "blynk-cloud.com" 127 | #endif 128 | 129 | #define apn "rogers-core-appl1.apn" 130 | #define gprsUser "" //"wapuser1" 131 | #define gprsPass "" //"wap" 132 | 133 | #endif //USE_BLYNK_WM 134 | 135 | #define BLYNK_HARDWARE_PORT 8080 136 | 137 | // Set serial for debug console (to the Serial Monitor, default speed 115200) 138 | #define SerialMon Serial 139 | 140 | #define RXD2 16 141 | #define TXD2 17 142 | 143 | // Use ESP32 Serial2 for GSM, Serial1 for TTGO T-Call 144 | #define SerialAT Serial1 145 | 146 | // Uncomment this if you want to see all AT commands 147 | #define DUMP_AT_COMMANDS false 148 | 149 | #if DUMP_AT_COMMANDS 150 | #include 151 | StreamDebugger debugger(SerialAT, SerialMon); 152 | TinyGsm modem(debugger); 153 | #else 154 | TinyGsm modem(SerialAT); 155 | #endif 156 | 157 | #define HOST_NAME "ESP32-GSM-WiFi" 158 | 159 | #endif //defines_h 160 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_GSM/dynamicParams.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | dynamicParams.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef dynamicParams_h 13 | #define dynamicParams_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | #if (USE_DYNAMIC_PARAMETERS) 18 | #warning USE_DYNAMIC_PARAMETERS 19 | #endif 20 | 21 | // USE_DYNAMIC_PARAMETERS defined in defined.h 22 | 23 | /////////////// Start dynamic Credentials /////////////// 24 | 25 | //Defined in 26 | /************************************** 27 | #define MAX_ID_LEN 5 28 | #define MAX_DISPLAY_NAME_LEN 16 29 | 30 | typedef struct 31 | { 32 | char id [MAX_ID_LEN + 1]; 33 | char displayName [MAX_DISPLAY_NAME_LEN + 1]; 34 | char *pdata; 35 | uint8_t maxlen; 36 | } MenuItem; 37 | **************************************/ 38 | 39 | #if USE_DYNAMIC_PARAMETERS 40 | 41 | #define MAX_MQTT_SERVER_LEN 34 42 | char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.ddns.net"; 43 | 44 | #define MAX_MQTT_PORT_LEN 6 45 | char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "1883"; 46 | 47 | #define MAX_MQTT_USERNAME_LEN 34 48 | char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "mqtt-user"; 49 | 50 | #define MAX_MQTT_PW_LEN 34 51 | char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "mqtt-pass"; 52 | 53 | #define MAX_MQTT_SUBS_TOPIC_LEN 34 54 | char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "SubTopic_ESP32_GSM"; 55 | 56 | #define MAX_MQTT_PUB_TOPIC_LEN 34 57 | char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "PubTopic_ESP32_GSM"; 58 | 59 | MenuItem myMenuItems [] = 60 | { 61 | { "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN }, 62 | { "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN }, 63 | { "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN }, 64 | { "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN }, 65 | { "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN }, 66 | { "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN }, 67 | }; 68 | 69 | uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; 70 | 71 | #else 72 | 73 | MenuItem myMenuItems [] = {}; 74 | 75 | uint16_t NUM_MENU_ITEMS = 0; 76 | #endif 77 | 78 | 79 | /////// // End dynamic Credentials /////////// 80 | 81 | #endif // #if USE_BLYNK_WM 82 | 83 | #endif //dynamicParams_h 84 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_MRD_GSM/Credentials.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | Credentials.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef Credentials_h 13 | #define Credentials_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | /// Start Default Config Data ////////////////// 18 | 19 | /* 20 | // Defined in 21 | 22 | #define SSID_MAX_LEN 32 23 | //From v1.0.10, WPA2 passwords can be up to 63 characters long. 24 | #define PASS_MAX_LEN 64 25 | 26 | typedef struct 27 | { 28 | char wifi_ssid[SSID_MAX_LEN]; 29 | char wifi_pw [PASS_MAX_LEN]; 30 | } WiFi_Credentials; 31 | 32 | #define BLYNK_SERVER_MAX_LEN 32 33 | #define BLYNK_TOKEN_MAX_LEN 36 34 | 35 | typedef struct 36 | { 37 | char blynk_server [BLYNK_SERVER_MAX_LEN]; 38 | char wifi_blynk_token [BLYNK_TOKEN_MAX_LEN]; 39 | char gsm_blynk_token [BLYNK_TOKEN_MAX_LEN]; 40 | } Blynk_Credentials; 41 | 42 | #define NUM_WIFI_CREDENTIALS 2 43 | #define NUM_BLYNK_CREDENTIALS 2 44 | 45 | // Configurable items besides fixed Header 46 | #define NUM_CONFIGURABLE_ITEMS ( 6 + (2 * NUM_WIFI_CREDENTIALS) + (3 * NUM_BLYNK_CREDENTIALS) ) 47 | #define DEFAULT_GPRS_PIN "1234" 48 | 49 | typedef struct Configuration 50 | { 51 | char header [16]; 52 | WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS]; 53 | Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 54 | int blynk_port; 55 | // YOUR GSM / GPRS RELATED 56 | char apn [32]; 57 | char gprsUser [32]; 58 | char gprsPass [32]; 59 | char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 60 | // END OF YOUR GSM / GPRS RELATED 61 | char board_name [24]; 62 | int checkSum; 63 | } Blynk_WF_Configuration; 64 | 65 | */ 66 | 67 | //bool LOAD_DEFAULT_CONFIG_DATA = true; 68 | bool LOAD_DEFAULT_CONFIG_DATA = false; 69 | 70 | Blynk_WF_Configuration defaultConfig = 71 | { 72 | //char header[16], dummy, not used 73 | "GSM", 74 | //WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS] 75 | //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw 76 | "SSID1", "password1", 77 | "SSID2", "password2", 78 | // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 79 | // Blynk_Creds.blynk_server, Blynk_Creds.wifi_blynk_token and Blynk_Creds.gsm_blynk_token 80 | "account.ddns.net", "wifi_token", "gsm_token", 81 | "account.duckdns.org", "wifi_token1", "gsm_token1", 82 | //int blynk_port; 83 | 8080, 84 | // YOUR GSM / GPRS RELATED 85 | //char apn [32]; 86 | "rogers-core-appl1.apn", 87 | //char gprsUser [32]; 88 | "wapuser1", 89 | //char gprsPass [32]; 90 | "wap", 91 | //char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 92 | "1245678", 93 | // END OF YOUR GSM / GPRS RELATED 94 | //char board_name [24]; 95 | "ESP32-GSM-WiFi", 96 | //int checkSum, dummy, not used 97 | 0 98 | }; 99 | 100 | /////////// End Default Config Data ///////////// 101 | 102 | #endif // #if USE_BLYNK_WM 103 | 104 | #endif //Credentials_h 105 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_MRD_GSM/TTGO_TCALL_MRD_GSM.ino: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | TTGO_TCALL_MRD_GSM.ino 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #include "defines.h" 12 | 13 | #if USE_BLYNK_WM 14 | #include "Credentials.h" 15 | #include "dynamicParams.h" 16 | 17 | #define BLYNK_PIN_FORCED_CONFIG V10 18 | #define BLYNK_PIN_FORCED_PERS_CONFIG V20 19 | 20 | // Use button V10 (BLYNK_PIN_FORCED_CONFIG) to forced Config Portal 21 | BLYNK_WRITE(BLYNK_PIN_FORCED_CONFIG) 22 | { 23 | if (param.asInt()) 24 | { 25 | Serial.println( F("\nCP Button Hit. Rebooting") ); 26 | 27 | // This will keep CP once, clear after reset, even you didn't enter CP at all. 28 | Blynk.resetAndEnterConfigPortal(); 29 | } 30 | } 31 | 32 | // Use button V20 (BLYNK_PIN_FORCED_PERS_CONFIG) to forced Persistent Config Portal 33 | BLYNK_WRITE(BLYNK_PIN_FORCED_PERS_CONFIG) 34 | { 35 | if (param.asInt()) 36 | { 37 | Serial.println( F("\nPersistent CP Button Hit. Rebooting") ); 38 | 39 | // This will keep CP forever, until you successfully enter CP, and Save data to clear the flag. 40 | Blynk.resetAndEnterConfigPortalPersistent(); 41 | } 42 | } 43 | #endif 44 | 45 | void heartBeatPrint() 46 | { 47 | static int num = 1; 48 | 49 | if (Blynk_WF.connected()) 50 | { 51 | Serial.print(F("B")); 52 | } 53 | else 54 | { 55 | Serial.print(F("F")); 56 | } 57 | 58 | if (Blynk_GSM.connected()) 59 | { 60 | Serial.print(F("G")); 61 | } 62 | else 63 | { 64 | Serial.print(F("F")); 65 | } 66 | 67 | if (num == 40) 68 | { 69 | Serial.println(); 70 | num = 1; 71 | } 72 | else if (num++ % 10 == 0) 73 | { 74 | Serial.print(F(" ")); 75 | } 76 | } 77 | 78 | void check_status() 79 | { 80 | static unsigned long checkstatus_timeout = 0; 81 | 82 | #define STATUS_CHECK_INTERVAL 60000L 83 | 84 | // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. 85 | if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0)) 86 | { 87 | // report status to Blynk 88 | heartBeatPrint(); 89 | 90 | checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; 91 | } 92 | } 93 | 94 | bool valid_apn = false; 95 | bool GSM_CONNECT_OK = false; 96 | 97 | void setup() 98 | { 99 | // Set console baud rate 100 | SerialMon.begin(115200); 101 | while (!SerialMon); 102 | 103 | delay(200); 104 | 105 | SerialMon.print(F("\nStart TTGO_TCALL_MRD_GSM (Simultaneous WiFi+GSM) using ")); 106 | SerialMon.print(CurrentFileFS); 107 | SerialMon.print(F(" on ")); SerialMon.println(ARDUINO_BOARD); 108 | SerialMon.println(BLYNK_GSM_MANAGER_VERSION); 109 | 110 | #if USE_BLYNK_WM 111 | #if USING_MRD 112 | Serial.println(ESP_MULTI_RESET_DETECTOR_VERSION); 113 | #else 114 | Serial.println(ESP_DOUBLE_RESET_DETECTOR_VERSION); 115 | #endif 116 | #endif 117 | 118 | // Set-up modem reset, enable, power pins 119 | pinMode(MODEM_PWKEY, OUTPUT); 120 | pinMode(MODEM_RST, OUTPUT); 121 | pinMode(MODEM_POWER_ON, OUTPUT); 122 | 123 | digitalWrite(MODEM_PWKEY, LOW); 124 | digitalWrite(MODEM_RST, HIGH); 125 | digitalWrite(MODEM_POWER_ON, HIGH); 126 | 127 | SerialMon.println(F("Set GSM module baud rate")); 128 | 129 | // Set GSM module baud rate 130 | SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX); 131 | delay(3000); 132 | 133 | Serial.println(F("Use WiFi to connect Blynk")); 134 | 135 | #if USE_BLYNK_WM 136 | 137 | // Set config portal SSID and Password 138 | Blynk_WF.setConfigPortal("TestPortal-ESP32", "TestPortalPass"); 139 | 140 | // Use configurable AP IP, instead of default IP 192.168.4.1 141 | Blynk_WF.setConfigPortalIP(IPAddress(192, 168, 232, 1)); 142 | // Set config portal channel, default = 1. Use 0 => random channel from 1-12 to avoid conflict 143 | Blynk_WF.setConfigPortalChannel(0); 144 | 145 | // Select either one of these to set static IP + DNS 146 | Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0)); 147 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 148 | // IPAddress(192, 168, 2, 1), IPAddress(8, 8, 8, 8)); 149 | //Blynk_WF.setSTAStaticIPConfig(IPAddress(192, 168, 2, 232), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), 150 | // IPAddress(4, 4, 4, 4), IPAddress(8, 8, 8, 8)); 151 | 152 | // Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX 153 | //Blynk_WF.begin(); 154 | // Use this to personalize DHCP hostname (RFC952 conformed) 155 | // 24 chars max,- only a..z A..Z 0..9 '-' and no '-' as last char 156 | Blynk_WF.begin("TTGO-TCALL-GSM"); 157 | #else 158 | Blynk_WF.begin(wifi_blynk_tok, ssid, pass, blynk_server, BLYNK_HARDWARE_PORT); 159 | 160 | Blynk_GSM.config(modem, gsm_blynk_tok, blynk_server, BLYNK_HARDWARE_PORT); 161 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(apn, gprsUser, gprsPass); 162 | 163 | if (GSM_CONNECT_OK) 164 | Blynk_GSM.connect(); 165 | #endif 166 | 167 | #if USE_BLYNK_WM 168 | Blynk_WF_Configuration localBlynkGSM_ESP32_config; 169 | 170 | Blynk_WF.getFullConfigData(&localBlynkGSM_ESP32_config); 171 | 172 | Serial.print(F("gprs apn = ")); 173 | Serial.println(localBlynkGSM_ESP32_config.apn); 174 | 175 | if ( Blynk.inConfigPortal() || (String(localBlynkGSM_ESP32_config.apn) == NO_CONFIG) ) 176 | { 177 | Serial.println(F("DRD/MRD, Forced Config Portal or No valid stored apn. Must run only WiFi to Open config portal")); 178 | valid_apn = false; 179 | } 180 | else 181 | { 182 | valid_apn = true; 183 | 184 | for (uint16_t index = 0; index < NUM_BLYNK_CREDENTIALS; index++) 185 | { 186 | Blynk_GSM.config(modem, localBlynkGSM_ESP32_config.Blynk_Creds[index].gsm_blynk_token, 187 | localBlynkGSM_ESP32_config.Blynk_Creds[index].blynk_server, localBlynkGSM_ESP32_config.blynk_port); 188 | 189 | GSM_CONNECT_OK = Blynk_GSM.connectNetwork(localBlynkGSM_ESP32_config.apn, localBlynkGSM_ESP32_config.gprsUser, 190 | localBlynkGSM_ESP32_config.gprsPass); 191 | 192 | if (GSM_CONNECT_OK) 193 | { 194 | if ( Blynk_GSM.connect() == true ) 195 | break; 196 | } 197 | } 198 | } 199 | #endif 200 | } 201 | 202 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 203 | void displayCredentials() 204 | { 205 | Serial.println(F("\nYour stored Credentials :")); 206 | 207 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 208 | { 209 | Serial.print(myMenuItems[i].displayName); 210 | Serial.print(F(" = ")); 211 | Serial.println(myMenuItems[i].pdata); 212 | } 213 | } 214 | #endif 215 | 216 | void loop() 217 | { 218 | Blynk_WF.run(); 219 | 220 | #if USE_BLYNK_WM 221 | if (valid_apn) 222 | Blynk_GSM.run(); 223 | #else 224 | Blynk_GSM.run(); 225 | #endif 226 | 227 | check_status(); 228 | 229 | #if (USE_BLYNK_WM && USE_DYNAMIC_PARAMETERS) 230 | static bool displayedCredentials = false; 231 | 232 | if (!displayedCredentials) 233 | { 234 | for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) 235 | { 236 | if (!strlen(myMenuItems[i].pdata)) 237 | { 238 | break; 239 | } 240 | 241 | if ( i == (NUM_MENU_ITEMS - 1) ) 242 | { 243 | displayedCredentials = true; 244 | displayCredentials(); 245 | } 246 | } 247 | } 248 | #endif 249 | } 250 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_MRD_GSM/defines.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | defines.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | *****************************************************************************************************************************/ 10 | 11 | #ifndef defines_h 12 | #define defines_h 13 | 14 | #ifndef ESP32 15 | #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting. 16 | #endif 17 | 18 | #define BLYNK_PRINT Serial 19 | #define BLYNK_HEARTBEAT 60 20 | 21 | #define BLYNK_WM_DEBUG 1 22 | 23 | #define USING_MRD true 24 | 25 | #if USING_MRD 26 | // These definitions must be placed before #include to be used 27 | // Otherwise, default values (MRD_TIMES = 3, MRD_TIMEOUT = 10 seconds and MRD_ADDRESS = 0) will be used 28 | // Number of subsequent resets during MRD_TIMEOUT to activate 29 | #define MRD_TIMES 3 30 | 31 | // Number of seconds after reset during which a subseqent reset will be considered a mlti reset. 32 | #define MRD_TIMEOUT 10 33 | 34 | // RTC/EEPPROM Address for the MultiResetDetector to use 35 | #define MRD_ADDRESS 0 36 | 37 | #define MULTIRESETDETECTOR_DEBUG true 38 | 39 | #warning Using MultiResetDetector MRD 40 | #else 41 | // These definitions must be placed before #include to be used 42 | // Otherwise, default values (DRD_TIMEOUT = 10 seconds and DRD_ADDRESS = 0) will be used 43 | // Number of subsequent resets during DRD_TIMEOUT to activate 44 | 45 | // Number of seconds after reset during which a subseqent reset will be considered a mlti reset. 46 | #define DRD_TIMEOUT 10 47 | 48 | // RTC/EEPPROM Address for the DoubleResetDetector to use 49 | #define DRD_ADDRESS 0 50 | 51 | #define DOUBLERESETDETECTOR_DEBUG true 52 | 53 | #warning Using DoubleResetDetector DRD 54 | #endif 55 | 56 | // Not use #define USE_LITTLEFS and #define USE_SPIFFS => using SPIFFS for configuration data in WiFiManager 57 | // (USE_LITTLEFS == false) and (USE_SPIFFS == false) => using EEPROM for configuration data in WiFiManager 58 | // (USE_LITTLEFS == true) and (USE_SPIFFS == false) => using LITTLEFS for configuration data in WiFiManager 59 | // (USE_LITTLEFS == true) and (USE_SPIFFS == true) => using LITTLEFS for configuration data in WiFiManager 60 | // (USE_LITTLEFS == false) and (USE_SPIFFS == true) => using SPIFFS for configuration data in WiFiManager 61 | // Those above #define's must be placed before #include 62 | 63 | #define USE_LITTLEFS true 64 | #define USE_SPIFFS false 65 | 66 | #if USE_LITTLEFS 67 | #define CurrentFileFS F("LittleFS") 68 | #elif USE_SPIFFS 69 | #define CurrentFileFS F("SPIFFS") 70 | #else 71 | #define CurrentFileFS F("EEPROM") 72 | 73 | // EEPROM_SIZE must be <= 2048 and >= CONFIG_DATA_SIZE (currently 172 bytes) 74 | #define EEPROM_SIZE (2 * 1024) 75 | // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE 76 | #define EEPROM_START 0 77 | #endif 78 | 79 | // Force some params in Blynk, only valid for library version 1.0.1 and later 80 | #define TIMEOUT_RECONNECT_WIFI 10000L 81 | #define RESET_IF_CONFIG_TIMEOUT true 82 | #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5 83 | 84 | // Config Timeout 120s (default 60s) 85 | #define CONFIG_TIMEOUT 120000L 86 | // Those above #define's must be placed before #include 87 | 88 | // TTGO T-Call pin definitions 89 | #define MODEM_RST 5 90 | #define MODEM_PWKEY 4 91 | #define MODEM_POWER_ON 23 92 | 93 | #define MODEM_TX 27 94 | #define MODEM_RX 26 95 | 96 | #define I2C_SDA 21 97 | #define I2C_SCL 22 98 | 99 | // Select your modem: 100 | #define TINY_GSM_MODEM_SIM800 101 | //#define TINY_GSM_MODEM_SIM808 102 | //#define TINY_GSM_MODEM_SIM868 103 | //#define TINY_GSM_MODEM_SIM900 104 | //#define TINY_GSM_MODEM_SIM5300 105 | //#define TINY_GSM_MODEM_SIM5320 106 | //#define TINY_GSM_MODEM_SIM5360 107 | //#define TINY_GSM_MODEM_SIM7000 108 | //#define TINY_GSM_MODEM_SIM7100 109 | //#define TINY_GSM_MODEM_SIM7500 110 | //#define TINY_GSM_MODEM_SIM7600 111 | //#define TINY_GSM_MODEM_SIM7800 112 | //#define TINY_GSM_MODEM_UBLOX 113 | //#define TINY_GSM_MODEM_SARAR4 114 | //#define TINY_GSM_MODEM_M95 115 | //#define TINY_GSM_MODEM_BG96 116 | //#define TINY_GSM_MODEM_A6 117 | //#define TINY_GSM_MODEM_A7 118 | //#define TINY_GSM_MODEM_M590 119 | //#define TINY_GSM_MODEM_MC60 120 | //#define TINY_GSM_MODEM_MC60E 121 | //#define TINY_GSM_MODEM_XBEE 122 | //#define TINY_GSM_MODEM_SEQUANS_MONARCH 123 | 124 | // Increase RX buffer if needed 125 | #define TINY_GSM_RX_BUFFER 1024 126 | 127 | #include 128 | 129 | //#define USE_BLYNK_WM false 130 | #define USE_BLYNK_WM true 131 | 132 | #include 133 | 134 | #if USE_BLYNK_WM 135 | #define USE_DYNAMIC_PARAMETERS true 136 | 137 | #include 138 | 139 | #else 140 | #include 141 | 142 | // Your WiFi credentials. 143 | #define ssid "****" 144 | #define pass "****" 145 | 146 | #define USE_LOCAL_SERVER true 147 | //#define USE_LOCAL_SERVER false 148 | 149 | #if USE_LOCAL_SERVER 150 | #define wifi_blynk_tok "****" 151 | #define gsm_blynk_tok "****" 152 | //#define blynk_server "account.duckdns.org" 153 | // Use direct IPAddress in case GPRS can't use DDNS fast enough and can't connect 154 | #define blynk_server "xxx.xxx.xxx.xxx" 155 | #else 156 | #define wifi_blynk_tok "****" 157 | #define gsm_blynk_tok "****" 158 | #define blynk_server "blynk-cloud.com" 159 | #endif 160 | 161 | #define apn "rogers-core-appl1.apn" 162 | #define gprsUser "" //"wapuser1" 163 | #define gprsPass "" //"wap" 164 | 165 | #endif //USE_BLYNK_WM 166 | 167 | #define BLYNK_HARDWARE_PORT 8080 168 | 169 | // Set serial for debug console (to the Serial Monitor, default speed 115200) 170 | #define SerialMon Serial 171 | 172 | #define RXD2 16 173 | #define TXD2 17 174 | 175 | // Use ESP32 Serial2 for GSM, Serial1 for TTGO T-Call 176 | #define SerialAT Serial1 177 | 178 | // Uncomment this if you want to see all AT commands 179 | #define DUMP_AT_COMMANDS false 180 | 181 | #if DUMP_AT_COMMANDS 182 | #include 183 | StreamDebugger debugger(SerialAT, SerialMon); 184 | TinyGsm modem(debugger); 185 | #else 186 | TinyGsm modem(SerialAT); 187 | #endif 188 | 189 | #define HOST_NAME "ESP32-GSM-WiFi" 190 | 191 | #endif //defines_h 192 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_MRD_GSM/dynamicParams.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | dynamicParams.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef dynamicParams_h 13 | #define dynamicParams_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | #if (USE_DYNAMIC_PARAMETERS) 18 | #warning USE_DYNAMIC_PARAMETERS 19 | #endif 20 | 21 | // USE_DYNAMIC_PARAMETERS defined in defined.h 22 | 23 | /////////////// Start dynamic Credentials /////////////// 24 | 25 | //Defined in 26 | /************************************** 27 | #define MAX_ID_LEN 5 28 | #define MAX_DISPLAY_NAME_LEN 16 29 | 30 | typedef struct 31 | { 32 | char id [MAX_ID_LEN + 1]; 33 | char displayName [MAX_DISPLAY_NAME_LEN + 1]; 34 | char *pdata; 35 | uint8_t maxlen; 36 | } MenuItem; 37 | **************************************/ 38 | 39 | #if USE_DYNAMIC_PARAMETERS 40 | 41 | #define MAX_MQTT_SERVER_LEN 34 42 | char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.ddns.net"; 43 | 44 | #define MAX_MQTT_PORT_LEN 6 45 | char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "1883"; 46 | 47 | #define MAX_MQTT_USERNAME_LEN 34 48 | char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "mqtt-user"; 49 | 50 | #define MAX_MQTT_PW_LEN 34 51 | char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "mqtt-pass"; 52 | 53 | #define MAX_MQTT_SUBS_TOPIC_LEN 34 54 | char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "SubTopic_ESP32_GSM"; 55 | 56 | #define MAX_MQTT_PUB_TOPIC_LEN 34 57 | char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "PubTopic_ESP32_GSM"; 58 | 59 | MenuItem myMenuItems [] = 60 | { 61 | { "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN }, 62 | { "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN }, 63 | { "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN }, 64 | { "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN }, 65 | { "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN }, 66 | { "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN }, 67 | }; 68 | 69 | uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; 70 | 71 | #else 72 | 73 | MenuItem myMenuItems [] = {}; 74 | 75 | uint16_t NUM_MENU_ITEMS = 0; 76 | #endif 77 | 78 | 79 | /////// // End dynamic Credentials /////////// 80 | 81 | #endif // #if USE_BLYNK_WM 82 | 83 | #endif //dynamicParams_h 84 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_SHT3x/Credentials.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | Credentials.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef Credentials_h 13 | #define Credentials_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | /// Start Default Config Data ////////////////// 18 | 19 | /* 20 | // Defined in 21 | 22 | #define SSID_MAX_LEN 32 23 | //From v1.0.10, WPA2 passwords can be up to 63 characters long. 24 | #define PASS_MAX_LEN 64 25 | 26 | typedef struct 27 | { 28 | char wifi_ssid[SSID_MAX_LEN]; 29 | char wifi_pw [PASS_MAX_LEN]; 30 | } WiFi_Credentials; 31 | 32 | #define BLYNK_SERVER_MAX_LEN 32 33 | #define BLYNK_TOKEN_MAX_LEN 36 34 | 35 | typedef struct 36 | { 37 | char blynk_server [BLYNK_SERVER_MAX_LEN]; 38 | char wifi_blynk_token [BLYNK_TOKEN_MAX_LEN]; 39 | char gsm_blynk_token [BLYNK_TOKEN_MAX_LEN]; 40 | } Blynk_Credentials; 41 | 42 | #define NUM_WIFI_CREDENTIALS 2 43 | #define NUM_BLYNK_CREDENTIALS 2 44 | 45 | // Configurable items besides fixed Header 46 | #define NUM_CONFIGURABLE_ITEMS ( 6 + (2 * NUM_WIFI_CREDENTIALS) + (3 * NUM_BLYNK_CREDENTIALS) ) 47 | #define DEFAULT_GPRS_PIN "1234" 48 | 49 | typedef struct Configuration 50 | { 51 | char header [16]; 52 | WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS]; 53 | Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 54 | int blynk_port; 55 | // YOUR GSM / GPRS RELATED 56 | char apn [32]; 57 | char gprsUser [32]; 58 | char gprsPass [32]; 59 | char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 60 | // END OF YOUR GSM / GPRS RELATED 61 | char board_name [24]; 62 | int checkSum; 63 | } Blynk_WF_Configuration; 64 | 65 | */ 66 | 67 | //bool LOAD_DEFAULT_CONFIG_DATA = true; 68 | bool LOAD_DEFAULT_CONFIG_DATA = false; 69 | 70 | Blynk_WF_Configuration defaultConfig = 71 | { 72 | //char header[16], dummy, not used 73 | "GSM", 74 | //WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS] 75 | //WiFi_Creds.wifi_ssid and WiFi_Creds.wifi_pw 76 | "SSID1", "password1", 77 | "SSID2", "password2", 78 | // Blynk_Credentials Blynk_Creds [NUM_BLYNK_CREDENTIALS]; 79 | // Blynk_Creds.blynk_server, Blynk_Creds.wifi_blynk_token and Blynk_Creds.gsm_blynk_token 80 | "account.ddns.net", "wifi_token", "gsm_token", 81 | "account.duckdns.org", "wifi_token1", "gsm_token1", 82 | //int blynk_port; 83 | 8080, 84 | // YOUR GSM / GPRS RELATED 85 | //char apn [32]; 86 | "rogers-core-appl1.apn", 87 | //char gprsUser [32]; 88 | "wapuser1", 89 | //char gprsPass [32]; 90 | "wap", 91 | //char gprsPin [12]; // A PIN (Personal Identification Number) is a 4-8 digit passcode 92 | "1245678", 93 | // END OF YOUR GSM / GPRS RELATED 94 | //char board_name [24]; 95 | "ESP32-GSM-WiFi", 96 | //int checkSum, dummy, not used 97 | 0 98 | }; 99 | 100 | /////////// End Default Config Data ///////////// 101 | 102 | #endif // #if USE_BLYNK_WM 103 | 104 | #endif //Credentials_h 105 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_SHT3x/defines.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | defines.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef defines_h 13 | #define defines_h 14 | 15 | #ifndef ESP32 16 | #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting. 17 | #endif 18 | 19 | #define BLYNK_PRINT Serial 20 | #define BLYNK_HEARTBEAT 60 21 | 22 | #define DOUBLERESETDETECTOR_DEBUG true //false 23 | #define BLYNK_WM_DEBUG 1 24 | 25 | // Not use #define USE_LITTLEFS and #define USE_SPIFFS => using SPIFFS for configuration data in WiFiManager 26 | // (USE_LITTLEFS == false) and (USE_SPIFFS == false) => using EEPROM for configuration data in WiFiManager 27 | // (USE_LITTLEFS == true) and (USE_SPIFFS == false) => using LITTLEFS for configuration data in WiFiManager 28 | // (USE_LITTLEFS == true) and (USE_SPIFFS == true) => using LITTLEFS for configuration data in WiFiManager 29 | // (USE_LITTLEFS == false) and (USE_SPIFFS == true) => using SPIFFS for configuration data in WiFiManager 30 | // Those above #define's must be placed before #include 31 | 32 | #define USE_LITTLEFS true 33 | #define USE_SPIFFS false 34 | 35 | #if USE_LITTLEFS 36 | #define CurrentFileFS F("LittleFS") 37 | #elif USE_SPIFFS 38 | #define CurrentFileFS F("SPIFFS") 39 | #else 40 | #define CurrentFileFS F("EEPROM") 41 | 42 | // EEPROM_SIZE must be <= 2048 and >= CONFIG_DATA_SIZE (currently 172 bytes) 43 | #define EEPROM_SIZE (2 * 1024) 44 | // EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE 45 | #define EEPROM_START 0 46 | #endif 47 | 48 | // Force some params in Blynk, only valid for library version 1.0.1 and later 49 | #define TIMEOUT_RECONNECT_WIFI 10000L 50 | #define RESET_IF_CONFIG_TIMEOUT true 51 | #define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5 52 | 53 | // Config Timeout 120s (default 60s) 54 | #define CONFIG_TIMEOUT 120000L 55 | // Those above #define's must be placed before #include 56 | 57 | // TTGO T-Call pin definitions 58 | #define MODEM_RST 5 59 | #define MODEM_PWKEY 4 60 | #define MODEM_POWER_ON 23 61 | 62 | #define MODEM_TX 27 63 | #define MODEM_RX 26 64 | 65 | #define I2C_SDA 21 66 | #define I2C_SCL 22 67 | 68 | // Select your modem: 69 | #define TINY_GSM_MODEM_SIM800 70 | //#define TINY_GSM_MODEM_SIM808 71 | //#define TINY_GSM_MODEM_SIM868 72 | //#define TINY_GSM_MODEM_SIM900 73 | //#define TINY_GSM_MODEM_SIM5300 74 | //#define TINY_GSM_MODEM_SIM5320 75 | //#define TINY_GSM_MODEM_SIM5360 76 | //#define TINY_GSM_MODEM_SIM7000 77 | //#define TINY_GSM_MODEM_SIM7100 78 | //#define TINY_GSM_MODEM_SIM7500 79 | //#define TINY_GSM_MODEM_SIM7600 80 | //#define TINY_GSM_MODEM_SIM7800 81 | //#define TINY_GSM_MODEM_UBLOX 82 | //#define TINY_GSM_MODEM_SARAR4 83 | //#define TINY_GSM_MODEM_M95 84 | //#define TINY_GSM_MODEM_BG96 85 | //#define TINY_GSM_MODEM_A6 86 | //#define TINY_GSM_MODEM_A7 87 | //#define TINY_GSM_MODEM_M590 88 | //#define TINY_GSM_MODEM_MC60 89 | //#define TINY_GSM_MODEM_MC60E 90 | //#define TINY_GSM_MODEM_XBEE 91 | //#define TINY_GSM_MODEM_SEQUANS_MONARCH 92 | 93 | // Increase RX buffer if needed 94 | #define TINY_GSM_RX_BUFFER 1024 95 | 96 | #include 97 | 98 | //#define USE_BLYNK_WM false 99 | #define USE_BLYNK_WM true 100 | 101 | #include 102 | 103 | #if USE_BLYNK_WM 104 | #define USE_DYNAMIC_PARAMETERS true 105 | 106 | #include 107 | 108 | #else 109 | #include 110 | 111 | // Your WiFi credentials. 112 | #define ssid "****" 113 | #define pass "****" 114 | 115 | #define USE_LOCAL_SERVER true 116 | //#define USE_LOCAL_SERVER false 117 | 118 | #if USE_LOCAL_SERVER 119 | #define wifi_blynk_tok "****" 120 | #define gsm_blynk_tok "****" 121 | //#define blynk_server "account.duckdns.org" 122 | // Use direct IPAddress in case GPRS can't use DDNS fast enough and can't connect 123 | #define blynk_server "xxx.xxx.xxx.xxx" 124 | #else 125 | #define wifi_blynk_tok "****" 126 | #define gsm_blynk_tok "****" 127 | #define blynk_server "blynk-cloud.com" 128 | #endif 129 | 130 | #define apn "rogers-core-appl1.apn" 131 | #define gprsUser "" //"wapuser1" 132 | #define gprsPass "" //"wap" 133 | 134 | #endif //USE_BLYNK_WM 135 | 136 | #define BLYNK_HARDWARE_PORT 8080 137 | 138 | // Set serial for debug console (to the Serial Monitor, default speed 115200) 139 | #define SerialMon Serial 140 | 141 | #define RXD2 16 142 | #define TXD2 17 143 | 144 | // Use ESP32 Serial2 for GSM, Serial1 for TTGO T-Call 145 | #define SerialAT Serial1 146 | 147 | // Uncomment this if you want to see all AT commands 148 | #define DUMP_AT_COMMANDS false 149 | 150 | #if DUMP_AT_COMMANDS 151 | #include 152 | StreamDebugger debugger(SerialAT, SerialMon); 153 | TinyGsm modem(debugger); 154 | #else 155 | TinyGsm modem(SerialAT); 156 | #endif 157 | 158 | #define HOST_NAME "ESP32-GSM-WiFi" 159 | 160 | #endif //defines_h 161 | -------------------------------------------------------------------------------- /examples/TTGO_TCALL_SHT3x/dynamicParams.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | dynamicParams.h 3 | For ESP32 TTGO-TCALL boards to run GSM/GPRS and WiFi simultaneously, using config portal feature 4 | Uploading SHT3x temperature and humidity data to Blynk 5 | 6 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 7 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 8 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 9 | Licensed under MIT license 10 | *****************************************************************************************************************************/ 11 | 12 | #ifndef dynamicParams_h 13 | #define dynamicParams_h 14 | 15 | #if USE_BLYNK_WM 16 | 17 | #if (USE_DYNAMIC_PARAMETERS) 18 | #warning USE_DYNAMIC_PARAMETERS 19 | #endif 20 | 21 | // USE_DYNAMIC_PARAMETERS defined in defined.h 22 | 23 | /////////////// Start dynamic Credentials /////////////// 24 | 25 | //Defined in 26 | /************************************** 27 | #define MAX_ID_LEN 5 28 | #define MAX_DISPLAY_NAME_LEN 16 29 | 30 | typedef struct 31 | { 32 | char id [MAX_ID_LEN + 1]; 33 | char displayName [MAX_DISPLAY_NAME_LEN + 1]; 34 | char *pdata; 35 | uint8_t maxlen; 36 | } MenuItem; 37 | **************************************/ 38 | 39 | #if USE_DYNAMIC_PARAMETERS 40 | 41 | #define MAX_MQTT_SERVER_LEN 34 42 | char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.ddns.net"; 43 | 44 | #define MAX_MQTT_PORT_LEN 6 45 | char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "1883"; 46 | 47 | #define MAX_MQTT_USERNAME_LEN 34 48 | char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "mqtt-user"; 49 | 50 | #define MAX_MQTT_PW_LEN 34 51 | char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "mqtt-pass"; 52 | 53 | #define MAX_MQTT_SUBS_TOPIC_LEN 34 54 | char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "SubTopic_ESP32_GSM"; 55 | 56 | #define MAX_MQTT_PUB_TOPIC_LEN 34 57 | char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "PubTopic_ESP32_GSM"; 58 | 59 | MenuItem myMenuItems [] = 60 | { 61 | { "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN }, 62 | { "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN }, 63 | { "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN }, 64 | { "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN }, 65 | { "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN }, 66 | { "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN }, 67 | }; 68 | 69 | uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; 70 | 71 | #else 72 | 73 | MenuItem myMenuItems [] = {}; 74 | 75 | uint16_t NUM_MENU_ITEMS = 0; 76 | #endif 77 | 78 | 79 | /////// // End dynamic Credentials /////////// 80 | 81 | #endif // #if USE_BLYNK_WM 82 | 83 | #endif //dynamicParams_h 84 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Data types (KEYWORD1) 3 | ####################################### 4 | 5 | Blynk KEYWORD1 6 | BlynkTimer KEYWORD1 7 | WidgetBridge KEYWORD1 8 | WidgetLCD KEYWORD1 9 | WidgetLED KEYWORD1 10 | WidgetRTC KEYWORD1 11 | WidgetSD KEYWORD1 12 | WidgetTerminal KEYWORD1 13 | WidgetMap KEYWORD1 14 | WidgetTable KEYWORD1 15 | BlynkParam KEYWORD1 16 | BlynkParamAllocated KEYWORD1 17 | 18 | ####################################### 19 | # Methods and Functions (KEYWORD2) 20 | ####################################### 21 | 22 | begin KEYWORD2 23 | config KEYWORD2 24 | run KEYWORD2 25 | connect KEYWORD2 26 | connected KEYWORD2 27 | tweet KEYWORD2 28 | notify KEYWORD2 29 | email KEYWORD2 30 | virtualWrite KEYWORD2 31 | virtualWriteBinary KEYWORD2 32 | syncAll KEYWORD2 33 | syncVirtual KEYWORD2 34 | setProperty KEYWORD2 35 | logEvent KEYWORD2 36 | setConfigPortalIP KEYWORD2 37 | setConfigPortal KEYWORD2 38 | setConfigPortalChannel KEYWORD2 39 | setSTAStaticIPConfig KEYWORD2 40 | getBoardName KEYWORD2 41 | getWiFiSSID KEYWORD2 42 | getWiFiPW KEYWORD2 43 | getServerName KEYWORD2 44 | getWiFiToken KEYWORD2 45 | getGSMToken KEYWORD2 46 | getAPN KEYWORD2 47 | getGPRSUser KEYWORD2 48 | getGPRSPass KEYWORD2 49 | getGPRSPIN KEYWORD2 50 | getHWPort KEYWORD2 51 | setHostname KEYWORD2 52 | getFullConfigData KEYWORD2 53 | inConfigPortal KEYWORD2 54 | clearConfigData KEYWORD2 55 | resetAndEnterConfigPortal KEYWORD2 56 | resetAndEnterConfigPortalPersistent KEYWORD2 57 | 58 | ####################################### 59 | # Handler helpers 60 | ####################################### 61 | 62 | BLYNK_READ KEYWORD2 63 | BLYNK_WRITE KEYWORD2 64 | BLYNK_READ_DEFAULT KEYWORD2 65 | BLYNK_WRITE_DEFAULT KEYWORD2 66 | BLYNK_ATTACH_WIDGET KEYWORD2 67 | BLYNK_CONNECTED KEYWORD2 68 | #BLYNK_DISCONNECTED KEYWORD2 69 | BLYNK_APP_CONNECTED KEYWORD2 70 | BLYNK_APP_DISCONNECTED KEYWORD2 71 | 72 | BLYNK_OUTPUT KEYWORD2 73 | BLYNK_INPUT KEYWORD2 74 | BLYNK_OUTPUT_DEFAULT KEYWORD2 75 | BLYNK_INPUT_DEFAULT KEYWORD2 76 | 77 | ####################################### 78 | # Variables binding 79 | ####################################### 80 | BLYNK_VAR_INT KEYWORD2 81 | BLYNK_VAR_LONG KEYWORD2 82 | BLYNK_VAR_DOUBLE KEYWORD2 83 | BLYNK_VAR_STRING KEYWORD2 84 | 85 | ####################################### 86 | # Special defines 87 | ####################################### 88 | BLYNK_DEBUG KEYWORD2 89 | BLYNK_DEBUG_ALL KEYWORD2 90 | BLYNK_PRINT KEYWORD2 91 | 92 | BLYNK_HEARTBEAT KEYWORD2 93 | BLYNK_EXPERIMENTAL KEYWORD2 94 | BLYNK_NO_BUILTIN KEYWORD2 95 | BLYNK_NO_FLOAT KEYWORD2 96 | BLYNK_NO_FANCY_LOGO KEYWORD2 97 | BLYNK_FANCY_LOGO_3D KEYWORD2 98 | BLYNK_USE_DIRECT_CONNECT KEYWORD2 99 | BLYNK_MAX_SENDBYTES KEYWORD2 100 | BLYNK_MAX_READBYTES KEYWORD2 101 | 102 | ####################################### 103 | # Periodic actions 104 | ####################################### 105 | #BLYNK_EVERY_N_MILLIS KEYWORD2 106 | #BLYNK_EVERY_N_SECONDS KEYWORD2 107 | #BLYNK_EVERY_N_MINUTES KEYWORD2 108 | #BLYNK_EVERY_N_HOURS KEYWORD2 109 | 110 | ####################################### 111 | # Literals (LITERAL1) 112 | ####################################### 113 | 114 | ####################################### 115 | # Virtual pins 116 | ####################################### 117 | V0 LITERAL1 118 | V1 LITERAL1 119 | V2 LITERAL1 120 | V3 LITERAL1 121 | V4 LITERAL1 122 | V5 LITERAL1 123 | V6 LITERAL1 124 | V7 LITERAL1 125 | V8 LITERAL1 126 | V9 LITERAL1 127 | V10 LITERAL1 128 | V11 LITERAL1 129 | V12 LITERAL1 130 | V13 LITERAL1 131 | V14 LITERAL1 132 | V15 LITERAL1 133 | V16 LITERAL1 134 | V17 LITERAL1 135 | V18 LITERAL1 136 | V19 LITERAL1 137 | V20 LITERAL1 138 | V21 LITERAL1 139 | V22 LITERAL1 140 | V23 LITERAL1 141 | V24 LITERAL1 142 | V25 LITERAL1 143 | V26 LITERAL1 144 | V27 LITERAL1 145 | V28 LITERAL1 146 | V29 LITERAL1 147 | V30 LITERAL1 148 | V31 LITERAL1 149 | V32 LITERAL1 150 | V33 LITERAL1 151 | V34 LITERAL1 152 | V35 LITERAL1 153 | V36 LITERAL1 154 | V37 LITERAL1 155 | V38 LITERAL1 156 | V39 LITERAL1 157 | V40 LITERAL1 158 | V41 LITERAL1 159 | V42 LITERAL1 160 | V43 LITERAL1 161 | V44 LITERAL1 162 | V45 LITERAL1 163 | V46 LITERAL1 164 | V47 LITERAL1 165 | V48 LITERAL1 166 | V49 LITERAL1 167 | V50 LITERAL1 168 | V51 LITERAL1 169 | V52 LITERAL1 170 | V53 LITERAL1 171 | V54 LITERAL1 172 | V55 LITERAL1 173 | V56 LITERAL1 174 | V57 LITERAL1 175 | V58 LITERAL1 176 | V59 LITERAL1 177 | V60 LITERAL1 178 | V61 LITERAL1 179 | V62 LITERAL1 180 | V63 LITERAL1 181 | V64 LITERAL1 182 | V65 LITERAL1 183 | V66 LITERAL1 184 | V67 LITERAL1 185 | V68 LITERAL1 186 | V69 LITERAL1 187 | V70 LITERAL1 188 | V71 LITERAL1 189 | V72 LITERAL1 190 | V73 LITERAL1 191 | V74 LITERAL1 192 | V75 LITERAL1 193 | V76 LITERAL1 194 | V77 LITERAL1 195 | V78 LITERAL1 196 | V79 LITERAL1 197 | V80 LITERAL1 198 | V81 LITERAL1 199 | V82 LITERAL1 200 | V83 LITERAL1 201 | V84 LITERAL1 202 | V85 LITERAL1 203 | V86 LITERAL1 204 | V87 LITERAL1 205 | V88 LITERAL1 206 | V89 LITERAL1 207 | V90 LITERAL1 208 | V91 LITERAL1 209 | V92 LITERAL1 210 | V93 LITERAL1 211 | V94 LITERAL1 212 | V95 LITERAL1 213 | V96 LITERAL1 214 | V97 LITERAL1 215 | V98 LITERAL1 216 | V99 LITERAL1 217 | V100 LITERAL1 218 | V101 LITERAL1 219 | V102 LITERAL1 220 | V103 LITERAL1 221 | V104 LITERAL1 222 | V105 LITERAL1 223 | V106 LITERAL1 224 | V107 LITERAL1 225 | V108 LITERAL1 226 | V109 LITERAL1 227 | V110 LITERAL1 228 | V111 LITERAL1 229 | V112 LITERAL1 230 | V113 LITERAL1 231 | V114 LITERAL1 232 | V115 LITERAL1 233 | V116 LITERAL1 234 | V117 LITERAL1 235 | V118 LITERAL1 236 | V119 LITERAL1 237 | V120 LITERAL1 238 | V121 LITERAL1 239 | V122 LITERAL1 240 | V123 LITERAL1 241 | V124 LITERAL1 242 | V125 LITERAL1 243 | V126 LITERAL1 244 | V127 LITERAL1 245 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BlynkGSM_Manager", 3 | "version": "1.2.1", 4 | "description": "Library for enabling GSM/GPRS and WiFi running simultaneously as well as configuring/auto(re)connecting at runtime GSM shields to Internet and Blynk and ESP8266/ESP32 WiFi modules to best or available MultiWiFi APs and MultiBlynk servers. Enable adding dynamic custom parameters from sketch and input using the same Config Portal. Config Portal will be auto-adjusted to match the number of dynamic parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Static STA IP and DHCP Hostname as well as Config Portal AP channel, IP, SSID, Password can be configured. Multi or Double DetectDetector feature permits entering Config Portal as requested.", 5 | "keywords": "sensors, control, device, smartphone, mobile, app, web, cloud, communication, protocol, iot, m2m, wifi, ble, bluetooth, ethernet, usb, serial, gsm, gprs, 3g, data, esp8266, esp32, http, drd, mrd, double-reset, multi-reset, configportal, portal, credentials", 6 | "authors": 7 | { 8 | "name": "Khoi Hoang", 9 | "url": "https://github.com/khoih-prog", 10 | "maintainer": true 11 | }, 12 | "repository": 13 | { 14 | "type": "git", 15 | "url": "https://github.com/khoih-prog/BlynkGSM_Manager" 16 | }, 17 | "homepage": "https://github.com/khoih-prog/BlynkGSM_Manager", 18 | "export": { 19 | "exclude": [ 20 | "linux", 21 | "extras", 22 | "tests" 23 | ] 24 | }, 25 | "dependencies": 26 | [ 27 | { 28 | "owner": "blynkkk", 29 | "name": "Blynk", 30 | "version": "^1.0.1", 31 | "platforms": ["espressif8266", "espressif32"] 32 | }, 33 | { 34 | "owner": "khoih-prog", 35 | "name": "ESP_DoubleResetDetector", 36 | "version": "^1.2.1", 37 | "platforms": ["espressif8266", "espressif32"] 38 | }, 39 | { 40 | "owner": "khoih-prog", 41 | "name": "ESP_MultiResetDetector", 42 | "version": "^1.2.1", 43 | "platforms": ["espressif8266", "espressif32"] 44 | }, 45 | { 46 | "owner": "vshymanskyy", 47 | "name": "TinyGSM", 48 | "version": "^0.11.5", 49 | "platforms": ["espressif8266", "espressif32"] 50 | }, 51 | { 52 | "owner": "lorol", 53 | "name": "LittleFS_esp32", 54 | "version": ">=1.0.6", 55 | "platforms": ["espressif32"] 56 | } 57 | ], 58 | "frameworks": "*", 59 | "platforms": "*", 60 | "examples": "examples/*/*/*.ino" 61 | } 62 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=BlynkGSM_Manager 2 | version=1.2.1 3 | author=Khoi Hoang 4 | license=MIT 5 | maintainer=Khoi Hoang 6 | sentence=Simple GSM shield Credentials Manager for Blynk and ESP32 / ESP8266 boards, with or without SSL, configuration data saved in LittleFS / SPIFFS / EEPROM. 7 | paragraph=Library for enabling GSM/GPRS and WiFi running simultaneously as well as configuring/auto(re)connecting at runtime GSM shields to Internet and Blynk and ESP8266/ESP32 WiFi modules to best or available MultiWiFi APs and MultiBlynk servers. Enable adding dynamic custom parameters from sketch and input using the same Config Portal. Config Portal will be auto-adjusted to match the number of dynamic parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Static STA IP and DHCP Hostname as well as Config Portal AP channel, IP, SSID, Password can be configured. Multi or Double DetectDetector feature permits entering Config Portal as requested. 8 | category=Communication 9 | url=https://github.com/khoih-prog/BlynkGSM_Manager 10 | architectures=esp32,esp8266 11 | depends=Blynk,TinyGSM,ESP_DoubleResetDetector,ESP_MultiResetDetector,LittleFS_esp32 12 | includes=BlynkSimpleESP32_GSM_WFM.h,BlynkSimpleESP8266_GSM_WFM.h,BlynkSimpleESP32_GSM_WF.h,BlynkSimpleESP8266_GSM_WF.h,BlynkSimpleTinyGSM_M.h 13 | -------------------------------------------------------------------------------- /pics/Selection_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoih-prog/BlynkGSM_Manager/3f81a55696bcf9e7098ff6f49c7c1c9fd6ac833a/pics/Selection_1.jpg -------------------------------------------------------------------------------- /pics/Selection_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoih-prog/BlynkGSM_Manager/3f81a55696bcf9e7098ff6f49c7c1c9fd6ac833a/pics/Selection_2.png -------------------------------------------------------------------------------- /pics/Selection_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoih-prog/BlynkGSM_Manager/3f81a55696bcf9e7098ff6f49c7c1c9fd6ac833a/pics/Selection_3.png -------------------------------------------------------------------------------- /platformio/platformio.ini: -------------------------------------------------------------------------------- 1 | ;PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [platformio] 12 | ; ============================================================ 13 | ; chose environment: 14 | ; ESP8266 15 | ; ESP32 16 | ; ============================================================ 17 | default_envs = ESP8266 18 | ;default_envs = ESP32 19 | 20 | [env] 21 | ; ============================================================ 22 | ; Serial configuration 23 | ; choose upload speed, serial-monitor speed 24 | ; ============================================================ 25 | upload_speed = 921600 26 | ;upload_port = COM11 27 | ;monitor_speed = 9600 28 | ;monitor_port = COM11 29 | 30 | ; Checks for the compatibility with frameworks and dev/platforms 31 | lib_compat_mode = strict 32 | 33 | lib_deps = 34 | ; PlatformIO 4.x 35 | Blynk@~1.0.1 36 | TinyGSM@~0.11.3 37 | ESP_DoubleResetDetector@~1.1.1 38 | ESP_MultiResetDetector@~1.1.1 39 | ; PlatformIO 5.x 40 | ; blynkkk/Blynk@~1.0.1 41 | ; vshymanskyy/TinyGSM@~0.11.3 42 | ; khoih-prog/ESP_DoubleResetDetector@~1.1.1 43 | ; khoih-prog/ESP_MultiResetDetector@~1.1.1 44 | 45 | build_flags = 46 | ; set your debug output (default=Serial) 47 | -D DEBUG_ESP_PORT=Serial 48 | ; comment the folowing line to enable WiFi debugging 49 | -D NDEBUG 50 | 51 | [env:ESP8266] 52 | platform = espressif8266 53 | framework = arduino 54 | ; ============================================================ 55 | ; Board configuration 56 | ; choose your board by uncommenting one of the following lines 57 | ; ============================================================ 58 | ;board = gen4iod 59 | ;board = huzzah 60 | ;board = oak 61 | ;board = esp_wroom_02 62 | ;board = espduino 63 | ;board = espectro 64 | ;board = espino 65 | ;board = espresso_lite_v1 66 | ;board = espresso_lite_v2 67 | ;board = esp12e 68 | ;board = esp01_1m 69 | ;board = esp01 70 | ;board = esp07 71 | ;board = esp8285 72 | ;board = heltec_wifi_kit_8 73 | ;board = inventone 74 | ;board = nodemcu 75 | board = nodemcuv2 76 | ;board = modwifi 77 | ;board = phoenix_v1 78 | ;board = phoenix_v2 79 | ;board = sparkfunBlynk 80 | ;board = thing 81 | ;board = thingdev 82 | ;board = esp210 83 | ;board = espinotee 84 | ;board = d1 85 | ;board = d1_mini 86 | ;board = d1_mini_lite 87 | ;board = d1_mini_pro 88 | ;board = wifi_slot 89 | ;board = wifiduino 90 | ;board = wifinfo 91 | ;board = wio_link 92 | ;board = wio_node 93 | ;board = xinabox_cw01 94 | ;board = esp32doit-devkit-v1 95 | 96 | [env:ESP32] 97 | platform = espressif32 98 | framework = arduino, espidf 99 | ; ============================================================ 100 | ; Board configuration 101 | ; choose your board by uncommenting one of the following lines 102 | ; ============================================================ 103 | ;board = esp32cam 104 | ;board = alksesp32 105 | ;board = featheresp32 106 | ;board = espea32 107 | ;board = bpi-bit 108 | ;board = d-duino-32 109 | board = esp32doit-devkit-v1 110 | ;board = pocket_32 111 | ;board = fm-devkit 112 | ;board = pico32 113 | ;board = esp32-evb 114 | ;board = esp32-gateway 115 | ;board = esp32-pro 116 | ;board = esp32-poe 117 | ;board = oroca_edubot 118 | ;board = onehorse32dev 119 | ;board = lopy 120 | ;board = lopy4 121 | ;board = wesp32 122 | ;board = esp32thing 123 | ;board = sparkfun_lora_gateway_1-channel 124 | ;board = ttgo-lora32-v1 125 | ;board = ttgo-t-beam 126 | ;board = turta_iot_node 127 | ;board = lolin_d32 128 | ;board = lolin_d32_pro 129 | ;board = lolin32 130 | ;board = wemosbat 131 | ;board = widora-air 132 | ;board = xinabox_cw02 133 | ;board = iotbusio 134 | ;board = iotbusproteus 135 | ;board = nina_w10 136 | -------------------------------------------------------------------------------- /src/Adapters/BlynkGsm_ESP32M.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | BlynkGsm_ESP32M.h 3 | For ESP32 with GSM/GPRS and WiFi running simultaneously, with WiFi config portal 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | 10 | Original Blynk Library author: 11 | @file BlynkSimpleESP8266.h 12 | @author Volodymyr Shymanskyy 13 | @license This project is released under the MIT License (MIT) 14 | @copyright Copyright (c) 2015 Volodymyr Shymanskyy 15 | @date Oct 2016 16 | @brief 17 | 18 | Version: 1.2.1 19 | 20 | Version Modified By Date Comments 21 | ------- ----------- ---------- ----------- 22 | 1.0.0 K Hoang 17/01/2020 Initial coding. Add config portal similar to Blynk_WM library. 23 | 1.0.1 K Hoang 27/01/2020 Change Synch XMLHttpRequest to Async (https://xhr.spec.whatwg.org/). Reduce code size 24 | 1.0.2 K Hoang 08/02/2020 Enable GSM/GPRS and WiFi running simultaneously 25 | 1.0.3 K Hoang 18/02/2020 Add checksum. Add clearConfigData() 26 | 1.0.4 K Hoang 14/03/2020 Enhance Config Portal GUI. Reduce code size. 27 | 1.0.5 K Hoang 20/03/2020 Add more modem supports. See the list in README.md 28 | 1.0.6 K Hoang 07/04/2020 Enable adding dynamic custom parameters from sketch 29 | 1.0.7 K Hoang 09/04/2020 SSID password maxlen is 63 now. Permit special chars # and % in input data. 30 | 1.0.8 K Hoang 14/04/2020 Fix bug. 31 | 1.0.9 K Hoang 31/05/2020 Update to use LittleFS for ESP8266 core 2.7.1+. Add Configurable Config Portal Title, 32 | Default Config Data and DRD. Add MultiWiFi/Blynk features for WiFi and GPRS/GSM 33 | 1.0.10 K Hoang 26/08/2020 Use MultiWiFi. Auto format SPIFFS/LittleFS for first time usage. 34 | Fix bug and logic of USE_DEFAULT_CONFIG_DATA. 35 | 1.1.0 K Hoang 01/01/2021 Add support to ESP32 LittleFS. Remove possible compiler warnings. Update examples. Add MRD 36 | 1.2.0 K Hoang 01/02/2021 Add functions to control Config Portal (CP) from software or Virtual Switches 37 | Fix CP and Dynamic Params bugs. To permit autoreset after timeout if DRD/MRD or forced CP 38 | 1.2.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json` 39 | *****************************************************************************************************************************/ 40 | 41 | #pragma once 42 | 43 | #ifndef ESP32 44 | #error This code is designed to run on ESP32, not ESP8266 nor Arduino AVR platform! Please check your Tools->Board setting. 45 | #endif 46 | 47 | #ifndef BlynkGsm_ESP32M_h 48 | #define BlynkGsm_ESP32M_h 49 | 50 | #ifndef BLYNK_GSM_ESP32_DEBUG 51 | #define BLYNK_GSM_ESP32_DEBUG 0 52 | #endif 53 | 54 | #ifndef BLYNK_INFO_CONNECTION 55 | #if defined(TINY_GSM_MODEM_SIM800) 56 | #define BLYNK_INFO_CONNECTION "SIM800" 57 | #elif defined(TINY_GSM_MODEM_SIM808) 58 | #define BLYNK_INFO_CONNECTION "SIM808" 59 | #elif defined(TINY_GSM_MODEM_SIM868) 60 | #define BLYNK_INFO_CONNECTION "SIM868" 61 | #elif defined(TINY_GSM_MODEM_SIM900) 62 | #define BLYNK_INFO_CONNECTION "SIM900" 63 | #elif defined(TINY_GSM_MODEM_SIM5300) 64 | #define BLYNK_INFO_CONNECTION "SIM5300" 65 | #elif defined(TINY_GSM_MODEM_SIM5320) 66 | #define BLYNK_INFO_CONNECTION "SIM5320" 67 | #elif defined(TINY_GSM_MODEM_SIM5360) 68 | #define BLYNK_INFO_CONNECTION "SIM5360" 69 | #elif defined(TINY_GSM_MODEM_SIM7000) 70 | #define BLYNK_INFO_CONNECTION "SIM7000" 71 | #elif defined(TINY_GSM_MODEM_SIM7100) 72 | #define BLYNK_INFO_CONNECTION "SIM7100" 73 | #elif defined(TINY_GSM_MODEM_SIM7500) 74 | #define BLYNK_INFO_CONNECTION "SIM7500" 75 | #elif defined(TINY_GSM_MODEM_SIM7600) 76 | #define BLYNK_INFO_CONNECTION "SIM7600" 77 | #elif defined(TINY_GSM_MODEM_SIM7800) 78 | #define BLYNK_INFO_CONNECTION "SIM7800" 79 | #elif defined(TINY_GSM_MODEM_UBLOX) 80 | #define BLYNK_INFO_CONNECTION "UBLOX" 81 | #elif defined(TINY_GSM_MODEM_SARAR4) 82 | #define BLYNK_INFO_CONNECTION "SARAR4" 83 | #elif defined(TINY_GSM_MODEM_M95) 84 | #define BLYNK_INFO_CONNECTION "M95" 85 | #elif defined(TINY_GSM_MODEM_BG96) 86 | #define BLYNK_INFO_CONNECTION "BG96" 87 | #elif defined(TINY_GSM_MODEM_A6) 88 | #define BLYNK_INFO_CONNECTION "A6" 89 | #elif defined(TINY_GSM_MODEM_A7) 90 | #define BLYNK_INFO_CONNECTION "A7" 91 | #elif defined(TINY_GSM_MODEM_M590) 92 | #define BLYNK_INFO_CONNECTION "M590" 93 | #elif defined(TINY_GSM_MODEM_MC60) 94 | #define BLYNK_INFO_CONNECTION "MC60" 95 | #elif defined(TINY_GSM_MODEM_MC60) 96 | #define BLYNK_INFO_CONNECTION "MC60" 97 | #elif defined(TINY_GSM_MODEM_MC60E) 98 | #define BLYNK_INFO_CONNECTION "MC60E" 99 | #elif defined(TINY_GSM_MODEM_XBEE) 100 | #define BLYNK_INFO_CONNECTION "XBEE" 101 | #elif defined(TINY_GSM_MODEM_SEQUANS_MONARCH) 102 | #define BLYNK_INFO_CONNECTION "SEQUANS_MONARCH" 103 | #else 104 | #define BLYNK_INFO_CONNECTION "TinyGSM" 105 | #endif 106 | #endif 107 | 108 | #ifndef BLYNK_HEARTBEAT 109 | #define BLYNK_HEARTBEAT 60 110 | #endif 111 | 112 | #ifndef BLYNK_TIMEOUT_MS 113 | #define BLYNK_TIMEOUT_MS 30000UL 114 | #endif 115 | 116 | #define BLYNK_SEND_ATOMIC 117 | 118 | #include 119 | #include 120 | #include 121 | #include 122 | 123 | 124 | class BlynkSIM 125 | : public BlynkProtocol 126 | { 127 | typedef BlynkProtocol Base; 128 | public: 129 | BlynkSIM(BlynkArduinoClient& transp) 130 | : Base(transp) 131 | , modem(NULL) 132 | {} 133 | 134 | bool connectNetwork(const char* apn, const char* user, const char* pass) 135 | { 136 | BLYNK_LOG1(BLYNK_F("InitModem")); 137 | if (!modem->begin()) 138 | { 139 | BLYNK_LOG1(BLYNK_F("failed")); 140 | return false; 141 | } 142 | 143 | switch (modem->getSimStatus()) 144 | { 145 | case SIM_ERROR: 146 | BLYNK_LOG1(BLYNK_F("NoSIM")); 147 | return false; 148 | case SIM_LOCKED: 149 | BLYNK_LOG1(BLYNK_F("SIMPINLocked")); 150 | return false; 151 | default: 152 | break; 153 | } 154 | 155 | BLYNK_LOG1(BLYNK_F("Con2Network")); 156 | if (modem->waitForNetwork()) 157 | { 158 | BLYNK_LOG2(BLYNK_F("Network:"), modem->getOperator()); 159 | } 160 | else 161 | { 162 | BLYNK_LOG1(BLYNK_F("NetworkRegisterFailed")); 163 | return false; 164 | } 165 | 166 | BLYNK_LOG2(BLYNK_F("Conn2 "), apn); 167 | if (!modem->gprsConnect(apn, user, pass)) 168 | { 169 | BLYNK_LOG1(BLYNK_F("GPRSConFailed")); 170 | return false; 171 | } 172 | 173 | BLYNK_LOG1(BLYNK_F("GPRSConOK")); 174 | return true; 175 | } 176 | 177 | void config(TinyGsm& gsm, 178 | const char* auth, 179 | const char* domain = BLYNK_DEFAULT_DOMAIN, 180 | uint16_t port = BLYNK_DEFAULT_PORT) 181 | { 182 | Base::begin(auth); 183 | modem = &gsm; 184 | client.init(modem); 185 | this->conn.setClient(&client); 186 | this->conn.begin(domain, port); 187 | } 188 | 189 | // KH, New 190 | void config(TinyGsm& gsm, 191 | const char* auth, 192 | IPAddress blynk_server_ip, 193 | uint16_t port = BLYNK_DEFAULT_PORT) 194 | { 195 | Base::begin(auth); 196 | modem = &gsm; 197 | client.init(modem); 198 | this->conn.setClient(&client); 199 | this->conn.begin(blynk_server_ip, port); 200 | } 201 | 202 | void begin(const char* auth, 203 | TinyGsm& gsm, 204 | const char* apn, 205 | const char* user, 206 | const char* pass, 207 | const char* domain = BLYNK_DEFAULT_DOMAIN, 208 | uint16_t port = BLYNK_DEFAULT_PORT) 209 | { 210 | config(gsm, auth, domain, port); 211 | connectNetwork(apn, user, pass); 212 | while (this->connect() != true) {} 213 | } 214 | 215 | private: 216 | TinyGsm* modem; 217 | TinyGsmClient client; 218 | }; 219 | 220 | #endif 221 | -------------------------------------------------------------------------------- /src/Adapters/BlynkGsm_ESP8266M.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | BlynkGsm_ESP8266M.h 3 | For ESP8266 with GSM/GPRS and WiFi running simultaneously, with WiFi config portal 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | 10 | Original Blynk Library author: 11 | @file BlynkSimpleESP8266.h 12 | @author Volodymyr Shymanskyy 13 | @license This project is released under the MIT License (MIT) 14 | @copyright Copyright (c) 2015 Volodymyr Shymanskyy 15 | @date Oct 2016 16 | @brief 17 | 18 | Version: 1.2.1 19 | 20 | Version Modified By Date Comments 21 | ------- ----------- ---------- ----------- 22 | 1.0.0 K Hoang 17/01/2020 Initial coding. Add config portal similar to Blynk_WM library. 23 | 1.0.1 K Hoang 27/01/2020 Change Synch XMLHttpRequest to Async (https://xhr.spec.whatwg.org/). Reduce code size 24 | 1.0.2 K Hoang 08/02/2020 Enable GSM/GPRS and WiFi running simultaneously 25 | 1.0.3 K Hoang 18/02/2020 Add checksum. Add clearConfigData() 26 | 1.0.4 K Hoang 14/03/2020 Enhance Config Portal GUI. Reduce code size. 27 | 1.0.5 K Hoang 20/03/2020 Add more modem supports. See the list in README.md 28 | 1.0.6 K Hoang 07/04/2020 Enable adding dynamic custom parameters from sketch 29 | 1.0.7 K Hoang 09/04/2020 SSID password maxlen is 63 now. Permit special chars # and % in input data. 30 | 1.0.8 K Hoang 14/04/2020 Fix bug. 31 | 1.0.9 K Hoang 31/05/2020 Update to use LittleFS for ESP8266 core 2.7.1+. Add Configurable Config Portal Title, 32 | Default Config Data and DRD. Add MultiWiFi/Blynk features for WiFi and GPRS/GSM 33 | 1.0.10 K Hoang 26/08/2020 Use MultiWiFi. Auto format SPIFFS/LittleFS for first time usage. 34 | Fix bug and logic of USE_DEFAULT_CONFIG_DATA. 35 | 1.1.0 K Hoang 01/01/2021 Add support to ESP32 LittleFS. Remove possible compiler warnings. Update examples. Add MRD 36 | 1.2.0 K Hoang 01/02/2021 Add functions to control Config Portal (CP) from software or Virtual Switches 37 | Fix CP and Dynamic Params bugs. To permit autoreset after timeout if DRD/MRD or forced CP 38 | 1.2.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json` 39 | *****************************************************************************************************************************/ 40 | 41 | #pragma once 42 | 43 | #ifndef ESP8266 44 | #error This code is designed to run on ESP8266, not ESP32 nor Arduino AVR platform! Please check your Tools->Board setting. 45 | #endif 46 | 47 | #ifndef BlynkGsm_ESP8266M_h 48 | #define BlynkGsm_ESP8266M_h 49 | 50 | #ifndef BLYNK_GSM_ESP8266_DEBUG 51 | #define BLYNK_GSM_ESP8266_DEBUG 0 52 | #endif 53 | 54 | #ifndef BLYNK_INFO_CONNECTION 55 | #if defined(TINY_GSM_MODEM_SIM800) 56 | #define BLYNK_INFO_CONNECTION "SIM800" 57 | #elif defined(TINY_GSM_MODEM_SIM808) 58 | #define BLYNK_INFO_CONNECTION "SIM808" 59 | #elif defined(TINY_GSM_MODEM_SIM868) 60 | #define BLYNK_INFO_CONNECTION "SIM868" 61 | #elif defined(TINY_GSM_MODEM_SIM900) 62 | #define BLYNK_INFO_CONNECTION "SIM900" 63 | #elif defined(TINY_GSM_MODEM_SIM5300) 64 | #define BLYNK_INFO_CONNECTION "SIM5300" 65 | #elif defined(TINY_GSM_MODEM_SIM5320) 66 | #define BLYNK_INFO_CONNECTION "SIM5320" 67 | #elif defined(TINY_GSM_MODEM_SIM5360) 68 | #define BLYNK_INFO_CONNECTION "SIM5360" 69 | #elif defined(TINY_GSM_MODEM_SIM7000) 70 | #define BLYNK_INFO_CONNECTION "SIM7000" 71 | #elif defined(TINY_GSM_MODEM_SIM7100) 72 | #define BLYNK_INFO_CONNECTION "SIM7100" 73 | #elif defined(TINY_GSM_MODEM_SIM7500) 74 | #define BLYNK_INFO_CONNECTION "SIM7500" 75 | #elif defined(TINY_GSM_MODEM_SIM7600) 76 | #define BLYNK_INFO_CONNECTION "SIM7600" 77 | #elif defined(TINY_GSM_MODEM_SIM7800) 78 | #define BLYNK_INFO_CONNECTION "SIM7800" 79 | #elif defined(TINY_GSM_MODEM_UBLOX) 80 | #define BLYNK_INFO_CONNECTION "UBLOX" 81 | #elif defined(TINY_GSM_MODEM_SARAR4) 82 | #define BLYNK_INFO_CONNECTION "SARAR4" 83 | #elif defined(TINY_GSM_MODEM_M95) 84 | #define BLYNK_INFO_CONNECTION "M95" 85 | #elif defined(TINY_GSM_MODEM_BG96) 86 | #define BLYNK_INFO_CONNECTION "BG96" 87 | #elif defined(TINY_GSM_MODEM_A6) 88 | #define BLYNK_INFO_CONNECTION "A6" 89 | #elif defined(TINY_GSM_MODEM_A7) 90 | #define BLYNK_INFO_CONNECTION "A7" 91 | #elif defined(TINY_GSM_MODEM_M590) 92 | #define BLYNK_INFO_CONNECTION "M590" 93 | #elif defined(TINY_GSM_MODEM_MC60) 94 | #define BLYNK_INFO_CONNECTION "MC60" 95 | #elif defined(TINY_GSM_MODEM_MC60) 96 | #define BLYNK_INFO_CONNECTION "MC60" 97 | #elif defined(TINY_GSM_MODEM_MC60E) 98 | #define BLYNK_INFO_CONNECTION "MC60E" 99 | #elif defined(TINY_GSM_MODEM_XBEE) 100 | #define BLYNK_INFO_CONNECTION "XBEE" 101 | #elif defined(TINY_GSM_MODEM_SEQUANS_MONARCH) 102 | #define BLYNK_INFO_CONNECTION "SEQUANS_MONARCH" 103 | #else 104 | #define BLYNK_INFO_CONNECTION "TinyGSM" 105 | #endif 106 | #endif 107 | 108 | #ifndef BLYNK_HEARTBEAT 109 | #define BLYNK_HEARTBEAT 60 110 | #endif 111 | 112 | #ifndef BLYNK_TIMEOUT_MS 113 | #define BLYNK_TIMEOUT_MS 30000UL 114 | #endif 115 | 116 | #define BLYNK_SEND_ATOMIC 117 | 118 | #include 119 | #include 120 | #include 121 | #include 122 | 123 | class BlynkSIM 124 | : public BlynkProtocol 125 | { 126 | typedef BlynkProtocol Base; 127 | public: 128 | BlynkSIM(BlynkArduinoClient& transp) 129 | : Base(transp) 130 | , modem(NULL) 131 | {} 132 | 133 | bool connectNetwork(const char* apn, const char* user, const char* pass) 134 | { 135 | BLYNK_LOG1(BLYNK_F("InitModem")); 136 | if (!modem->begin()) 137 | { 138 | BLYNK_LOG1(BLYNK_F("failed")); 139 | return false; 140 | } 141 | 142 | switch (modem->getSimStatus()) 143 | { 144 | case SIM_ERROR: 145 | BLYNK_LOG1(BLYNK_F("NoSIM")); 146 | return false; 147 | case SIM_LOCKED: 148 | BLYNK_LOG1(BLYNK_F("SIMPINLocked")); 149 | return false; 150 | default: 151 | break; 152 | } 153 | 154 | BLYNK_LOG1(BLYNK_F("Con2Network")); 155 | if (modem->waitForNetwork()) 156 | { 157 | BLYNK_LOG2(BLYNK_F("Network:"), modem->getOperator()); 158 | } 159 | else 160 | { 161 | BLYNK_LOG1(BLYNK_F("NetworkRegisterFailed")); 162 | return false; 163 | } 164 | 165 | BLYNK_LOG2(BLYNK_F("Conn2 "), apn); 166 | if (!modem->gprsConnect(apn, user, pass)) 167 | { 168 | BLYNK_LOG1(BLYNK_F("GPRSConFailed")); 169 | return false; 170 | } 171 | 172 | BLYNK_LOG1(BLYNK_F("GPRSConOK")); 173 | return true; 174 | } 175 | 176 | void config(TinyGsm& gsm, 177 | const char* auth, 178 | const char* domain = BLYNK_DEFAULT_DOMAIN, 179 | uint16_t port = BLYNK_DEFAULT_PORT) 180 | { 181 | Base::begin(auth); 182 | modem = &gsm; 183 | client.init(modem); 184 | this->conn.setClient(&client); 185 | this->conn.begin(domain, port); 186 | } 187 | 188 | void begin(const char* auth, 189 | TinyGsm& gsm, 190 | const char* apn, 191 | const char* user, 192 | const char* pass, 193 | const char* domain = BLYNK_DEFAULT_DOMAIN, 194 | uint16_t port = BLYNK_DEFAULT_PORT) 195 | { 196 | config(gsm, auth, domain, port); 197 | connectNetwork(apn, user, pass); 198 | while (this->connect() != true) {} 199 | } 200 | 201 | 202 | private: 203 | TinyGsm* modem; 204 | TinyGsmClient client; 205 | 206 | }; 207 | 208 | #endif 209 | -------------------------------------------------------------------------------- /src/BlynkSimpleEsp32_GSM_WF.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | BlynkSimpleESP32_GSM_WF.h 3 | For ESP32 with GSM/GPRS and WiFi running simultaneously, with WiFi config portal 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | 10 | Original Blynk Library author: 11 | @file BlynkSimpleESP8266.h 12 | @author Volodymyr Shymanskyy 13 | @license This project is released under the MIT License (MIT) 14 | @copyright Copyright (c) 2015 Volodymyr Shymanskyy 15 | @date Oct 2016 16 | @brief 17 | 18 | Version: 1.2.1 19 | 20 | Version Modified By Date Comments 21 | ------- ----------- ---------- ----------- 22 | 1.0.0 K Hoang 17/01/2020 Initial coding. Add config portal similar to Blynk_WM library. 23 | 1.0.1 K Hoang 27/01/2020 Change Synch XMLHttpRequest to Async (https://xhr.spec.whatwg.org/). Reduce code size 24 | 1.0.2 K Hoang 08/02/2020 Enable GSM/GPRS and WiFi running simultaneously 25 | 1.0.3 K Hoang 18/02/2020 Add checksum. Add clearConfigData() 26 | 1.0.4 K Hoang 14/03/2020 Enhance Config Portal GUI. Reduce code size. 27 | 1.0.5 K Hoang 20/03/2020 Add more modem supports. See the list in README.md 28 | 1.0.6 K Hoang 07/04/2020 Enable adding dynamic custom parameters from sketch 29 | 1.0.7 K Hoang 09/04/2020 SSID password maxlen is 63 now. Permit special chars # and % in input data. 30 | 1.0.8 K Hoang 14/04/2020 Fix bug. 31 | 1.0.9 K Hoang 31/05/2020 Update to use LittleFS for ESP8266 core 2.7.1+. Add Configurable Config Portal Title, 32 | Default Config Data and DRD. Add MultiWiFi/Blynk features for WiFi and GPRS/GSM 33 | 1.0.10 K Hoang 26/08/2020 Use MultiWiFi. Auto format SPIFFS/LittleFS for first time usage. 34 | Fix bug and logic of USE_DEFAULT_CONFIG_DATA. 35 | 1.1.0 K Hoang 01/01/2021 Add support to ESP32 LittleFS. Remove possible compiler warnings. Update examples. Add MRD 36 | 1.2.0 K Hoang 01/02/2021 Add functions to control Config Portal (CP) from software or Virtual Switches 37 | Fix CP and Dynamic Params bugs. To permit autoreset after timeout if DRD/MRD or forced CP 38 | 1.2.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json` 39 | *****************************************************************************************************************************/ 40 | 41 | #pragma once 42 | 43 | #ifndef BlynkSimpleEsp32_GSM_WF_h 44 | #define BlynkSimpleEsp32_GSM_WF_h 45 | 46 | #ifndef ESP32 47 | #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting. 48 | #endif 49 | 50 | #define BLYNK_GSM_MANAGER_VERSION "BlynkGSM_Manager v1.2.1" 51 | 52 | #define BLYNK_SEND_ATOMIC 53 | 54 | // KH 55 | #define BLYNK_TIMEOUT_MS 30000UL 56 | 57 | #include 58 | #include 59 | #include 60 | #include 61 | 62 | class BlynkWifi 63 | : public BlynkProtocol 64 | { 65 | typedef BlynkProtocol Base; 66 | public: 67 | BlynkWifi(BlynkArduinoClient& transp) 68 | : Base(transp) 69 | {} 70 | 71 | void connectWiFi(const char* ssid, const char* pass) 72 | { 73 | BLYNK_LOG2(BLYNK_F("Con2:"), ssid); 74 | WiFi.mode(WIFI_STA); 75 | if (pass && strlen(pass)) { 76 | WiFi.begin(ssid, pass); 77 | } else { 78 | WiFi.begin(ssid); 79 | } 80 | while (WiFi.status() != WL_CONNECTED) { 81 | BlynkDelay(500); 82 | } 83 | BLYNK_LOG1(BLYNK_F("Conn2WiFi")); 84 | 85 | IPAddress myip = WiFi.localIP(); 86 | BLYNK_LOG_IP("IP:", myip); 87 | } 88 | 89 | void config(const char* auth, 90 | const char* domain = BLYNK_DEFAULT_DOMAIN, 91 | uint16_t port = BLYNK_DEFAULT_PORT) 92 | { 93 | Base::begin(auth); 94 | this->conn.begin(domain, port); 95 | } 96 | 97 | void config(const char* auth, 98 | IPAddress ip, 99 | uint16_t port = BLYNK_DEFAULT_PORT) 100 | { 101 | Base::begin(auth); 102 | this->conn.begin(ip, port); 103 | } 104 | 105 | void begin(const char* auth, 106 | const char* ssid, 107 | const char* pass, 108 | const char* domain = BLYNK_DEFAULT_DOMAIN, 109 | uint16_t port = BLYNK_DEFAULT_PORT) 110 | { 111 | connectWiFi(ssid, pass); 112 | config(auth, domain, port); 113 | while (this->connect() != true) {} 114 | } 115 | 116 | void begin(const char* auth, 117 | const char* ssid, 118 | const char* pass, 119 | IPAddress ip, 120 | uint16_t port = BLYNK_DEFAULT_PORT) 121 | { 122 | connectWiFi(ssid, pass); 123 | config(auth, ip, port); 124 | while (this->connect() != true) {} 125 | } 126 | 127 | }; 128 | 129 | static WiFiClient _blynkWifiClient; 130 | 131 | // KH 132 | static BlynkArduinoClient _blynkTransport_WF(_blynkWifiClient); 133 | BlynkWifi Blynk_WF(_blynkTransport_WF); 134 | 135 | #if defined(Blynk) 136 | #undef Blynk 137 | #define Blynk Blynk_WF 138 | #endif 139 | // 140 | 141 | #include 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /src/BlynkSimpleEsp8266_GSM_WF.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | BlynkSimpleESP8266_GSM_WF.h 3 | For ESP8266 with GSM/GPRS and WiFi running simultaneously, with WiFi config portal 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | 10 | Original Blynk Library author: 11 | @file BlynkSimpleESP8266.h 12 | @author Volodymyr Shymanskyy 13 | @license This project is released under the MIT License (MIT) 14 | @copyright Copyright (c) 2015 Volodymyr Shymanskyy 15 | @date Oct 2016 16 | @brief 17 | 18 | Version: 1.2.1 19 | 20 | Version Modified By Date Comments 21 | ------- ----------- ---------- ----------- 22 | 1.0.0 K Hoang 17/01/2020 Initial coding. Add config portal similar to Blynk_WM library. 23 | 1.0.1 K Hoang 27/01/2020 Change Synch XMLHttpRequest to Async (https://xhr.spec.whatwg.org/). Reduce code size 24 | 1.0.2 K Hoang 08/02/2020 Enable GSM/GPRS and WiFi running simultaneously 25 | 1.0.3 K Hoang 18/02/2020 Add checksum. Add clearConfigData() 26 | 1.0.4 K Hoang 14/03/2020 Enhance Config Portal GUI. Reduce code size. 27 | 1.0.5 K Hoang 20/03/2020 Add more modem supports. See the list in README.md 28 | 1.0.6 K Hoang 07/04/2020 Enable adding dynamic custom parameters from sketch 29 | 1.0.7 K Hoang 09/04/2020 SSID password maxlen is 63 now. Permit special chars # and % in input data. 30 | 1.0.8 K Hoang 14/04/2020 Fix bug. 31 | 1.0.9 K Hoang 31/05/2020 Update to use LittleFS for ESP8266 core 2.7.1+. Add Configurable Config Portal Title, 32 | Default Config Data and DRD. Add MultiWiFi/Blynk features for WiFi and GPRS/GSM 33 | 1.0.10 K Hoang 26/08/2020 Use MultiWiFi. Auto format SPIFFS/LittleFS for first time usage. 34 | Fix bug and logic of USE_DEFAULT_CONFIG_DATA. 35 | 1.1.0 K Hoang 01/01/2021 Add support to ESP32 LittleFS. Remove possible compiler warnings. Update examples. Add MRD 36 | 1.2.0 K Hoang 01/02/2021 Add functions to control Config Portal (CP) from software or Virtual Switches 37 | Fix CP and Dynamic Params bugs. To permit autoreset after timeout if DRD/MRD or forced CP 38 | 1.2.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json` 39 | *****************************************************************************************************************************/ 40 | 41 | #pragma once 42 | 43 | #ifndef BlynkSimpleESP8266_GSM_WF 44 | #define BlynkSimpleESP8266_GSM_WF 45 | 46 | #ifndef ESP8266 47 | #error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting. 48 | #endif 49 | 50 | #define BLYNK_GSM_MANAGER_VERSION "BlynkGSM_Manager v1.2.1" 51 | 52 | #define BLYNK_SEND_ATOMIC 53 | 54 | // KH 55 | #define BLYNK_TIMEOUT_MS 30000UL 56 | 57 | #include 58 | 59 | #if ESP_SDK_VERSION_NUMBER < 0x020200 60 | #error Please update your ESP8266 Arduino Core 61 | #endif 62 | 63 | #include 64 | #include 65 | #include 66 | #include 67 | 68 | class BlynkWifi 69 | : public BlynkProtocol 70 | { 71 | typedef BlynkProtocol Base; 72 | public: 73 | BlynkWifi(BlynkArduinoClient& transp) 74 | : Base(transp) 75 | {} 76 | 77 | void connectWiFi(const char* ssid, const char* pass) 78 | { 79 | BLYNK_LOG2(BLYNK_F("Con2:"), ssid); 80 | WiFi.mode(WIFI_STA); 81 | if (WiFi.status() != WL_CONNECTED) { 82 | if (pass && strlen(pass)) { 83 | WiFi.begin(ssid, pass); 84 | } else { 85 | WiFi.begin(ssid); 86 | } 87 | } 88 | while (WiFi.status() != WL_CONNECTED) { 89 | BlynkDelay(500); 90 | } 91 | BLYNK_LOG1(BLYNK_F("Conn2WiFi")); 92 | 93 | IPAddress myip = WiFi.localIP(); 94 | BLYNK_LOG_IP("IP:", myip); 95 | } 96 | 97 | void config(const char* auth, 98 | const char* domain = BLYNK_DEFAULT_DOMAIN, 99 | uint16_t port = BLYNK_DEFAULT_PORT) 100 | { 101 | Base::begin(auth); 102 | this->conn.begin(domain, port); 103 | } 104 | 105 | void config(const char* auth, 106 | IPAddress ip, 107 | uint16_t port = BLYNK_DEFAULT_PORT) 108 | { 109 | Base::begin(auth); 110 | this->conn.begin(ip, port); 111 | } 112 | 113 | void begin(const char* auth, 114 | const char* ssid, 115 | const char* pass, 116 | const char* domain = BLYNK_DEFAULT_DOMAIN, 117 | uint16_t port = BLYNK_DEFAULT_PORT) 118 | { 119 | connectWiFi(ssid, pass); 120 | config(auth, domain, port); 121 | while (this->connect() != true) {} 122 | } 123 | 124 | void begin(const char* auth, 125 | const char* ssid, 126 | const char* pass, 127 | IPAddress ip, 128 | uint16_t port = BLYNK_DEFAULT_PORT) 129 | { 130 | connectWiFi(ssid, pass); 131 | config(auth, ip, port); 132 | while (this->connect() != true) {} 133 | } 134 | 135 | }; 136 | 137 | static WiFiClient _blynkWifiClient; 138 | 139 | // KH 140 | static BlynkArduinoClient _blynkTransport_WF(_blynkWifiClient); 141 | BlynkWifi Blynk_WF(_blynkTransport_WF); 142 | 143 | #if defined(Blynk) 144 | #undef Blynk 145 | #define Blynk Blynk_WF 146 | #endif 147 | // 148 | 149 | #include 150 | 151 | #endif 152 | -------------------------------------------------------------------------------- /src/BlynkSimpleTinyGSM_M.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | BlynkSimpleTinyGSM_M.h 3 | For ESP32 / ESP8266 with GSM/GPRS and WiFi running simultaneously, with WiFi config portal 4 | 5 | Library to enable GSM/GPRS and WiFi running simultaneously , with WiFi config portal. 6 | Based on and modified from Blynk library v0.6.1 https://github.com/blynkkk/blynk-library/releases 7 | Built by Khoi Hoang https://github.com/khoih-prog/BlynkGSM_Manager 8 | Licensed under MIT license 9 | 10 | Original Blynk Library author: 11 | @file BlynkSimpleESP8266.h 12 | @author Volodymyr Shymanskyy 13 | @license This project is released under the MIT License (MIT) 14 | @copyright Copyright (c) 2015 Volodymyr Shymanskyy 15 | @date Oct 2016 16 | @brief 17 | 18 | Version: 1.2.1 19 | 20 | Version Modified By Date Comments 21 | ------- ----------- ---------- ----------- 22 | 1.0.0 K Hoang 17/01/2020 Initial coding. Add config portal similar to Blynk_WM library. 23 | 1.0.1 K Hoang 27/01/2020 Change Synch XMLHttpRequest to Async (https://xhr.spec.whatwg.org/). Reduce code size 24 | 1.0.2 K Hoang 08/02/2020 Enable GSM/GPRS and WiFi running simultaneously 25 | 1.0.3 K Hoang 18/02/2020 Add checksum. Add clearConfigData() 26 | 1.0.4 K Hoang 14/03/2020 Enhance Config Portal GUI. Reduce code size. 27 | 1.0.5 K Hoang 20/03/2020 Add more modem supports. See the list in README.md 28 | 1.0.6 K Hoang 07/04/2020 Enable adding dynamic custom parameters from sketch 29 | 1.0.7 K Hoang 09/04/2020 SSID password maxlen is 63 now. Permit special chars # and % in input data. 30 | 1.0.8 K Hoang 14/04/2020 Fix bug. 31 | 1.0.9 K Hoang 31/05/2020 Update to use LittleFS for ESP8266 core 2.7.1+. Add Configurable Config Portal Title, 32 | Default Config Data and DRD. Add MultiWiFi/Blynk features for WiFi and GPRS/GSM 33 | 1.0.10 K Hoang 26/08/2020 Use MultiWiFi. Auto format SPIFFS/LittleFS for first time usage. 34 | Fix bug and logic of USE_DEFAULT_CONFIG_DATA. 35 | 1.1.0 K Hoang 01/01/2021 Add support to ESP32 LittleFS. Remove possible compiler warnings. Update examples. Add MRD 36 | 1.2.0 K Hoang 01/02/2021 Add functions to control Config Portal (CP) from software or Virtual Switches 37 | Fix CP and Dynamic Params bugs. To permit autoreset after timeout if DRD/MRD or forced CP 38 | 1.2.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json` 39 | *****************************************************************************************************************************/ 40 | 41 | #pragma once 42 | 43 | #ifndef BlynkSimpleTinyGSM_M_h 44 | #define BlynkSimpleTinyGSM_M_h 45 | 46 | #define BLYNK_GSM_MANAGER_VERSION "BlynkGSM_Manager v1.2.1" 47 | 48 | 49 | #if defined(ESP32) 50 | #include 51 | #elif defined(ESP8266) 52 | #include 53 | #else 54 | #error This code is intended to run on the ESP32 or ESP8266 platform! Please check your Tools->Board setting. 55 | #endif 56 | 57 | static BlynkArduinoClient _blynkTransport; 58 | 59 | BlynkSIM Blynk_GSM(_blynkTransport); 60 | 61 | #define Blynk Blynk_GSM 62 | 63 | #include 64 | 65 | #endif 66 | --------------------------------------------------------------------------------