90 lines
2.4 KiB
C++
90 lines
2.4 KiB
C++
/*************************************************************
|
|
Blynk is a platform with iOS and Android apps to control
|
|
ESP32, Arduino, Raspberry Pi and the likes over the Internet.
|
|
You can easily build mobile and web interfaces for any
|
|
projects by simply dragging and dropping widgets.
|
|
|
|
Downloads, docs, tutorials: https://www.blynk.io
|
|
Sketch generator: https://examples.blynk.cc
|
|
Blynk community: https://community.blynk.cc
|
|
Follow us: https://www.fb.com/blynkapp
|
|
https://twitter.com/blynk_app
|
|
|
|
Blynk library is licensed under MIT license
|
|
This example code is in public domain.
|
|
|
|
*************************************************************
|
|
Attention! Please check out TinyGSM guide:
|
|
https://tiny.cc/tinygsm-readme
|
|
|
|
Change GPRS apm, user, pass, and Blynk auth token to run :)
|
|
Feel free to apply it to any other example. It's simple!
|
|
|
|
*************************************************************/
|
|
|
|
/* Comment this out to disable prints and save space */
|
|
#define BLYNK_PRINT Serial
|
|
|
|
/* Fill in information from Blynk Device Info here */
|
|
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
|
|
//#define BLYNK_TEMPLATE_NAME "Device"
|
|
//#define BLYNK_AUTH_TOKEN "YourAuthToken"
|
|
|
|
|
|
// Arduino MKR GSM 1400 uses U-blox modem
|
|
#define TINY_GSM_MODEM_UBLOX
|
|
|
|
// Default heartbeat interval for GSM is 60
|
|
// If you want override this value, uncomment and set this option:
|
|
//#define BLYNK_HEARTBEAT 30
|
|
|
|
#include <TinyGsmClient.h>
|
|
#include <BlynkSimpleTinyGSM.h>
|
|
|
|
// Your GPRS credentials
|
|
// Leave empty, if missing user or pass
|
|
char apn[] = "YourAPN";
|
|
char user[] = "";
|
|
char pass[] = "";
|
|
|
|
TinyGsm modem(SerialGSM);
|
|
|
|
void setup()
|
|
{
|
|
// Debug console
|
|
Serial.begin(9600);
|
|
|
|
delay(10);
|
|
|
|
// Set GSM module baud rate
|
|
SerialGSM.begin(115200);
|
|
|
|
pinMode(GSM_DTR, OUTPUT);
|
|
digitalWrite(GSM_DTR, LOW);
|
|
delay(5);
|
|
|
|
// Turn on the GSM module by triggering GSM_RESETN pin
|
|
pinMode(GSM_RESETN, OUTPUT);
|
|
digitalWrite(GSM_RESETN, HIGH);
|
|
delay(100);
|
|
digitalWrite(GSM_RESETN, LOW);
|
|
|
|
delay(1000);
|
|
|
|
// Restart takes quite some time
|
|
// To skip it, call init() instead of restart()
|
|
Serial.println("Initializing modem...");
|
|
modem.restart();
|
|
|
|
// Unlock your SIM card with a PIN
|
|
//modem.simUnlock("1234");
|
|
|
|
Blynk.begin(BLYNK_AUTH_TOKEN, modem, apn, user, pass);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
Blynk.run();
|
|
}
|
|
|