Go Down

Topic: using GSM shield without Arduino GSM library (AT commands?) (Read 8362 times) previous topic - next topic


I've assembled a data logging unit with an RTC module, LCD (i2c) display, SD memory card shield and Arduino GSM/GPRS shield on Arduino Uno R3.

Since the sketch was too big for Arduino, I removed some of not used GSM library (Mockup, SMS, Voice, ModemVerification,MultiClientProvider, MultiServerProvider, ScanNetwork) moving all related files in a new folder.
I checked on a separate sketch that having removed those files did no affect the GPRS connection and data transfer with GET method works perfectly.

The sketch compiles well, but goes out of memory and it doesn't run.

Is there a way to avoid using GSM library? reducing so far memory usage to what I actually need? maybe with AT commands (I don't know much how they work).

Thanks for any help.


You can do it with SoftwareSerial library. Modem uses digital pin 2 for RX and digital pin 3 for TX.


You can directly give the AT command and also see the response of the AT.
First try out the AT commands using hyperterminal and then use it in your code .


Put this code in your Arduino and enter AT commands with Serial Monitor:

#include <SoftwareSerial.h>
#include <string.h>

char incoming_char = 0;
SoftwareSerial cell(2,3);

void setup()
  // Initialize serial ports for communication.

  // Reset
  Serial.println("Start Reset");
  pinMode(7, OUTPUT);
  digitalWrite(7, HIGH);
  digitalWrite(7, LOW);
  Serial.println("End Reset"); 


  Serial.println("Enter your AT commands (with CR & NL)...");

void loop()
  if(cell.available() > 0)
    incoming_char = cell.read();
    if((incoming_char >= ' ') && (incoming_char<='z'))
      Serial.print((int) incoming_char);
      if(incoming_char == 10)

  if(Serial.available() > 0)
    incoming_char = Serial.read();


How do you  send sms in serial monitor using the at commands? Iv found these instructions but they seem to be for hyper terminal because no prompt shows up and ctrl+Z Have no effect. Buth NL & CR are selected and the proper baud rate is selected.

im using a tinysine gsm module and an arduino uno.

any suggestions?

To send an SMS, AT commands need to be entered in the following order:

- at+cmgf=1 (send SMS in text mode)

- at+cmgs="+9955555555? (Destination number; replace +99 with the country code of the country you want to send the SMS to, 55555555 needs to be replaced with the destination number)

When a prompt > appears enter the text you wish to send as a message, for example:
> Test sending SMS message
press CTRL+Z keys to send the message

When the SMS is sent correctly, a response will appear on the screen:
+CMGS: xx (xx=reference number)


Check this link out .... http://www.theengineeringprojects.com/2014/06/send-sms-with-arduino-uno-and-sim900d-using-at-commands.html ..... This code works perfectly as I have testing it myself. Its for sending sms via sm900 using AT commands but you can modify it and can send whatever command you want. Hope it will work.
You can find a lot more tutorials on Arduino in my blog www.TheEngineeringProjects.com/blog


Hi all...I have a question for you, regarding AT commands..How did you managed to read the responses from the module ?I've tryied some serial reads, but it seems I'm not doing it properly...Tryied  to discard the firsts <LF>,<CR>, the last ones, but with no succes. Can't find the proper alghorithm to do this. Can you point me to some direction ?


        First make sure your software serial pins and the one in gsmlibrary matches. Then it will work fine!


I had solved the problem, using strings (much easyer to manipulate,at least for me ),and for the moment I'm in the sms "bussiness", receiving commands that Ardu will execute,send sms for some status reporting and commands confirming.In this way, the module also works with the others platforms ,such Pic32's,uno32's, using his native Rx,Tx,Ctrl pins...Next attempt will be the GPRS stuff, which will be much tricky..for a noob like me...:)


I've written this code for my Arduino UNO R3 and Arduino GSM shield on top to send a message to a cell phone when it detects a sound ( Microphone and amplifier is built already as an input)

and I recently get a problem with the double messages sending to my phone everytime.

When it picks up the signal. Pin 9 powers up the GSM Shield. Then it takes a few second to log on to the network. Then a message is sent to my cellphone.

Unfortunately, it is supposed to turn off the GSM module right away but it doesn't and many more messages come.

I use
Code: [Select]
digitalWrite(powerPin, LOW); to turn it off.

It works sometimes but most of the time it doesn't and I don't want it to be so unstable.

Could it be the delay time? I've tried to modify the code in various ways and it still doesnt work.

Can anyone help me?
Code: [Select]

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);

int threshold = 300;
int powerPin = 9;

void setup()
  pinMode(powerPin, OUTPUT);

void loop()
  if(analogRead(A0) > threshold)
  digitalWrite(powerPin, HIGH);
  digitalWrite(powerPin, LOW);

void sendSMS()
  SIM900.print("AT+CMGF=1\r");                                                        // AT command to send SMS message
  SIM900.println("AT + CMGS = \"+1234536789\"");                                     // recipient's mobile number, in international format E.123
  SIM900.println("Message to be sent in here");        // message to send
  SIM900.println((char)26);                       // End AT command with a ^Z, ASCII code 26

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131