New tutorial - Arduino and SIM900 GSM Modules

And I've updated it with some more remote-control examples:
http://tronixstuff.com/2014/01/08/tutorial-arduino-and-sim900-gsm-modules/

There has to be a better way of checking caller-id and the SMS content? Seems really awkward the way you do it now?

You could store the incoming data into a string and then parse it.

In something like this:

if (SIM900.available() > 0){
    c = SIM900.read();
    if (c != '\r') temp = temp + c;
     else {
        //do something with string temp
     }
}

I'm using tronixstuff's tutorial extensively and it is a life saver.

There's one thing I can't manage: Software Power On/Off. And sometimes the arduino resets (lose global variables) after an SMS is sent. I don't know what's going on.

I'm using this version: SIMCOM SIM900 Quad-band GSM GPRS Shield Development Board for Arduino/Iduino. Works perfectly. Just didn't manage to power on and that's something I really need unfortunately. Any help?

Arduino SIM900: micro:bit Accessories Store | ELECFREAKS

Hi John,

Thanks for your very good Sim900 tutorials , found them to be the best around.
Could not leave thanks on your site as not member of those feeds.

Would just like to ask you for some more practical voltage questions.

Those shields say feed with 5v to produced the 3v3 via the regulator but the regulator is able to accept a higher input voltage, but due to its minimal pcb heatsink wondered how it would fair with a 9v or 12v dc input ?

Its use in my project is very low, just sending out an alarm status message as a rare event.

Also when measuring the shields current during a SMS I can only see a peak of 330ma on my slow DVM, though its said it can reach 2A peak.

Again, in your experience, would a Wall pack rated at 1A with an extra 470uf by or on the shield be sufficient to deal with that short 2A peak draw ?

Thanks

i do not find library relatede this codes such as print , printin so anyone have that library ?
or any other codes detail ?

library codes detail and its purpose ?

At last code that works :slight_smile:

Do you know how i can get the Arduino GMS library to work with this SiMCOM SIM900 shield?

Or do you have a GPRS example?

I have a problem with my SIM900 module which do not take the signal, ie the green light will blink and does pause signal indicating that it has. Ah to be this as I solve this problem

I have a problem with my SIM900 module which do not take the signal, ie the green light will blink and does pause signal indicating that it has. Ah to be this as I solve this problem

hey guys,

i have a project to make some security alarm, and i have plan on connected it with SIM900 where the alarm would active when it receive a call (i try to use a code from tronixstuff), when i combine the code for the alarm it doesn't work, may i have some example on how to do that please?

what can i do if i don't want to receive new sms message notifications when i'm reading the serial port???

Thanks for a great tutorial.

I wander if anyone has successfully used the SIM900 shield with the arduino to check on the amount of credit on the prepay SIM card?

I have tried using the USSD code AT+CUSD=1,"*#10#" where *#10# is the code for the O2 network but I get nothing although the codes give me an OK return.

Any help would be much appreciated.

Slim

I have managed to answer my own query as to checking my prepay sim credit balance using an AT test sketch. I have included it below but due to blasted smilies being active on the board it has changed one line of code after the include# statement, which starts;
"SoftwareSerial GPRS(7, ........" to include a smilie (dammit). it should be 7,8 but the 8 and then the ) screw it up
You'll need to check that in the IDE.
The explanation of how to use it is in the sketch and the use of the AT+CUSD section into any other SIM900 skect is easily possible

// Serial echo and control for AT commands
// Uses software serial link between the computer and the GPRS Shield
// Set serial monitor to 19200
// Computer is connected to hardware UART
// SIM900 Shield is connected via the software UART

// Enter the line below into the input part of the serial monitor
// AT+CUSD=1, "#10#"
// press send
// Remaining balance will print out in the serial monitor
// NOTE "
#10#" is the code for O2 in the UK. You will need to find the correct code for your provider

#include <SoftwareSerial.h>

SoftwareSerial GPRS(7, 8) ; //control pins for SIM900 shield

unsigned char serialbuffer[64]; // set up serialbuffer array for holding data received over serial port
int count=0; // counter for serialbuffer array

void setup() // setup routines
{
GPRS.begin(19200); // Set SIM900 interface speed to 19,200
Serial.begin(19200); // Set Arduino serial monitor speed to 19,200
}

void loop() //main program
{
if (GPRS.available()) // check GPRS is available
{
while(GPRS.available())
{
serialbuffer[count++]=GPRS.read();
if(count == 64)break;
}
Serial.write(serialbuffer,count); // write to serial port buffer
clearserialbufferArray();
count = 0;
}
if (Serial.available())
GPRS.write(Serial.read()); // read from serial from sim900 shield
}

void clearserialbufferArray() // clear the storage buffer
{
for (int i=0; i<count;i++)
{
serialbuffer*=NULL;*

  • }*
    }

please use code tags,

Thank you for the clearly written how-to. It's was/is very helpful :wink:

I have tried the below mentioned code to get the message to my mobile. Instead of getting message i could only get the output in my serial monitor alone. Could anyone help me to get the message to my mobile. I'm in very need of this now.

char phone_no[]="8754928455";
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
delay(2000);
Serial.println("AT");
delay(1000);
Serial.println("AT+CMGS=1");
Serial.print("AT+CMGS="");
Serial.print(phone_no);
delay(1000);
Serial.print("\n Hello Dude");
delay(1000);

}

void loop()
{
// put your main code here, to run repeatedly:

}

Can someone help me? This is my code.

#include <LiquidCrystal.h>
#include "SIM900.h"
#include "sms.h"
#include <SoftwareSerial.h>
//#include <sms.h>
#include <PString.h>
SMSGSM sms;
boolean started = false;
char buffer[160];
char smsbuffer[160];
char n[20];
//LiquidCrystal lcd(4,2,3,7,8,9);
int buttonState;
int lastButtonState = LOW;
long lastDebounceTime = 0;
long debounceDelay = 50;
boolean st = false;
int buzzer = 12;

void setup() {

//lcd.begin(16, 2);
Serial.begin(9600);
if (gsm.begin(2400))
{
started = true;
}
if (started)
{
delsms();
}
sms.SendSMS("+60142646978" , "Gas Sensor and GSM module activated");

}

void loop() {

//lcd.setCursor(0, 0);

//lcd.print("Detektor Gas SMS");
int val = analogRead(A0);
val = map(val, 0, 1023, 0, 100);
//lcd.setCursor(0,1);
//lcd.print("Kadar: ");
//lcd.print(val);
//lcd.print("% ");

//code using sensor detection
if (val > 10) {
tone(buzzer,800,500);
delay(1000);
st = true;
}
else st = false;

if (st != lastButtonState) {
lastDebounceTime = millis();
}

if ((millis() - lastDebounceTime) > debounceDelay) {

if (st != buttonState) {
buttonState = st;

if (buttonState == HIGH) {
PString str(buffer, sizeof(buffer));
str.begin();
str.print("Gas Detected! Gas leakage at ");
str.print(val);
str.print("%");
//String a=str;
sms.SendSMS("+60142646978", buffer);
}
}
}

//code using sms lapor.
lastButtonState = st;
int pos = 0;
if (started)
{
pos = sms.IsSMSPresent(SMS_ALL);
if (pos)
{
sms.GetSMS(pos, n, smsbuffer, 100);
delay(2000);
if (!strcmp(smsbuffer, "lapor"))
{
PString str(buffer, sizeof(buffer));
str.begin();
str.print("Rate of gas leakage currently at ");
str.print(val);
str.print("%");
//String a=str;
sms.SendSMS("+60142646978", buffer);
}
delsms();
}
}
}

//delete sms yang dihantar
void delsms()
{
for (int i = 0; i < 10; i++)
{
int pos = sms.IsSMSPresent(SMS_ALL);
if (pos != 0)
{
if (sms.DeleteSMS(pos) == 1) {} else {}
}
}
}

I'm using arduino uno, sim900 module, mq2 gas sensor and buzzer to create a gas sensor detector based on sms.
I have to 2 option :

  1. The mq2 gas sensor detects and send the result via sms to the number set in the code.
  2. We can send a specific string to know the surrounding gas percentage and send the result to the specific number set in the code.

But I want to change the second option to be auto reply to any incoming number. What should I do?