arepex92 / gsm-shield-arduino

Automatically exported from code.google.com/p/gsm-shield-arduino
0 stars 0 forks source link

gsm900 programming problem.... #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Please i need help i m doing my final year project...... what i want is when 
send sms "On" led should turn on and when i send sms "Off" led should turn off 
but when i send sms "Off" PIR sensor should start work..... but i dont know its 
not working here is my code please anyone can help meee

#include "SIM900.h"
#include <SoftwareSerial.h>
//#include "inetGSM.h"
#include "sms.h"
SMSGSM sms;
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
int ledPin = 13; // led connected to control pin 13
int PIRSensor = 2; // the PIR sensor will be plugged at digital pin 2
int val=0;
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
pinMode(PIRSensor, INPUT); // declare the PIRSensor as as OUTPUT
Serial.begin(9600); // use the serial port
  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 PIRON(){

if(digitalRead(PIRSensor==HIGH)){   // read the input pin
  digitalWrite(ledPin, HIGH);      // sets the LED to the button's value
  delay(1000);    
digitalWrite(ledPin, LOW);   // delay in milisecond. 3000 = 3 second
  }

}

void loop() {
   if(started){
    //Read if there are messages on SIM card and print them.
    if(gsm.readSMS(smsbuffer, 160, "On", 20))
    {
       digitalWrite(ledPin, HIGH);
      Serial.println(n);
      Serial.println(smsbuffer);

    }
     if(gsm.readSMS(smsbuffer, 160, "Off", 20))
    {

  digitalWrite(ledPin, LOW);

       PIRON();
 Serial.println(n);
      Serial.println(smsbuffer);

    }
    delay(1000);

  }

}

Original issue reported on code.google.com by veezo201...@gmail.com on 2 May 2012 at 6:18

GoogleCodeExporter commented 8 years ago
look how readSMS() works...
readSMS(char* msg, int msglength, char* number, int nlength)

the third parameter is number not string_expected

Original comment by martines...@gmail.com on 2 May 2012 at 10:48

GoogleCodeExporter commented 8 years ago
then how can i send sms to turn on led? because i want to send sms which will 
be string not number....? i m confused hehe

Original comment by veezo201...@gmail.com on 2 May 2012 at 11:56

GoogleCodeExporter commented 8 years ago
its not working i dont know why i want to send sms "On" led should turn on and 
when i send sms "Off" led should turn off but PIR sensor should start work here 
is the code i have attached

Original comment by veezo201...@gmail.com on 2 May 2012 at 3:10

Attachments:

GoogleCodeExporter commented 8 years ago
You have to compare the message saved from readSMS, with 
if(strcmp(msg,"On"))
   LED ON
else if(strcmp(msg,"Off")
   LED OFF
check the return of strcmp.
However for this kind of request is better if you use the Arduino's forum (that 
sometimes I check and answer).
http://www.arduino.cc/forum/
The issue are strictly only for library's problem.
Marco

Original comment by martines...@gmail.com on 2 May 2012 at 4:42

GoogleCodeExporter commented 8 years ago

Original comment by martines...@gmail.com on 2 May 2012 at 4:43

GoogleCodeExporter commented 8 years ago
This issue section is not longer supported.
Please check the support page www.gsmlib.org 

Original comment by martines...@gmail.com on 6 Jul 2013 at 11:27