Loading...
Pages: [1] 2   Go Down
Author Topic: iComSat v1.1 HELP  (Read 744 times)
0 Members and 1 Guest are viewing this topic.
Malaysia
Offline Offline
Full Member
***
Karma: 3
Posts: 166
Stay calm and call batman!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 55
Posts: 1599
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
been very frustrated with this code
What code ?
Logged

Malaysia
Offline Offline
Full Member
***
Karma: 3
Posts: 166
Stay calm and call batman!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

LOL i tot i have uploaded -.- so sorry
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("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);
  }
};
Logged

Malaysia
Offline Offline
Full Member
***
Karma: 3
Posts: 166
Stay calm and call batman!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Logged

East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 55
Posts: 1599
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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 ?
« Last Edit: March 23, 2013, 05:44:55 am by UKHeliBob » Logged

East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 55
Posts: 1599
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Code:
if (smsbuffer== "on")
Logged

Malaysia
Offline Offline
Full Member
***
Karma: 3
Posts: 166
Stay calm and call batman!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What does that function do ?
Where is it called from ?
honestly, i have no idea....biggest mystery haha. i just tried an error

Quote
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 <action>?
Logged

East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 55
Posts: 1599
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Malaysia
Offline Offline
Full Member
***
Karma: 3
Posts: 166
Stay calm and call batman!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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!!
« Last Edit: March 23, 2013, 11:58:06 pm by desmondttm123 » Logged

Malaysia
Offline Offline
Full Member
***
Karma: 3
Posts: 166
Stay calm and call batman!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: March 24, 2013, 01:02:48 am by desmondttm123 » Logged

East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 55
Posts: 1599
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Malaysia
Offline Offline
Full Member
***
Karma: 3
Posts: 166
Stay calm and call batman!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
GSM Shield testing.

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

Logged

East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 55
Posts: 1599
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Malaysia
Offline Offline
Full Member
***
Karma: 3
Posts: 166
Stay calm and call batman!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 55
Posts: 1599
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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.
Logged

Pages: [1] 2   Go Up
Print
 
Jump to: