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.

96 lines
2.5 KiB

8 years ago
8 years ago
8 years ago
8 years ago
7 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. * http://tiny.cc/tiny-gsm-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_SIM900
  32. // #define TINY_GSM_MODEM_A6
  33. // #define TINY_GSM_MODEM_A7
  34. // #define TINY_GSM_MODEM_M590
  35. // #define TINY_GSM_MODEM_ESP8266
  36. // #define TINY_GSM_MODEM_XBEE
  37. #include <TinyGsmClient.h>
  38. #include <BlynkSimpleSIM800.h>
  39. // Set serial for debug console (to the Serial Monitor, default speed 115200)
  40. #define SerialMon Serial
  41. // Hardware Serial on Mega, Leonardo, Micro
  42. #define SerialAT Serial1
  43. // or Software Serial on Uno, Nano
  44. //#include <SoftwareSerial.h>
  45. //SoftwareSerial SerialAT(2, 3); // RX, TX
  46. // Your GPRS credentials
  47. // Leave empty, if missing user or pass
  48. const char apn[] = "YourAPN";
  49. const char user[] = "";
  50. const char pass[] = "";
  51. // You should get Auth Token in the Blynk App.
  52. // Go to the Project Settings (nut icon).
  53. const char auth[] = "YourAuthToken";
  54. TinyGsm modem(SerialAT);
  55. void setup()
  56. {
  57. // Set console baud rate
  58. SerialMon.begin(115200);
  59. delay(10);
  60. // Set GSM module baud rate
  61. SerialAT.begin(115200);
  62. delay(3000);
  63. // Restart takes quite some time
  64. // To skip it, call init() instead of restart()
  65. SerialMon.println("Initializing modem...");
  66. modem.restart();
  67. String modemInfo = modem.getModemInfo();
  68. SerialMon.print("Modem: ");
  69. SerialMon.println(modemInfo);
  70. // Unlock your SIM card with a PIN
  71. //modem.simUnlock("1234");
  72. Blynk.begin(auth, modem, apn, user, pass);
  73. }
  74. void loop()
  75. {
  76. Blynk.run();
  77. }