You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.2 KiB

6 years ago
8 years ago
5 years ago
6 years ago
6 years ago
8 years ago
8 years ago
8 years ago
  1. /**************************************************************
  2. *
  3. * For this example, you need to install Blynk library:
  4. * https://github.com/blynkkk/blynk-library/releases/latest
  5. *
  6. * TinyGSM Getting Started guide:
  7. * https://tiny.cc/tinygsm-readme
  8. *
  9. **************************************************************
  10. *
  11. * Blynk is a platform with iOS and Android apps to control
  12. * Arduino, Raspberry Pi and the likes over the Internet.
  13. * You can easily build graphic interfaces for all your
  14. * projects by simply dragging and dropping widgets.
  15. *
  16. * Blynk supports many development boards with WiFi, Ethernet,
  17. * GSM, Bluetooth, BLE, USB/Serial connection methods.
  18. * See more in Blynk library examples and community forum.
  19. *
  20. * http://www.blynk.io/
  21. *
  22. * Change GPRS apm, user, pass, and Blynk auth token to run :)
  23. **************************************************************/
  24. /* Fill in information from Blynk Device Info here */
  25. #define BLYNK_TEMPLATE_ID "TMPxxxxxx"
  26. #define BLYNK_TEMPLATE_NAME "Device"
  27. #define BLYNK_AUTH_TOKEN "YourAuthToken"
  28. #define BLYNK_PRINT Serial // Comment this out to disable prints and save space
  29. // Default heartbeat interval for GSM is 60
  30. // If you want override this value, uncomment and set this option:
  31. // #define BLYNK_HEARTBEAT 30
  32. // Select your modem:
  33. #define TINY_GSM_MODEM_SIM800
  34. // #define TINY_GSM_MODEM_SIM808
  35. // #define TINY_GSM_MODEM_SIM868
  36. // #define TINY_GSM_MODEM_SIM900
  37. // #define TINY_GSM_MODEM_SIM7000
  38. // #define TINY_GSM_MODEM_SIM7000SSL
  39. // #define TINY_GSM_MODEM_SIM7080
  40. // #define TINY_GSM_MODEM_SIM5360
  41. // #define TINY_GSM_MODEM_SIM7600
  42. // #define TINY_GSM_MODEM_UBLOX
  43. // #define TINY_GSM_MODEM_SARAR4
  44. // #define TINY_GSM_MODEM_M95
  45. // #define TINY_GSM_MODEM_BG96
  46. // #define TINY_GSM_MODEM_A6
  47. // #define TINY_GSM_MODEM_A7
  48. // #define TINY_GSM_MODEM_M590
  49. // #define TINY_GSM_MODEM_MC60
  50. // #define TINY_GSM_MODEM_MC60E
  51. // #define TINY_GSM_MODEM_ESP8266
  52. // #define TINY_GSM_MODEM_XBEE
  53. // #define TINY_GSM_MODEM_SEQUANS_MONARCH
  54. #include <TinyGsmClient.h>
  55. #include <BlynkSimpleTinyGSM.h>
  56. // Set serial for debug console (to the Serial Monitor, default speed 115200)
  57. #define SerialMon Serial
  58. // Hardware Serial on Mega, Leonardo, Micro
  59. #ifndef __AVR_ATmega328P__
  60. #define SerialAT Serial1
  61. // or Software Serial on Uno, Nano
  62. #else
  63. #include <SoftwareSerial.h>
  64. SoftwareSerial SerialAT(2, 3); // RX, TX
  65. #endif
  66. // Your GPRS credentials, if any
  67. const char apn[] = "YourAPN";
  68. const char user[] = "";
  69. const char pass[] = "";
  70. // You should get Auth Token in the Blynk App.
  71. // Go to the Project Settings (nut icon).
  72. const char auth[] = "YourAuthToken";
  73. TinyGsm modem(SerialAT);
  74. void setup()
  75. {
  76. // Set console baud rate
  77. SerialMon.begin(115200);
  78. delay(10);
  79. // Set GSM module baud rate
  80. SerialAT.begin(115200);
  81. delay(6000);
  82. // Restart takes quite some time
  83. // To skip it, call init() instead of restart()
  84. SerialMon.println("Initializing modem...");
  85. modem.restart();
  86. String modemInfo = modem.getModemInfo();
  87. SerialMon.print("Modem Info: ");
  88. SerialMon.println(modemInfo);
  89. // Unlock your SIM card with a PIN
  90. //modem.simUnlock("1234");
  91. Blynk.begin(auth, modem, apn, user, pass);
  92. }
  93. void loop()
  94. {
  95. Blynk.run();
  96. }