Pages: [1]   Go Down
Author Topic: Arduino Uno + sim900  (Read 12563 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,

I have purchased an arduino uno rev 3 http://arduino.cc/en/Main/arduinoBoardUno and a icomsat v1.0 sim900 http://iteadstudio.com/store/images/produce/Shield/IComSat/icomsat_DS1.2.pdf i am trying to send an sms using this.

the code that i am using is
Code:
#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"

//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to send and receive SMS.

int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];

void setup()
{
  //Serial connection.
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    started=true; 
  }
  else Serial.println("\nstatus=IDLE");
 
  if(started){
    //Enable this two lines if you want to send an SMS.
    if (sms.SendSMS("+971505393365", "Arduino SMS"))
      Serial.println("\nSMS sent OK");
  }

};

void loop()
{
  if(started){
    //Read if there are messages on SIM card and print them.
    if(gsm.readSMS(smsbuffer, 160, n, 20))
    {
      Serial.println(n);
      Serial.println(smsbuffer);
    }
    delay(1000);
  }
};

it  prints the first line GSM shield testing and then gives DB: NO RESP
what could be the reason for this.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you connected an external power supply to the Uno board? The IComSat SIM900 requires 9V/2A power supply and will not work with the Uno board just connected to the USB. Also, you need to set the Tx to pin 4 and Rx to pin 5.

Also, there is a small switch with UART_Port/DBG_Port options - you need to set that to UART_Port

Once the above is done correctly, you should be able to read the SMS on your SIM Card using the below mentioned example code.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got the same problem.
The status light on sim 900 is green all the time so does PWR, the net light on every 3 second.
I am not sure if it is registed, when I trid the code following
#include <NewSoftSerial.h>

/* GSM Shield example
 
 created 2011
 by Boris Landoni
 
 This example code is in the public domain.

 
 http://www.open-electronics.org
 http://www.futurashop.it
 */

#include <GSM_Shield.h>
//for enable disable debug rem or not the string       #define DEBUG_PRINT
// definition of instance of GSM class
GSM gsm;



void setup() {
  Serial.begin(9600);
  Serial.println("system startup");
  //gsm.InitSerLine(9600);   //initialize serial 1
  gsm.TurnOn(9600);              //module power on
  //gsm.InitSerLine(9600);   //initialize serial 1
  gsm.InitParam(PARAM_SET_1);//configure the module 
  gsm.Echo(1);               //enable AT echo
}


void loop()
{
 
    int reg;
    reg=gsm.CheckRegistration();
    switch (reg){   
      case REG_NOT_REGISTERED:
        Serial.println("not registered");
        break;
      case REG_REGISTERED:
        Serial.println("GSM module is registered");     
        break;
      case REG_NO_RESPONSE:
        Serial.println("GSM doesn't response");
        break;
      case REG_COMM_LINE_BUSY:
        Serial.println("comm line is not free");
        break;
    }
    delay(2000);
   
    reg=gsm.IsRegistered();
      Serial.print("Registration ");
      Serial.println(reg);
   
    delay(50000);
}
   
It always show GSM doesn't response.
By the way, I wander why do we need to change RX and TX number. In arduino uno,tx is 1 and rx is 0.

Thanks
Logged

USA
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I bought a similar shield from seeedstudio and followed the instructions on their wiki.  I got it to work by sending it AT-commands (which this shield apparently accepts too), but have not tried the SMS/GSM specific library, which I assume is just a wrapper for the AT commands.

Check http://www.seeedstudio.com/wiki/index.php?title=GPRS_Shield_v0.9b and see if your shield will respond properly?  I am curious whether you will get this one working OK, because it's a little cheaper and I would buy it instead.

BTW: If your Arduino is connected (or will be connected) via USB to the computer, then the USB is using 1 & 2, and the shield uses two digital pins via the Serial library.

To that effect, starting with Arduino 1.0, you should try the SoftwareSerial.h library that is built-into the distribution.

Finally, I found (via some google searches and confirmed this) that when using the SoftwareSerial (or NewSoftwareSerial) library to communicate, you should reduce the shield's baud rate.  I do this across each interface to keep consistent with the following on startup:
Code:
mySerial.begin(9600);
Serial.begin(9600); //only if USB will be connected
mySerial.println("AT+IPR=9600"); //sets the GPRS chip to communicate at 9600 as well

Maybe this will help.  Please keep me informed as to how you do!

--AJ
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is working now. I did not connect a extra power supply, just connect Uno with usb to labtop.
TX is 4 and RX is 5. I guess that the right pin.
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am using sim900 library the sms library , softwareserial ,wire.h and a rtc( real time clock ) library . i just read in the library example that if the ram is getting full the program would keep on restarting. my code is also acting wierd ,but my memory usage shows aboout 17kb from 30kb. although i think there is some conflict between the Sim900 and wire.h library . because the program would keep on restarting at wire.begin() when i use the wire.h library only. any solutions? I2C protocol may be causing a problem someone said to me, makes sense because sim900 also said it uses something like that , but dont know how .

libraries i used :
#include "SIM900.h"
#include "sms.h"
#include "SoftwareSerial.h"
#include "Wire.h"
#define DS3232_I2C_ADDRESS 0x68
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but my memory usage shows aboout 17kb from 30kb.
Of the 2K (on 328-based Arduinos) or 8K (on the Mega)? You are not looking at the right kind of memory usage.
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok,yea its 328 based UNO and it say "Binary sketch size: 17,542 bytes (of a 32,256 byte maximum)" when compiled. is it the RAM as referred in the library, isn't it Rom usage . and if it isn't RAM , how do i know how much i've used.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a playground page that might be of interest: http://playground.arduino.cc/Code/AvailableMemory

There are three kinds of memory on the Arduino - Flash, where the code is stored, SRAM, where variables and literals are stored, along with the stack and heap, and EEPROM, where persistent data can be stored.

The message "Binary sketch size: 17,542 bytes (of a 32,256 byte maximum)" refers to the Flash memory used.

There is nothing that reports the amount of SRAM used, because it changes as the program runs. As local variables are created, the heap grows. As functions are called, the stack grows. The grow toward each other. When they meet, bad things happen.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried using AT commands and my module is responding but it gives an error when i try to send an sms using AT+CMGS
Any advice??
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Any advice??
Sure. Re-read your post, and see if you can spot anything you left out. Like the code and error messages.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's the code. When i run it through arduino uno which is interfaced to a GPRS module from itead studios, it says AT+CMGS="+919---------" ERROR on the serial monitor.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() 
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  mySerial.begin(9600);
  mySerial.println("AT+CMGS=+919---------");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

I tried replacing AT+CMGS="919---------" with just AT and it responds perfectly fine.

Hope u can help.
Thanks
Logged

Pages: [1]   Go Up
Jump to: