safwan092

Send Arabic SMS using SIM900A

Feb 6th, 2020
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Send Arabic SMS using SIM900A
  2.  
  3. #include <SoftwareSerial.h>
  4. SoftwareSerial SIM900A(10, 11);
  5. void setup()
  6. {
  7.   pinMode(buz, OUTPUT);
  8.   pinMode(gnd, OUTPUT);
  9.   digitalWrite(gnd, LOW);
  10.  
  11.   SIM900A.begin(9600);   // Setting the baud rate of GSM Module
  12.   Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  13.   Serial.println ("SIM900A Ready");
  14.   delay(100);
  15.   Serial.println ("Type s to send message or r to receive message");
  16. }
  17. void loop()
  18. {
  19.  
  20.   if (Serial.available() > 0)
  21.     switch (Serial.read())
  22.     {
  23.       case 's':
  24.         SendMessageArabic();
  25.         break;
  26.       case 'r':
  27.         //      RecieveMessage();
  28.         break;
  29.     }
  30.   if (SIM900A.available() > 0)
  31.     Serial.write(SIM900A.read());
  32.  
  33. }
  34.  
  35.  
  36. void SendMessageArabic()
  37. {
  38.   Serial.println ("Sending Message");
  39.   SIM900A.println("AT+CSCS=\"HEX\"\r");
  40.   delay(1000);
  41.   SIM900A.println("AT+CSMP=17,167,0,8\r");
  42.   delay(1000);
  43.   SIM900A.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  44.   delay(1000);
  45.   Serial.println ("Set SMS Number");
  46.   // https://www.branah.com/unicode-converter
  47.   // for phone number convert to (UTF-8) and (Remove \x)
  48.   SIM900A.println("AT+CMGS=\"2b393636353534383733343631\""); //Mobile phone number to send message +966554873461  //2b393636353534383733343631
  49.   delay(1000);
  50.   Serial.println ("Set SMS Content");
  51.   // for message convert to (UTF-16) and (Remove \u)
  52.   SIM900A.println("06450631062d0628062700200643064a064106430020");// Messsage content
  53.   delay(100);
  54.   Serial.println ("Finish");
  55.   SIM900A.println("\x1A");// ASCII code of CTRL+Z
  56.   delay(1000);
  57.   Serial.println ("Message has been sent ->SMS Selesai dikirim");
  58. }
RAW Paste Data