2
votes

My Connections are
5VT to D9
5VR to D10
And external adaptor for power.. (5v 2A)

The blinks are good because it blinks every 3seconds,
The sim card is loaded.
But when I run the serial monitor, It only shows AT AT AT sometimes AT with reverse question marks..

Here is the Code I am using..

#include <SoftwareSerial.h>

SoftwareSerial mySerial(9, 10);

void setup()
{
  mySerial.begin(9600);   // Setting the baud rate of GSM Module  
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
}


void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
      SendMessage();
      break;
    case 'r':
      RecieveMessage();
      break;
  }

 if (mySerial.available()>0)
   Serial.write(mySerial.read());
}


 void SendMessage()
{
  mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  mySerial.println("AT+CMGS=\"+639176344625\"\r"); // Replace x with mobile number
  delay(1000);
  mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
  delay(100);
   mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
}


 void RecieveMessage()
{
  mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  delay(1000);
 }
 

This is the Sim900A I am using together with Arduino Uno.. enter image description here

1

1 Answers

0
votes

Check out this code for simple data sending using GSM.

#include <SoftwareSerial.h>
SoftwareSerial ph(9,10); // RX, TX of gsm
void setup() {
  Serial.begin(9600);
  ph.begin(9600);
  sms(600);
}
void loop() {
  // put your main code here, to run repeatedly:
}
void sms(float amount) {
  ph.println("AT+CMGF=1"); 
  delay(1000); 
  ph.println("AT+CMGS=\"123456789\"\r"); //Enter your number in place of 123456789
  delay(1000);
  ph.print("Amount:  ");
  ph.println(amount);
  delay(100);
  ph.println((char)26);// ASCII code of CTRL+Z
  delay(1000);   
}