GSM Sim900A

Does anyone have a code to recieve a message from Gsm module and display it on serial monitor..
I searched a lot but I found nothing..
And I am not familiar with Gsm SMS library.
So is there anycode using Tx and Rx pins of arduino.
Please help me.
Thank you

What did you find which did not suit your needs? There are tons of instructables, articles, libraries and example on line or in this very forum...

is there anycode using Tx and Rx pins of arduino.

It is usually not a good idea to use the Tx and Rx pins on most Arduinos (which board are you using ?) because that may make uploading programs impossible whilst the module is connected and it also prevents Serial.print() being used to output messages to the serial monitor for debugging and program status messages.

The alternative is to use a board with more hardware UARTs or using the SoftSerial library to allow Rx/Tx on user defined pins.

I am using Arduino uno r3.. Actually I am able to send messages using Tx rx pin.. But I tried codes from all forums.. Like instructables.com and all but it doesn't work..
Can youll write a code for recieving a SMS and display it on serial monitor. It will be really helpful.
Thankyou for ur replies.

Can youll write a code for recieving a SMS and display it on serial monitor. It will be really helpful.

The red part is probably where you failed if you used the hardware Serial (pin 0 and 1) to connect to your module because they are also the one used by your USB connection to your computer for serial communication to the monitor.

Also most frequent error I have seen is underpowering the module. It needs a separate power supply able to deliver 2 amps.

Confirm wiring of your module and power supply, post some code that you tried and we will help you fix it

Okay…
But I also tried using software serial library still no results.
The Code I tried using software serial

#include <SoftwareSerial.h>
SoftwareSerial gsm(9,8);
void setup()
{
  gsm.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':
      Send();
      break;
    case 'r':
      Recieve();
      break;
      case 'S':
      Send();
      break;
    case 'R':
      Recieve();
      break;
  }
 if (gsm.available()>0)
   Serial.write(gsm.read());
}
 void Send()
{
  gsm.println("AT+CMGF=1");   
  delay(1000); 
  gsm.println("AT+CMGS=\"+91xxxxxxxxxx\"\r"); // Replace x with mobile number
  delay(1000);
  gsm.println("Hello I am GSM modem!!!");// The SMS text you want to send
  delay(100);
   gsm.println((char)26); // ASCII code of CTRL+Z
  delay(1000);
}
 void Recieve()
{
  gsm.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  delay(1000);
 }

Please describe wiring and power too

I have powered it with arduino..
As well as I have tried using powering Gsm module with external power supply.
Gsm tx- digital pin 8
Gsm rx - digital pin 9

Gsm tx- digital pin 8
Gsm rx - digital pin 9

When you doSoftwareSerial gsm(9,8);you are telling the library that rxPin=9 and txPin=8 where:

  • rxPin: the pin on which to receive serial data → needs to be connected to the GSM Tx
  • txPin: the pin on which to transmit serial data → needs to be connected to the GSM Rx

So you need to wire

GSM Tx <--> digital pin 9
GSM Rx <--> digital pin 8

which is the opposite of what you did.

you definitely need to power from an external power supply - make sure that power supply can deliver 2A.

Make sure your SIM card does not have a pin code.

J-M-L:
When you doSoftwareSerial gsm(9,8);you are telling the library that rxPin=9 and txPin=8 where:

  • rxPin: the pin on which to receive serial data → needs to be connected to the GSM Tx
  • txPin: the pin on which to transmit serial data → needs to be connected to the GSM Rx

So you need to wire

GSM Tx <--> digital pin 9

GSM Rx <–> digital pin 8




which is the opposite of what you did.

you definitely need to power from an external power supply - make sure that power supply can deliver 2A.


Make sure your SIM card does not have a pin code.

I am using 2amps… And I tried changing the connection as u said but no result.

Is your GSM Sim900A a shield you plug on top of your arduino or something you set on the side? can you share a picture of your module and a link to this module?

Assuming it’s not a shield but that it’s a complete system on a break out board and that you are wiring everything between a Uno and your shield:

  • plug the power to your separate 5V 2A power supply.
    - connect the ground of your shield to the ground of your arduino (important!)
  • connect GSM Tx <–> Uno digital pin 9
  • connect GSM Rx <–> Uno digital pin 8

double check your module documentation to see if some jumpers need to be set in a certain way.

upload the following code

#include <SoftwareSerial.h>

/*
    GSM Tx <--> digital pin 9
    GSM Rx <--> digital pin 8
*/
SoftwareSerial gsmSerial(9, 8);

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

void loop()
{
  while (Serial.available()) gsmSerial.write(Serial.read());
  while (gsmSerial.available()) Serial.write(gsmSerial.read());
}

open the IDE Serial console and set it to 115200 bauds and sending CR/LF in the popup menus at the bottom

type AT and enter in the Serial Console → do you see a response from your module?

(SIM900 is configured usually by default for auto-baud but you need to send A (generally AT) until you get an OK answer to establish correct baud rate)

Here is the link.. Gsm modem I am using.

https://m.ebay.in/itm/SIM900A-Dualband-GSM-GPRS-MODULE-with-SMA-Antenna-for-Arduino-Raspberry-Pi-/252275978967?hash=Mw==

So do you have a RS232 to TTL serial adaptor?

please describe in details your setup if you want help and answer questions asked... we can't second guess everything...

J-M-L:
open the IDE Serial console and set it to 115200 bauds and sending CR/LF in the popup menus at the bottom

type AT and enter in the Serial Console --> do you see a response from your module?

(SIM900 is configured usually by default for auto-baud but you need to send A (generally AT) until you get an OK answer to establish correct baud rate)

I did as you told. And yes I get a "Ok" response on monitor.

That's good sign.

try with [color=blue]AT+CMGS=?[/color] --> do you get OK as well? (indicates the AT command +CMGS is supported. If the GSM/GPRS modem or mobile phone returns the final result code "ERROR", it means the command is not supported.)

try also [color=blue]AT+CMGS=?;+CMSS=?;+CNMI=?;+CMGL=?;+CMGR=?[/color] what do you see?

try to use your mobile phone to send an SMS to the module.

then type the following

[color=blue]AT+CNMI=2,2,0,0,0[/color]

what do you see?

I got it.. I didn't got any ok response.. But I got the message..
Now can you help me write a code..
And thank you

I don't see your image..

The image isnt uploading coz the size of image large..

upload somewhere else and put a link...

Check now… I reduced the size