Error while compiling the GSM-ReceiveSMS sketch from the Arduino Examples

When I compile the ReceiveSMS example from Arduino Example I am getting following error.

In file included from ReceiveSMS.ino:21:0:
C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM.h:7:28: fatal error: SoftwareSerial.h: No such file or directory
#include <SoftwareSerial.h>

How to resolve this issue.
Thanks in advance.

Did you look in the path defined to see if the file is not there?

File named Softwareserial.h is not there in the path. But from which link I have to download that file. I have tried but did not get the exact file. Please give me the link to download the file.

you have not included the library file. I have attached library file here. you need to extract path they mentioned or C:\Program Files (x86)\Arduino\libraries\

then try to upload code .

SoftwareSerial.zip (8.75 KB)

Dear sir,
I kept softwareserial.h file in the directory and the problem was solved.
Now I am getting other errors.

My code is (It is from GSM Examples in the Arduino IDE)

https://www.arduino.cc/en/Tutorial/GSMExamplesReceiveSMS

/*
SMS receiver

This sketch, for the Arduino GSM shield, waits for SMS messages
and displays them through the Serial port.

Circuit:

  • GSM shield

created 25 Feb 2012
by Javier Zorzano / TD

This example is in the public domain.
*/

// libraries
#include <GSM.h>

// PIN Number
#define PINNUMBER ""

// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSM_SMS sms;

char remoteNumber[20]; // Holds the emitting number

void setup()
{
// initialize serial communications
Serial.begin(9600);

Serial.println("SMS Messages Receiver");

// connection state
boolean notConnected = true;

// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}

Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}

void loop()
{
char c;

// If there are any SMSs available()
if (sms.available())
{
Serial.println("Message received from:");

// Get remote number
sms.remoteNumber(remoteNumber, 20);
Serial.println(remoteNumber);

// This is just an example of message disposal
// Messages starting with # should be discarded
if(sms.peek()=='#')
{
Serial.println("Discarded SMS");
sms.flush();
}

// Read message bytes and print them
while(c=sms.read())
Serial.print(c);

Serial.println("\nEND OF MESSAGE");

// delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}

delay(1000);

}

Errors I am getting are

ReceiveSMS:28: error: 'GSM_SMS' does not name a type
ReceiveSMS.ino: In function 'void setup()':
ReceiveSMS:49: error: invalid conversion from 'const char*' to 'long int' [-fpermissive]
In file included from ReceiveSMS.ino:21:0:
C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM.h:207:17: error: initializing argument 1 of 'virtual int GSM::begin(long int)' [-fpermissive]
virtual int begin(long baud_rate);
^
ReceiveSMS:49: error: 'GSM_READY' was not declared in this scope
ReceiveSMS.ino: In function 'void loop()':
ReceiveSMS:67: error: 'sms' was not declared in this scope
'GSM_SMS' does not name a type

These error comes becaus of reason

1)In gsm library using , they haven't define .GSM_SMS

  1. IDE you might using older version of IDE v1.0.1 you must use 1.6.4 or later version

i have attached the image file for reference. where in old version its not compiled & new version its compiled.

if you wanna run the same code on older IDE you might change library function or you need to search equivalnet library supported IDE

Thank you sir,

It was solved if I use IDE 1.6.5

But now I am not getting any output. After uploading it is just printing "SMS Messages Receiver" on the serial monitor. Even though gsm module received sms's it is not showing any thing on the serial monitor.
How can this happen? I have given the code above. otherwise link is

Please help me to reslove this issue..
Thanks in advance!

You are using the official Arduino shield aren't you?

i haven't used shield before. i will try to help by giving some ideas of debugging.i dont have sheild to test it. you can only give us what exactly happening.share us screen shot of serial monitor

you should define a no here

#define PINNUMBER "  enter phone no"

Add this part here in your code

void setup() 
{
  // initialize serial communications
  Serial.begin(9600); 

  Serial.println("SMS Messages Receiver");

  // connection state
  boolean notConnected = true;

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
      notConnected = false;
      Serial.println("GSM is ready");
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("GSM initialized");
  Serial.println("Waiting for messages");
}
  1. No, I am not using official Arduino shield. I am using GSM-Module Sim900.

  2. My sim does not have any PIN NUMBER, (They said if you don't have a PIN leave it), So I left it blank.

  3. Here I am attaching the screen shot of serial monitor when I run the code.

Try my quick troubleshooting guide, particulary points 3 & 4:

http://www.simpasture.com/26020.html

#I have used the same connections to send the sms from gsm module. I have seen the message on the serial monitor. So, It may not be problem with connections.

If it is with the connections we should not get anything on the serial monitor. we are getting first message as "SMS message receiver".

I am not sure about which libraries I have to use. I have placed the files given by @AMPS-N.

The message you are seeing is coming from the sketch, not the shield. That does not prove that you are communicating with the shield.

I still have no idea which specific shield you are using so try my last post on this thread, it may help.

http://forum.arduino.cc/index.php?topic=332624.0

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
 
char incoming_char=0;
 
void setup()
{
  Serial.begin(19200); // for serial monitor
  SIM900.begin(19200); // for GSM shield
  SIM900power();  // turn on shield
  delay(20000);  // give time to log on to network.
 
  SIM900.print("AT+CMGF=1\r");  // set SMS mode to text
  delay(100);
  SIM900.print("AT+CNMI=2,2,0,0,0\r"); 
  // blurt out contents of new SMS upon receipt to the GSM shield's serial out
  delay(100);
}
 
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(7000);
}
 
void loop()
{
  // Now we simply display any text that the GSM shield sends out on the serial monitor
  if(SIM900.available() >0)
  {
    incoming_char=SIM900.read(); //Get the character from the cellular serial port.
    Serial.print(incoming_char); //Print the incoming character to the terminal.
  }
}

can you send screen shot of your serial monitor.

try to upload code by removing sheild. if still error persist , It means your bootloader get crashed. you need upload bootloader. it can be done using avr pocket programmer.(https://www.sparkfun.com/products/9825)

I have run the above given code. I could not see anything on the Serial monitor. It is just empty. (I keep baud rate in serial monitor as 19200)

ok if code start uploading change baudrate 9600, check you GSM/ GPRS baudrate from datasheet. set those baudrate there & upload code.

I have not changed any connections, do I need any?

From your other thread I assumed that you had it working?

http://forum.arduino.cc/index.php?topic=338991