Guest User

EGizmo GSM Shield - Send SMS Test(With Codes and Guides)

a guest
Oct 15th, 2017
1,173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1.  
  2. //GSM Shield for Arduino
  3. //www.open-electronics.org
  4. //this code is based on the example of Arduino Labs.
  5.  
  6. //Simple sketch to send and receive SMS.
  7.  
  8. #include "SIM900.h"
  9. #include <SoftwareSerial.h>
  10.  
  11. #include "sms.h"
  12. SMSGSM sms;
  13.  
  14. int numdata;
  15. boolean started=false;
  16. char smsbuffer[160];
  17. char n[20];
  18.  
  19. void setup()
  20. {
  21.   //Serial connection.
  22.   Serial.begin(9600);
  23.   Serial.println("GSM Shield testing.");
  24.   if (gsm.begin(2400)){
  25.     Serial.println("\nstatus=READY");
  26.     started=true;  
  27.   }
  28.   else Serial.println("\nstatus=IDLE");
  29.  
  30.   if(started){
  31.         //SET THE RECEIVER'S PHONE NUMBER AND THE MESSAGE, (replace the 0 in the first digit with your country code,In my case I use +63 because I'm in the Philippines).
  32.     if (sms.SendSMS("+639474153195", "TEXT MESSAGE HERE"))
  33.       Serial.println("\nSMS sent OK");
  34.   }
  35.  
  36. };
  37.  
  38. void loop()
  39. {
  40.   if(started){
  41.     //Read if there are messages on SIM card and print them.
  42.     if(gsm.readSMS(smsbuffer, 160, n, 20))
  43.     {
  44.       Serial.println(n);
  45.       Serial.println(smsbuffer);
  46.     }
  47.     delay(1000);
  48.   }
  49. };
Advertisement
Add Comment
Please, Sign In to add comment