SerialGSM is a library for simplifying GSM shields.

This is sample code for sending SMS:

#include <SerialGSM.h>
#include <SoftwareSerial.h>
SerialGSM cell(2,3);
void setup(){
  cell.Message("hello world");

void loop(){
  if (cell.ReceiveSMS()){


As you can see, he uses software serial.

I intend to use this for my school thesis, but I am using a shield, so I won't be using Software Serial.

What bothers me is this line

SerialGSM cell(2,3);

In my case, do I declare it like this?:

SerialGSM cell(0,1); 

Or will there be conflicts with serial?

EDIT: In other words, how do I declare the SeralGSM object using hardware serial and not software serial?

2 Answers 2


SerialGSM is designed to work with software serial, as you can see that from the class declaration in the SerialGSM.h header:

class SerialGSM : public SoftwareSerial {

Unfortunately, changing it to use hardware serial is more complicated than it looks. There are two potential ways you could go about it:

  1. Derive from HardwareSerial instead of SoftwareSerial. This would give you flexibility, but you'd have to take care of passing all the right data to the HardwareSerial constructor, which is quite messy.

  2. Don't derive from anything. Use the global Serial object, and manually replace all serial function calls with their Serial.xxx() equivalents. This is probably easier, but it restricts you to a specific serial port.

Both approaches involve quite a lot of coding, so they aren't trivial tasks. It's also important to note that SerialGSM currently uses the global Serial object to output debug information. You'd have to remove or modify that before converting to hardware serial, or else it could interfere.

  • Thanks a lot! Ok, if that is the case, i can use it in Software Serial mode. Now, i have a gps unit that i want to use as well. That means, plug in the shield and use the SerailGSM library, and also plug in the gps on ports 0 (and 1 if i want the gps to receive data), and use Serial.begin(4800); to start the serial receiving stuff? Jun 23, 2014 at 16:17
  • That should work, although bear in mind that SerialGSM outputs debug info to hardware serial. That means if you connect the hardware TX to your GPS, then it will probably go wrong. Jun 23, 2014 at 16:33
  • OK, another approach then would be to use arduinos ready example of sending sms. the thing is i have this shield sparkfun.com/products/9607, with the SM5100B chipset. Do you know if the arduinos example of SMS sending will work with this shield? Jun 23, 2014 at 17:29
  • I've never used that shield, so I'm afraid I don't know. It looks SparkFun have their own sample code for it though: github.com/sparkfun/SM5100B_Cellular_Shield/blob/master/… Jun 23, 2014 at 20:21

Never mind, i went with the GSM SMS example from arduino 1.0.5 (Don't know the version of arduino IDE that included this) and works fine.

If you are considering using the SerialGSM library there is no need to!

CAUTION: In the Arduino's library, when you declare the phone number, you have to use international format

(Thanks bloomfield for the info you provided in the previous answer)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.