iComSat v1.1 HELP

Hello, i need help with a sketch. i am using this GSM module from iTead Studio. This sketch can only view and display the SMS once, i have to remove the sim, use a phone and delete all the read and unread sms. only when the sim is empty i can display the SMS. but like i said, i can only send 1 sms to it. the second time will not work. any body has any ideas? been very frustrated with this code.

thanks for the help!

been very frustrated with this code

What code ?

LOL i tot i have uploaded -.- so sorry

#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("3471234567", "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);
  }
};

I have solved the problem already, i just added this at the end

void ProcessSms( String sms ){
}

after that everything went well =) however i have a second problem. i want to activate an LED via SMS. when i SMS “on” the LED will light. the code is as below

#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 A=7;
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");
pinMode( 7, OUTPUT );
   
  if(started){
    //Enable this two lines if you want to send an SMS.
    //if (sms.SendSMS("3471234567", "Arduino SMS"))
    //Serial.println("\nSMS sent OK");
  }

};

void loop() 

{

  char  position1 = sms.IsSMSPresent(SMS_READ);
  char  position2 = sms.IsSMSPresent(SMS_UNREAD);
  char  position3 = sms.IsSMSPresent(SMS_UNREAD);
  char  position4 = sms.IsSMSPresent(SMS_UNREAD);
  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);


    if (position1) {
      sms.DeleteSMS(position1);
      if (position2) {
        sms.DeleteSMS(position2);
        if (position3) {
          sms.DeleteSMS(position3);
          if (position4) {
            sms.DeleteSMS(position4);
          }
        }
      }
    }
  }
if (smsbuffer== "on")digitalWrite(A, HIGH);
}

void ProcessSms( String sms ){
}

the sketch can compile, but when i send “on” nothing happens

i have tried using strcmp to compare stringa as well but that turned out a failure too…any suffestions? smsbuffer is the SMS content

I have solved the problem already, i just added this at the end

Code: void ProcessSms( String sms ){ }

What does that function do ? Where is it called from ?

As to your other problem. What do you get when you print smsmbuffer having sent an SMS message "on" ? If the message looks correct when printed,(I would surround it with start/end marker such as [ and ] ) then you should be suspicious of your test

if (smsbuffer== "on")

What does that function do ?
Where is it called from ?

honestly, i have no idea…biggest mystery haha. i just tried an error

What do you get when you print smsmbuffer having sent an SMS message “on” ?

on the serial monitor, it says “on” but the led does not light up. basically what SMS i send to the arduino GSM, it will appear on the serial Monitor. in my case “smsbuffer” is a variable right? so is there a way to say if this vairiable = “on” then ?

  if (strcmp (smsbuffer,"on") == 0)
  {
    Serial.println("match"); 
  }

Hi, thanks for the reply! unfortunately it still did not work =( however, when i changedit to >=0, it can display "match" in serial monitor, but led not lit, my sketch is as below

if (strcmp (smsbuffer,"on") >= 0)
  {
   digitalWrite(led, HIGH);
    Serial.println("Match On"); 
    
  }
   if (strcmp (smsbuffer,"off") >= 0)
  {
    digitalWrite(led, LOW);
    Serial.println("Match Off");

Thanks! i know its close to accomplish!!

Hi an add on to my previos reply, i can get the led to on if i remove the"off" because in the serial monitor it dislays

on match on match off

how should i improve it? thanks!!!!

This is the full serial monitor, i dont understand the pattern, some text other than "off" can turn it off and same as "on" can anyone explain ? GSM Shield testing.

status=READY 13/03/24,13:57:05+3 Abc

Match OFF

Ate

Match OFF 13/03/24,13:57:37+3 Am

Match OFF 13/03/24,13:57:52+3 On

Match ON 13/03/24,13:58:07+3 Op

Match ON Desmond Pe

Match ON Desmond ad

Match ON 13/03/24,13:59:16+3 Shj

Match ON 13/03/24,13:59:31+3 Off

Desmond Abc

Match OFF Desmond Abc

Match OFF

A zero value returned from strcmp indicates that both strings are equal. Try printing out the values to see what is going on. Whatever is happening, your test must be for zero otherwise you are testing that teh two strings don't match.

Hi,When i put if (strcmp (smsbuffer,"On") == 0) this is the results in the serial monitor. however if i put >= 0 it works..i dont understand

GSM Shield testing.

status=READY
13/03/24,16:50:04+3
On

What I meant was for you to print out the value of the strcmp. If it is not zero then the strings do not match.

Im sorry i still dont quite understand..can u explain? or give an example?

Serial.print(smsbuffer is : ";
Serial.println(smsbuffer);
Serial.print("The result of strcmp is : ";
Serial.println((strcmp (smsbuffer,"On"));
if (strcmp (smsbuffer,"On") == 0)

If strcmp is not zero then the strings don't match but the value printed may help diagnose what is going on.

Hi, this is what the serial monitor says

GSM Shield testing.

status=READY
13/03/24,20:14:23+3
On

smsbuffer is : On

The result of strcmp is : 13

so when i put

if (strcmp (smsbuffer,"On") == 13) 
  {
Serial.print("match On");

the LED only turns on upon "on"! you are a genius! however, i tried adding another "off" funtion where the serial monitor says

Off

smsbuffer is : Off

The result of strcmp is : -8

but when i put if (strcmp (smsbuffer,"Off") == -8) nothing happens. below is how my sketch looks like

 Serial.print("smsbuffer is : ");
Serial.println(smsbuffer);
Serial.print("The result of strcmp is : ");
Serial.println((strcmp (smsbuffer,"On")));


if (strcmp (smsbuffer,"On") == 13) 
  {
Serial.print("match On");
digitalWrite(led,HIGH);
 }

 if (strcmp (smsbuffer,"Off") == -8
) 
  {
Serial.print("match Off");
digitalWrite(led,LOW);
 }
  }

once again, many many thanks! u are truly awesome!!

HI, I FINALLY SOLVED IT WITH YOUR HELP! THANKS SO MUCH!!!! i changed

if (strcmp (smsbuffer,"On") == -8) 
{
  Serial.print("match Off");
digitalWrite(led,LOW);
 }
  }

and it worked =)!!

btw just another small problem, the serial monitor displays repetitive results, why is that so? the sketch is the same as the ones above

You have not solved it, you have worked round it.

The program will continue to print values for ever because there is nothing to stop it. If you only want it to run once then put all of the code in setup() and nothing in loop(). To start it again you would need to reset the Arduino which can be done by pressing the reset button or restarting the serial monitor (not on the Leonardo though)

A better way would be to set a flag when enough readings have been made and surround the code in an if test. If the flag is not set then run the program. This would allow you to incorporate a button to restart the test.

Hi, thanks for the reply again. is this the way http://arduino.cc/en/Tutorial/SerialEvent ? thanks