Old Mobile Phone GSM Sim900 - Sending Message

Ok. Now we will send a message using this setup.

Software Part, I believe you already have arduino IDE installed in your computer. You may download the full code first before we proceed further. I will not go through each line with you. You may ask me on the comment section on which part you need more explanation.

Full code: tutorial2_sendingMessage.zip

Extract the file and open the program.

1) This is the part where we define the library that we use . SoftwareSerial, string and liquidCrystal library is pre-built in the softaware when you installed the arduino IDE . Only keypad library you need to download and install it in arduino libraries folder.

You may notice that i ended up not using the GSM library : D Im more excited to use to direct communication to the GSM using AT-Cammand in the first place . So we will not use any GSM library in this tutoraial or in the next tutorial . The AT Command file can be downloaded in Old Mobile Phone GSM Sim900 - Preparing Arduino Library.

-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
2) Remember that in Old Mobile Phone GSM Sim900 - Wiring, we already have a pin diagram for arduino uno . At this part of code is where we declare all the pin use by keypad , lcd and gsm shield .

-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


3) At this part is where we setup our communication module between arduino and GSM , bettween arduino and computer for debug purpose . Arduino will communicate with GSM using software serial with baudrate of 19200 while arduino will communicate with computer using hardware serial with baudrate of 9600 . Hardware serial is fixed on pin 0 and 1 on arduino .

-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------

4) This part will automatically turn ON the GSM shield . If it already turn ON , it will turn it OFF and turn it ON again .

-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------



5) displayHome( ) function is to display the home on the LCD . We need to make it as function because we may need to call it a couple of time in other line of code .

-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------






6) This line is where arduino read what is pressed on the keypad . Then the data will be store in the keypressed variable .

-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


7) If keypad is not pressed when this line is executed, keypressed will be store with NO_KEY .

-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


8) If keypad is pressed , keypressed will store one of the following character .

-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------



9) displaySelection( ) function used to control the selection arrow .

-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------


10) So, this is actually the core part to send a message. Code above represent the AT Command that we need to use in order to sent message. This AT Command is sent and receive through software serial which is pin 7 and 8 of arduino.

-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------

11) In conclusion, we will summarize what AT Command that you need to sent sms using software serial command each in one line.

  //To send text message in text mode
  gsmSerial.println("AT+CMGF=1");
  delay(100);

  //Phone number of the person receive
  gsmSerial.print("AT + CMGS = \"+60194339489\"");
  delay(100);

  //Message that you want to sent
  gsmSerial.println("Hi, are you there?");
  delay(100);

  //Terminator
  gsmSerial.println((char)26);
  delay(100);


-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------



Done. Feel free to comment if you see any major fault or anything you did not understand or anything that you want me to edit or add up something. Just comment it below. See you soon on next tutorial. Done for sent message : D Hopefully we can start to read a text message in next tutorial : D



No comments:

Post a Comment