mirror of
https://github.com/Xinyuan-LilyGO/LilyGo-T-Call-SIM800.git
synced 2026-07-27 19:56:23 +00:00
118 lines
3.1 KiB
Arduino
118 lines
3.1 KiB
Arduino
/**************************************************************
|
|
*
|
|
* For this example, you need to install Blynk library:
|
|
* https://github.com/blynkkk/blynk-library/releases/latest
|
|
*
|
|
* TinyGSM Getting Started guide:
|
|
* https://tiny.cc/tinygsm-readme
|
|
*
|
|
**************************************************************
|
|
*
|
|
* Blynk is a platform with iOS and Android apps to control
|
|
* Arduino, Raspberry Pi and the likes over the Internet.
|
|
* You can easily build graphic interfaces for all your
|
|
* projects by simply dragging and dropping widgets.
|
|
*
|
|
* Blynk supports many development boards with WiFi, Ethernet,
|
|
* GSM, Bluetooth, BLE, USB/Serial connection methods.
|
|
* See more in Blynk library examples and community forum.
|
|
*
|
|
* http://www.blynk.io/
|
|
*
|
|
* Change GPRS apm, user, pass, and Blynk auth token to run :)
|
|
**************************************************************/
|
|
|
|
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
|
|
|
|
// Default heartbeat interval for GSM is 60
|
|
// If you want override this value, uncomment and set this option:
|
|
// #define BLYNK_HEARTBEAT 30
|
|
|
|
// Please select the corresponding model
|
|
|
|
// #define SIM800L_IP5306_VERSION_20190610
|
|
// #define SIM800L_AXP192_VERSION_20200327
|
|
// #define SIM800C_AXP192_VERSION_20200609
|
|
// #define SIM800L_IP5306_VERSION_20200811
|
|
|
|
#include "utilities.h"
|
|
|
|
// Select your modem:
|
|
#define TINY_GSM_MODEM_SIM800
|
|
|
|
// Set serial for debug console (to the Serial Monitor, default speed 115200)
|
|
#define SerialMon Serial
|
|
|
|
// Set serial for AT commands (to the module)
|
|
// Use Hardware Serial on Mega, Leonardo, Micro
|
|
#define SerialAT Serial1
|
|
|
|
// See all AT commands, if wanted
|
|
//#define DUMP_AT_COMMANDS
|
|
|
|
// Define the serial console for debug prints, if needed
|
|
#define TINY_GSM_DEBUG SerialMon
|
|
|
|
// set GSM PIN, if any
|
|
#define GSM_PIN ""
|
|
|
|
// Your GPRS credentials, if any
|
|
const char apn[] = "";
|
|
const char gprsUser[] = "";
|
|
const char gprsPass[] = "";
|
|
|
|
#include <TinyGsmClient.h>
|
|
#include <BlynkSimpleTinyGSM.h>
|
|
|
|
#ifdef DUMP_AT_COMMANDS
|
|
#include <StreamDebugger.h>
|
|
StreamDebugger debugger(SerialAT, SerialMon);
|
|
TinyGsm modem(debugger);
|
|
#else
|
|
TinyGsm modem(SerialAT);
|
|
#endif
|
|
TinyGsmClient client(modem);
|
|
|
|
|
|
// You should get Auth Token in the Blynk App.
|
|
// Go to the Project Settings (nut icon).
|
|
const char auth[] = "YourAuthToken";
|
|
|
|
void setup()
|
|
{
|
|
// Set console baud rate
|
|
SerialMon.begin(115200);
|
|
|
|
delay(10);
|
|
|
|
setupModem();
|
|
|
|
SerialMon.println("Wait...");
|
|
|
|
// Set GSM module baud rate and UART pins
|
|
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
|
|
|
|
delay(6000);
|
|
|
|
// Restart takes quite some time
|
|
// To skip it, call init() instead of restart()
|
|
SerialMon.println("Initializing modem...");
|
|
modem.restart();
|
|
// modem.init();
|
|
|
|
String modemInfo = modem.getModemInfo();
|
|
SerialMon.print("Modem Info: ");
|
|
SerialMon.println(modemInfo);
|
|
|
|
// Unlock your SIM card with a PIN
|
|
//modem.simUnlock("1234");
|
|
|
|
Blynk.begin(auth, modem, apn, gprsUser, gprsPass);
|
|
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
Blynk.run();
|
|
}
|