Go Down

Topic: New tutorial - Arduino and SIM900 GSM Modules (Read 47879 times) previous topic - next topic

masterice

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

masterice

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;
  }
}

robtillaart

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

BillieBricks

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

Nandagopal-P

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:
 
}

richmond

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?

sahmed1990

Hi guys,

In SIM900 module, when the RTC time reaches to predefined value, is it possible to set or reset one of the GPIO's of the SIM900. Like at 10AM module has to SET the GPIO for 10 seconds and reset after 10 seconds (one time everyday). All these things to be done by SIM900 module.

dhuhachaniago

Want to ask the master
I'd like an LED control sms with sim900 and button / switch
Roughly like this:
1) When we send sms led1on then LED1 flame and no sms notification sms that LED1 Flash
2) When we sms led1off then LED1 dead and no sms notification sms that LED1 dead
3) When we sms led2on then LED2 flame and no sms notification sms that LED2 flame
4) When we sms led2off then LED2 dead and no sms notification sms that LED2 dead
5) When we sms ledallon then LED1 and LED2 flame and no sms notification sms that LED1 and LED2 flame
6) When we sms ledalloff then LED1 and LED2 dead and no sms notification sms that LED1 and LED2 dead
7) When we press the button / switch then LED3 flame and no sms notification sms that LED3 flame
8) When we press the button / switch again then LED2 dead and no sms notification sms that LED3 dead
9) But when we've sms command led1on / led2on / ledallon, led1off / led2off / ledalloff, then the button / switch, we press no sms notification that LED3 flame (button press)

Please help the master arduino
Thank you already want to help me

dhuhachaniago

My problem at the points 7, 8, 9 in the sketch that I have
please help me
thank you

dhuhachaniago


Marcrem

Hello, can somebody help me?
I bought some weeks ago a Geetech GPRS/GSM SIM900 shield. After installing the antenna and putting the SIM card to the shield, i stacked the shield to my Arduino Uno. The shield gets power via the Arduino Uno. I switched the shield on and the red led started up. The green led started to blink aswell, but with a frequency which indicates that there's NO network connection.
On the internet I don't find anything which tell me how to solve the problem.
Can somebody Help me with a list of instructions (steps to follow) in order to get the shield connected to the cellular GSM network.

PS: the SIM card that I'm using is a prepaid card and works perfect in my mobile GSM, after inserting the PIN code on my GSM.

I'm looking forward to some reactions on the message, which will help me.
Thanks in advance.

deo93

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
how you solve it mr may you help me i have the same problem

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!

Arduino
via Egeo 16
Torino, 10131
Italy