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.

110 lines
3.0 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. #define BLYNK_PRINT Serial // Comment this out to disable prints and save space
  25. // Default heartbeat interval for GSM is 60
  26. // If you want override this value, uncomment and set this option:
  27. // #define BLYNK_HEARTBEAT 30
  28. // Select your modem:
  29. #define TINY_GSM_MODEM_SIM800
  30. // #define TINY_GSM_MODEM_SIM808
  31. // #define TINY_GSM_MODEM_SIM868
  32. // #define TINY_GSM_MODEM_SIM900
  33. // #define TINY_GSM_MODEM_SIM7000
  34. // #define TINY_GSM_MODEM_SIM7000SSL
  35. // #define TINY_GSM_MODEM_SIM7080
  36. // #define TINY_GSM_MODEM_SIM5360
  37. // #define TINY_GSM_MODEM_SIM7600
  38. // #define TINY_GSM_MODEM_UBLOX
  39. // #define TINY_GSM_MODEM_SARAR4
  40. // #define TINY_GSM_MODEM_M95
  41. // #define TINY_GSM_MODEM_BG96
  42. // #define TINY_GSM_MODEM_A6
  43. // #define TINY_GSM_MODEM_A7
  44. // #define TINY_GSM_MODEM_M590
  45. // #define TINY_GSM_MODEM_MC60
  46. // #define TINY_GSM_MODEM_MC60E
  47. // #define TINY_GSM_MODEM_ESP8266
  48. // #define TINY_GSM_MODEM_XBEE
  49. // #define TINY_GSM_MODEM_SEQUANS_MONARCH
  50. #include <TinyGsmClient.h>
  51. #include <BlynkSimpleTinyGSM.h>
  52. // Set serial for debug console (to the Serial Monitor, default speed 115200)
  53. #define SerialMon Serial
  54. // Hardware Serial on Mega, Leonardo, Micro
  55. #ifndef __AVR_ATmega328P__
  56. #define SerialAT Serial1
  57. // or Software Serial on Uno, Nano
  58. #else
  59. #include <SoftwareSerial.h>
  60. SoftwareSerial SerialAT(2, 3); // RX, TX
  61. #endif
  62. // Your GPRS credentials, if any
  63. const char apn[] = "YourAPN";
  64. const char user[] = "";
  65. const char pass[] = "";
  66. // You should get Auth Token in the Blynk App.
  67. // Go to the Project Settings (nut icon).
  68. const char auth[] = "YourAuthToken";
  69. TinyGsm modem(SerialAT);
  70. void setup()
  71. {
  72. // Set console baud rate
  73. SerialMon.begin(115200);
  74. delay(10);
  75. // Set GSM module baud rate
  76. SerialAT.begin(115200);
  77. delay(6000);
  78. // Restart takes quite some time
  79. // To skip it, call init() instead of restart()
  80. SerialMon.println("Initializing modem...");
  81. modem.restart();
  82. String modemInfo = modem.getModemInfo();
  83. SerialMon.print("Modem Info: ");
  84. SerialMon.println(modemInfo);
  85. // Unlock your SIM card with a PIN
  86. //modem.simUnlock("1234");
  87. Blynk.begin(auth, modem, apn, user, pass);
  88. }
  89. void loop()
  90. {
  91. Blynk.run();
  92. }