Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: switching led on from toggle switch on: November 04, 2013, 12:47:01 pm
Hi, i did load the example,it basically flashes an led,how do i implement it into switching with a toggle switch,thanks
2  Using Arduino / Programming Questions / switching led on from toggle switch on: November 04, 2013, 12:20:12 pm
hi , the following code switches an led on when pin 3 goes high,the code i require needs to switch an led on for 10 seconds then off  even when toggle switch on pin 3 is in on position,it must remain off even when the toggle switch is in the on position(pin 3 is high),when the toggle switch is switched off then on again the led must come on again for ten seconds then off and stay off until the toggle switch is reset again.
thank you for your assistance
learning arduino
Code:
int ledPin = 13; // choose the pin for the LED
int inPin = 3;   // choose the input pin (for a toggle switch)
int val = 0;     // variable for reading the pin status

void setup() {
  pinMode(ledPin, OUTPUT);  // declare LED as output
  pinMode(inPin, INPUT);    // declare toggle switch as input
}

void loop(){
  val = digitalRead(inPin);  // read input value
  if (val == HIGH) {         // check if the input is HIGH (button released)
    digitalWrite(ledPin, HIGH);  // turn LED ON
  } else {
    digitalWrite(ledPin, LOW);  // turn LED OFF
  }
}
 
3  Using Arduino / Programming Questions / Re: reading sms on: May 28, 2013, 10:15:55 am
HI ,many of us have arduino r3"s and sim 900 shield all plugged up,no matter how hard we try and even if we do get the sketch working, it seems to work for a certain time then decides to do its own thing,leaving us with frustrations,is there anyone with an arduino sketch that will receive an sms on sim900 shield and uno R3, read the sms then turn on an led if the message has the word 'on' in it and then delete the received sms on the simcard successfully,so the sim doesn't fill up.Anyone with a fully working sketch please help us put our hardware to use also remember we not hardcore programmers so the task of changing things like serial buffers are not for us,there are many working sketches out there, but be careful the sudden
failure especially if u using it to open the garage door by sms,help the hundreds of us that experience problems with this shield thanks
4  Using Arduino / Programming Questions / Re: deleting sms using AT commands on: February 09, 2013, 12:59:34 am
I never mentioned in any part of this post that I want to talk to the phone and pc at the same time,that will defeat purpose of a stand alone unit,let me explain,"in detail", I. First upload the sms sketch to my arduino uno  R3,then I place my arduino sim900 shield,then usb and external power,everything works well except the delete sms command in the sketch,the serial display shows at command been sent but the simcard still fulls up after about 10 sms's. Next step would be to problem solve,so I need to check if the delete AT command works with my shield,so I configure the arduino in gate way mode(no jumpers or chip),which means communication between shield and uno with no sketch but only AT commands using a terminal program in windows,so when I send the same delete  AT command it deletes the sms's from the sim,so the AT commands not executed by the arduino  sketch but its a valid command for my shield,then I decide to get help from arduino forum,(on going process unable to understand what I'm doing).
5  Using Arduino / Programming Questions / Re: deleting sms using AT commands on: February 04, 2013, 03:36:07 am
Hi,on the serial display the AT command is seen,but all sms's are still on the sim card,although the command is executed on the sketch,no sms are deleted,after 10 sms's the sim card fulls up.
6  Using Arduino / Programming Questions / deleting sms using AT commands on: February 02, 2013, 06:54:40 am
hi,using arduino uno and sim900 gsm shield,
when i send the delete command AT+CMGDA="DEL READ"  using serial program,the sms's on my sim card are deleted but when i try it using arduino the sms's are not deleted,,,,,,thanks
Code:
void deleteSMS()
{
  Serial.print("AT+CMGDA=\"DEL READ\"");
  Serial.println();
  delay(1000);
7  Using Arduino / Programming Questions / Re: reading sms on: January 12, 2013, 11:20:35 am
hi, sorry about posting the code with unnecessary text,will clean it up when i make another post,i spent many hours researching strings and looking at other sketches,trying to read an sms and activate the led,finally don't think i understand the strings well enough to modify it and get it to work,so ill have to go back to controlling leds ,sensors ,motors and sending sms's,had no difficulty modifing these sketches and getting them to work,think the best is to use my shield for sending sms's only.
sorry for any inconvenience
Thank you for your help,
8  Using Arduino / Programming Questions / Re: reading sms on: January 12, 2013, 10:29:06 am
Code:
this sketch reads incoming sms's and stores it perfectly,the stored sms  doesnt show the contents of it,the word 'on' doesnt appear anywhere on the serial monitor only the cellphone number and some other details,according to the sketch it should activate the led when an sms 'on' is sent,i checked all AT commands they seem to be right,not sure how to modify the part that is responsible for reading the sms,


 #define _SS_MAX_RX_BUFF 128 // RX buffer size
#include <SoftwareSerial.h>
 
SoftwareSerial mySerial(7, 8);

// EN: String buffer for the GPRS shield message
// FR: Mémoire tampon de type string pour les messages du shield GPRS
String msg = String("");
// EN: Set to 1 when the next GPRS shield message will contains the SMS message
// FR: Est mis à 1 quand le prochain message du shield GPRS contiendra le contenu du SMS
int SmsContentFlag = 0;

// EN: Pin of the LED to turn ON and OFF depending on the received message
// FR: Pin de la LED a allumer/éteindre en fonction du message reçu
int ledPin = 13;

// EN: Code PIN of the SIM card (if applied)
// FR: Code PIN de la carte SIM (si applicable)
String SIM_PIN_CODE = String( "XXXX" );
 
void setup()
{
  mySerial.begin(19200);               // the GPRS baud rate  
  Serial.begin(19200);                 // the GPRS baud rate

  // Initialize la PIN
  pinMode( ledPin, OUTPUT );
  digitalWrite( ledPin, LOW );
}
 
void loop()
{
    char SerialInByte;
    
    if(Serial.available())
    {
       mySerial.print((unsigned char)Serial.read());
     }  
    else  if(mySerial.available())
    {
        char SerialInByte;
        SerialInByte = (unsigned char)mySerial.read();
        
        // EN: Relay to Arduino IDE Monitor
        // FR: Relayer l'information vers le moniteur Serie Arduino
        Serial.print( SerialInByte );
        
        // -------------------------------------------------------------------
        // EN: Program also listen to the GPRS shield message.
        // FR: Le programme écoute également les messages issus du GPRS Shield.
        // -------------------------------------------------------------------
        
        // EN: If the message ends with <CR> then process the message
        // FR: Si le message se termine par un <CR> alors traiter le message
        if( SerialInByte == 13 ){
          // EN: Store the char into the message buffer
          // FR: Stocké le caractère dans le buffer de message
          ProcessGprsMsg();
         }
         if( SerialInByte == 10 ){
            // EN: Skip Line feed
            // FR: Ignorer les Line Feed
         }
         else {
           // EN: store the current character in the message string buffer
           // FR: stocker le caractère dans la mémoire tampon réservé au message
           msg += String(SerialInByte);
         }
     }  
}

// EN: Make action based on the content of the SMS.
//     Notice than SMS content is the result of the processing of several GPRS shield messages.
// FR: Execute une action sur base du contenu d'un SMS.
//     Notez que le contenu du SMS est le résultat du traitement de plusieurs messages du shield GPRS.
void ProcessSms( String sms ){
  Serial.print( "ProcessSms for [" );
  Serial.print( sms );
  Serial.println( "]" );
  
  if( sms.indexOf("on") >= 0 ){
    digitalWrite( ledPin, HIGH );
    Serial.println( "LED IS ON" );
    return;
  }
  if( sms.indexOf("off") >= 0 ){
    digitalWrite( ledPin, LOW );
    Serial.println( "LED IS OFF" );
    return;
  }
}

// EN: Send the SIM PIN Code to the GPRS shield
// FR: Envoyer le code PIN de la carte SIM au shield GRPS
void GprsSendPinCode(){
  if( SIM_PIN_CODE.indexOf("XXXX")>=0 ){
    Serial.println( "*** OUPS! you did not have provided a PIN CODE for your SIM CARD. ***" );
    Serial.println( "*** Please, define the SIM_PIN_CODE variable . ***" );
    return;
  }
  mySerial.print("AT+CPIN=");
  mySerial.println( SIM_PIN_CODE );
}

// EN: Request Text Mode for SMS messaging
// FR: Demande d'utiliser le mode Text pour la gestion des messages
void GprsTextModeSMS(){
  mySerial.println( "AT+CMGF=1" );
}

void GprsReadSmsStore( String SmsStorePos ){
  // Serial.print( "GprsReadSmsStore for storePos " );
  // Serial.println( SmsStorePos );
  mySerial.print( "AT+CMGR=" );
  mySerial.println( SmsStorePos );
}

// EN: Clear the GPRS shield message buffer
// FR: efface le contenu de la mémoire tampon des messages du GPRS shield.
void ClearGprsMsg(){
  msg = "";
}

// EN: interpret the GPRS shield message and act appropiately
// FR: interprete le message du GPRS shield et agit en conséquence
void ProcessGprsMsg() {
  Serial.println("");
  Serial.print( "GPRS Message: [" );
  Serial.print( msg );
  Serial.println( "]" );
  
  if( msg.indexOf( "+CPIN: SIM PIN" ) >= 0 ){
     Serial.println( "*** NEED FOR SIM PIN CODE ***" );
     Serial.println( "PIN CODE *** WILL BE SEND NOW" );
     GprsSendPinCode();
  }

  if( msg.indexOf( "Call Ready" ) >= 0 ){
     Serial.println( "*** GPRS Shield registered on Mobile Network ***" );
     GprsTextModeSMS();
  }
  
  // EN: unsolicited message received when getting a SMS message
  // FR: Message non sollicité quand un SMS arrive
  if( msg.indexOf( "+CMTI" ) >= 0 ){
     Serial.println( "*** SMS Received ***" );
     // EN: Look for the coma in the full message (+CMTI: "SM",6)
     //     In the sample, the SMS is stored at position 6
     // FR: Rechercher la position de la virgule dans le message complet (+CMTI: "SM",6)
     //     Dans l'exemple, le SMS est stocké à la position 6
     int iPos = msg.indexOf( "," );
     String SmsStorePos = msg.substring( iPos+1 );
     Serial.print( "SMS stored at " );
     Serial.println( SmsStorePos );
    
     // EN: Ask to read the SMS store
     // FR: Demande de lecture du stockage SMS
     GprsReadSmsStore( SmsStorePos );
  }
  
  // EN: SMS store readed through UART (result of GprsReadSmsStore request)  
  // FR: Lecture du stockage SMS via l'UART (résultat de la requete GprsReadSmsStore)
  if( msg.indexOf( "+CMGR:" ) >= 0 ){
    // EN: Next message will contains the BODY of SMS
    // FR: Le prochain message contiendra le contenu du SMS
    SmsContentFlag = 1;
    // EN: Following lines are essentiel to not clear the flag!
    // FR: Les ligne suivantes sont essentielle pour ne pas effacer le flag!
    ClearGprsMsg();
    return;
  }
  
  // EN: +CMGR message just before indicate that the following GRPS Shield message
  //     (this message) will contains the SMS body
  // FR: le message +CMGR précédent indiquait que le message suivant du Shield GPRS
  //     (ce message) contient le corps du SMS
  if( SmsContentFlag == 1 ){
    Serial.println( "*** SMS MESSAGE CONTENT ***" );
    Serial.println( msg );
    Serial.println( "*** END OF SMS MESSAGE ***" );
    ProcessSms( msg );
  }
  
  ClearGprsMsg();
  // EN: Always clear the flag
  // FR: Toujours mettre le flag à 0
  SmsContentFlag = 0;
}


Code:
GPRS Message: []

NORMAL POWER DOWN

GPRS Message: [
NORMAL POWER DOWN]

Àÿÿÿÿÿÿÿÿ

GPRS Message: [
Àÿÿÿÿÿÿÿÿ]

RDY

GPRS Message: [
RDY]



GPRS Message: [
]

+CFUN: 1

GPRS Message: [
+CFUN: 1]



GPRS Message: [
]

+CPIN: READY

GPRS Message: [
+CPIN: READY]



GPRS Message: [
]

Call Ready

GPRS Message: [
Call Ready]
*** GPRS Shield registered on Mobile Network ***

AT+CMGF=1

GPRS Message: [
AT+CMGF=1]



GPRS Message: [
]

OK

GPRS Message: [
OK]



GPRS Message: [
]

+CMTI: "SM",9

GPRS Message: [
+CMTI: "SM",9]
*** SMS Received ***
SMS stored at 9

AT+CMGR=9

GPRS Message: [
AT+CMGR=9]



GPRS Message: [
]

+CMGR: "REC UNREAD","+27764569***","","13/01/12,17:13:31+08"

GPRS Message: [
+CMGR: "REC UNREAD","+27764569***","","13/01/12,17:13:31+08"]



GPRS Message: [
]
*** SMS MESSAGE CONTENT ***


*** END OF SMS MESSAGE ***
ProcessSms for [
]

OK

GPRS Message: [
OK]



GPRS Message: [
]

NORMAL POWER DOWN

GPRS Message: [
NORMAL POWER DOWN]

9  Using Arduino / Programming Questions / Re: reading sms on: January 11, 2013, 03:48:07 pm
Code:
found a sketch for sim900,that should activate led pin output when receives an sms with on but does not,my serial monitors shows the sketch reading the sms without any problems but no led lights up.Got the gsm shield set on software serial and using uno R3,also tried using it in hardware serial mode,did not work,in hardware serial mode pin1 and 2 are (txrx),not sure how to re-configure in the sketch and not sure why led is not high when sms with ,on is sent.

[code]#define _SS_MAX_RX_BUFF 128 // RX buffer size
#include <SoftwareSerial.h>
 
SoftwareSerial mySerial(7, 8);

// EN: String buffer for the GPRS shield message
// FR: Mémoire tampon de type string pour les messages du shield GPRS
String msg = String("");
// EN: Set to 1 when the next GPRS shield message will contains the SMS message
// FR: Est mis à 1 quand le prochain message du shield GPRS contiendra le contenu du SMS
int SmsContentFlag = 0;

// EN: Pin of the LED to turn ON and OFF depending on the received message
// FR: Pin de la LED a allumer/éteindre en fonction du message reçu
int ledPin = 13;

// EN: Code PIN of the SIM card (if applied)
// FR: Code PIN de la carte SIM (si applicable)
String SIM_PIN_CODE = String( "XXXX" );
 
void setup()
{
  mySerial.begin(19200);               // the GPRS baud rate   
  Serial.begin(19200);                 // the GPRS baud rate

  // Initialize la PIN
  pinMode( ledPin, OUTPUT );
  digitalWrite( ledPin, LOW );
}
 
void loop()
{
    char SerialInByte;
     
    if(Serial.available())
    {
       mySerial.print((unsigned char)Serial.read());
     } 
    else  if(mySerial.available())
    {
        char SerialInByte;
        SerialInByte = (unsigned char)mySerial.read();
       
        // EN: Relay to Arduino IDE Monitor
        // FR: Relayer l'information vers le moniteur Serie Arduino
        Serial.print( SerialInByte );
       
        // -------------------------------------------------------------------
        // EN: Program also listen to the GPRS shield message.
        // FR: Le programme écoute également les messages issus du GPRS Shield.
        // -------------------------------------------------------------------
       
        // EN: If the message ends with <CR> then process the message
        // FR: Si le message se termine par un <CR> alors traiter le message
        if( SerialInByte == 13 ){
          // EN: Store the char into the message buffer
          // FR: Stocké le caractère dans le buffer de message
          ProcessGprsMsg();
         }
         if( SerialInByte == 10 ){
            // EN: Skip Line feed
            // FR: Ignorer les Line Feed
         }
         else {
           // EN: store the current character in the message string buffer
           // FR: stocker le caractère dans la mémoire tampon réservé au message
           msg += String(SerialInByte);
         }
     }   
}

// EN: Make action based on the content of the SMS.
//     Notice than SMS content is the result of the processing of several GPRS shield messages.
// FR: Execute une action sur base du contenu d'un SMS.
//     Notez que le contenu du SMS est le résultat du traitement de plusieurs messages du shield GPRS.
void ProcessSms( String sms ){
  Serial.print( "ProcessSms for [" );
  Serial.print( sms );
  Serial.println( "]" );
 
  if( sms.indexOf("on") >= 0 ){
    digitalWrite( ledPin, HIGH );
    Serial.println( "LED IS ON" );
    return;
  }
  if( sms.indexOf("off") >= 0 ){
    digitalWrite( ledPin, LOW );
    Serial.println( "LED IS OFF" );
    return;
  }
}

// EN: Send the SIM PIN Code to the GPRS shield
// FR: Envoyer le code PIN de la carte SIM au shield GRPS
void GprsSendPinCode(){
  if( SIM_PIN_CODE.indexOf("XXXX")>=0 ){
    Serial.println( "*** OUPS! you did not have provided a PIN CODE for your SIM CARD. ***" );
    Serial.println( "*** Please, define the SIM_PIN_CODE variable . ***" );
    return;
  }
  mySerial.print("AT+CPIN=");
  mySerial.println( SIM_PIN_CODE );
}

// EN: Request Text Mode for SMS messaging
// FR: Demande d'utiliser le mode Text pour la gestion des messages
void GprsTextModeSMS(){
  mySerial.println( "AT+CMGF=1" );
}

void GprsReadSmsStore( String SmsStorePos ){
  // Serial.print( "GprsReadSmsStore for storePos " );
  // Serial.println( SmsStorePos );
  mySerial.print( "AT+CMGR=" );
  mySerial.println( SmsStorePos );
}

// EN: Clear the GPRS shield message buffer
// FR: efface le contenu de la mémoire tampon des messages du GPRS shield.
void ClearGprsMsg(){
  msg = "";
}

// EN: interpret the GPRS shield message and act appropiately
// FR: interprete le message du GPRS shield et agit en conséquence
void ProcessGprsMsg() {
  Serial.println("");
  Serial.print( "GPRS Message: [" );
  Serial.print( msg );
  Serial.println( "]" );

/*The following code used only when you have set pin code to your SIM card*/
//  if( msg.indexOf( "+CPIN: SIM PIN" ) >= 0 ){
//     Serial.println( "*** NEED FOR SIM PIN CODE ***" );
//     Serial.println( "PIN CODE *** WILL BE SEND NOW" );
//     GprsSendPinCode();
//  }

  if( msg.indexOf( "Call Ready" ) >= 0 ){
     Serial.println( "*** GPRS Shield registered on Mobile Network ***" );
     GprsTextModeSMS();
  }
 
  // EN: unsolicited message received when getting a SMS message
  // FR: Message non sollicité quand un SMS arrive
  if( msg.indexOf( "+CMTI" ) >= 0 ){
     Serial.println( "*** SMS Received ***" );
     // EN: Look for the coma in the full message (+CMTI: "SM",6)
     //     In the sample, the SMS is stored at position 6
     // FR: Rechercher la position de la virgule dans le message complet (+CMTI: "SM",6)
     //     Dans l'exemple, le SMS est stocké à la position 6
     int iPos = msg.indexOf( "," );
     String SmsStorePos = msg.substring( iPos+1 );
     Serial.print( "SMS stored at " );
     Serial.println( SmsStorePos );
     
     // EN: Ask to read the SMS store
     // FR: Demande de lecture du stockage SMS
     GprsReadSmsStore( SmsStorePos );
  }
 
  // EN: SMS store readed through UART (result of GprsReadSmsStore request) 
  // FR: Lecture du stockage SMS via l'UART (résultat de la requete GprsReadSmsStore)
  if( msg.indexOf( "+CMGR:" ) >= 0 ){
    // EN: Next message will contains the BODY of SMS
    // FR: Le prochain message contiendra le contenu du SMS
    SmsContentFlag = 1;
    // EN: Following lines are essentiel to not clear the flag!
    // FR: Les ligne suivantes sont essentielle pour ne pas effacer le flag!
    ClearGprsMsg();
    return;
  }
 
  // EN: +CMGR message just before indicate that the following GRPS Shield message
  //     (this message) will contains the SMS body
  // FR: le message +CMGR précédent indiquait que le message suivant du Shield GPRS
  //     (ce message) contient le corps du SMS
  if( SmsContentFlag == 1 ){
    Serial.println( "*** SMS MESSAGE CONTENT ***" );
    Serial.println( msg );
    Serial.println( "*** END OF SMS MESSAGE ***" );
    ProcessSms( msg );
  }
 
  ClearGprsMsg();
  // EN: Always clear the flag
  // FR: Toujours mettre le flag à 0
  SmsContentFlag = 0;
}

Code:
GPRS Message: [0Àÿÿÿÿÿÿÿÿ]

RDY

GPRS Message: [
RDY]



GPRS Message: [
]

+CFUN: 1

GPRS Message: [
+CFUN: 1]



GPRS Message: [
]

+CPIN: READY

GPRS Message: [
+CPIN: READY]



GPRS Message: [
]

Call Ready

GPRS Message: [
Call Ready]
*** GPRS Shield registered on Mobile Network ***

AT+CMGF=1

GPRS Message: [
AT+CMGF=1]



GPRS Message: [
]

OK

GPRS Message: [
OK]



GPRS Message: [
]

+CMTI: "SM",1

GPRS Message: [
+CMTI: "SM",1]
*** SMS Received ***
SMS stored at 1

AT+CMGR=1

GPRS Message: [
AT+CMGR=1]



GPRS Message: [
]

+CMGR: "REC UNREAD","+27764569***","","13/01/11,22:24:02+08"

GPRS Message: [
+CMGR: "REC UNREAD","+27764569***","","13/01/11,22:24:02+08"]



GPRS Message: [
]
*** SMS MESSAGE CONTENT ***


*** END OF SMS MESSAGE ***
ProcessSms for [
]

OK

GPRS Message: [
OK]



GPRS Message: [
]

+CMTI: "SM",2

GPRS Message: [
+CMTI: "SM",2]
*** SMS Received ***
SMS stored at 2

AT+CMGR=2

GPRS Message: [
AT+CMGR=2]



GPRS Message: [
]

+CMGR: "REC UNREAD","+27764569***","","13/01/11,22:04:23+08"

GPRS Message: [
+CMGR: "REC UNREAD","+27764569***","","13/01/11,22:04:23+08"]



GPRS Message: [
]
*** SMS MESSAGE CONTENT ***


*** END OF SMS MESSAGE ***
[/code]
10  Using Arduino / Programming Questions / Re: reading sms on: January 11, 2013, 10:00:16 am
hi sir, not sure if its done correctly but there's my attempt,
yes the data does get corrupted.
Code:
int led = 13;
int onModulePin = 9;        // the pin to switch on the module (without press on button)

int timesToSend = 1;        // Numbers of SMS to send
int count = 0;

int n_sms,x,sms_start;
char data[256];

void switchModule(){
  digitalWrite(onModulePin,HIGH);
  delay(2000);
  digitalWrite(onModulePin,LOW);
}

void setup(){

  Serial.begin(19200);                // UART baud rate
  delay(2000);
  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);
  switchModule();                    // switches the module ON

  for (int i=0;i < 5;i++){
    delay(5000);
  }

  Serial.println("AT+CMGF=1");         // sets the SMS mode to text

  delay(1000);
}

void loop(){


  Serial.println("AT+CMGR=1");    //Reads the first SMS



  x=0;
  do{
    while(Serial.available()==0);
    data[x]=Serial.read(); 
    x++;           
    if(data[x-1]==0x0D&&data[x-2]=='"'){
      x=0;
    }
      if(strcmp(data, "on") == 0)
      Serial.print("data: [");
      Serial.print(data);
      Serial.println("]");
   
  }
  while(!(data[x-1]=='K'&&data[x-2]=='O'));

  data[x-3]='\0';        //finish the string before the OK

  Serial.println(data);    //shows the message


  delay(5000);

}
Code:
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
ÿÿÿÿ]
ÿÿÿÿ
]
ÿÿÿÿ
]
ÿÿÿÿ
R]
ÿÿÿÿ
RD]
ÿÿÿÿ
RDY]
ÿÿÿÿ
RDY
]
ÿÿÿÿ
RDY
]
ÿÿÿÿ
RDY

]
ÿÿÿÿ
RDY

]
ÿÿÿÿ
RDY

+]
ÿÿÿÿ
RDY

+C]
ÿÿÿÿ
RDY

+CF]
ÿÿÿÿ
RDY

+CFU]
ÿÿÿÿ
RDY

+CFUN]
ÿÿÿÿ
RDY

+CFUN:]
ÿÿÿÿ
RDY

+CFUN: ]
ÿÿÿÿ
RDY

+CFUN: 1]
ÿÿÿÿ
RDY

+CFUN: 1
]
ÿÿÿÿ
RDY

+CFUN: 1
]
ÿÿÿÿ
RDY

+CFUN: 1

]
ÿÿÿÿ
RDY

+CFUN: 1

]
ÿÿÿÿ
RDY

+CFUN: 1

+]
ÿÿÿÿ
RDY

+CFUN: 1

+C]
ÿÿÿÿ
RDY

+CFUN: 1

+CP]
ÿÿÿÿ
RDY

+CFUN: 1

+CPI]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN:]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: R]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: RE]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: REA]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

C]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Ca]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Cal]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call R]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Re]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Rea]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Read]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
A]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+C]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CM]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMG]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
A]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+C]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CM]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMG]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
ÿ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
ÿÿ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
ÿÿÿ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
ÿÿÿÿ]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
ÿÿÿÿ]]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
ÿÿÿÿ]
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
ÿÿÿÿ]
]
ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
ÿ]
ÿÿ]
ÿÿÿ]
11  Using Arduino / Programming Questions / Re: reading sms on: January 11, 2013, 08:59:31 am
hi ,been trying to modify the code for many hours but no matter what i add or modify always end up with incorrect readings,tried reading up on strings and used them without any luck,all i have is this perfect code for reading sms's but not been able to use output data,
Code:
int led = 13;
int onModulePin = 9;        // the pin to switch on the module (without press on button)

int timesToSend = 1;        // Numbers of SMS to send
int count = 0;

int n_sms,x,sms_start;
char data[256];

void switchModule(){
    digitalWrite(onModulePin,HIGH);
    delay(2000);
    digitalWrite(onModulePin,LOW);
}

void setup(){

    Serial.begin(19200);                // UART baud rate
    delay(2000);
    pinMode(led, OUTPUT);
    pinMode(onModulePin, OUTPUT);
    switchModule();                    // switches the module ON

    for (int i=0;i < 5;i++){
        delay(5000);
    }

    Serial.println("AT+CMGF=1");         // sets the SMS mode to text
   
    delay(1000);
}

void loop(){
   
   
        Serial.println("AT+CMGR=1");    //Reads the first SMS
         
         
       
        x=0;
        do{
            while(Serial.available()==0);
            data[x]=Serial.read(); 
            x++;           
            if(data[x-1]==0x0D&&data[x-2]=='"'){
                x=0;
            }
        }while(!(data[x-1]=='K'&&data[x-2]=='O'));

        data[x-3]='\0';        //finish the string before the OK

        Serial.println(data);    //shows the message
       

        delay(5000);

}
12  Using Arduino / Programming Questions / Re: reading sms on: January 10, 2013, 10:56:13 am
ok,additions to the code,have to concentrate on reading the serial correctly,
the code continues to check for new sms's but its not in a format i understand and
the module switches itself off after a few minutes,below the output then switches off,
Code:
data: [
NORMAüAT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿÿ]
data: [ÿÿÿ]
data: [ÿÿÿÿ]
data: [ÿÿÿÿ
]
data: [ÿÿÿÿ
]
data: [ÿÿÿÿ
R]
data: [ÿÿÿÿ
RD]
data: [ÿÿÿÿ
RDY]
data: [ÿÿÿÿ
RDY
]
data: [ÿÿÿÿ
RDY
]
data: [ÿÿÿÿ
RDY

]
data: [ÿÿÿÿ
RDY

]
data: [ÿÿÿÿ
RDY

+]
data: [ÿÿÿÿ
RDY

+C]
data: [ÿÿÿÿ
RDY

+CF]
data: [ÿÿÿÿ
RDY

+CFU]
data: [ÿÿÿÿ
RDY

+CFUN]
data: [ÿÿÿÿ
RDY

+CFUN:]
data: [ÿÿÿÿ
RDY

+CFUN: ]
data: [ÿÿÿÿ
RDY

+CFUN: 1]
data: [ÿÿÿÿ
RDY

+CFUN: 1
]
data: [ÿÿÿÿ
RDY

+CFUN: 1
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

]
data: [ÿÿÿÿ
RDY

+CFUN: 1

]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+C]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CP]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPI]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN:]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: ]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: R]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: RE]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: REA]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READ]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

C]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Ca]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Cal]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call ]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call R]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Re]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Rea]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Read]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
A]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+C]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CM]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMG]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
A]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+C]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CM]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMG]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
d]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
da]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
dat]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data:]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: ]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: []
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
d]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
da]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
dat]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data:]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: ]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: []
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿ]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿÿ]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿÿ]]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿÿ]
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿÿ]
]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿÿ]
d]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿÿ]
da]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿÿ]
dat]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]
data: [ÿÿ]
data]
data: [ÿÿÿÿ
RDY

+CFUN: 1

+CPIN: READY

Call Ready
AT+CMGF=1
AT+CMGR=1
data: [ÿ]

sketch
Code:
int led = 13;
int onModulePin = 9;        // the pin to switch on the module (without press on button)

int timesToSend = 1;        // Numbers of SMS to send
int count = 0;

int n_sms,x,sms_start;
char data[256];

void switchModule(){
  digitalWrite(onModulePin,HIGH);
  delay(2000);
  digitalWrite(onModulePin,LOW);
}

void setup(){

  Serial.begin(19200);                // UART baud rate
  delay(2000);
  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);
  switchModule();                    // switches the module ON

  for (int i=0;i < 5;i++){
    delay(5000);
  }

  Serial.println("AT+CMGF=1");         // sets the SMS mode to text

  delay(1000);
}

void loop(){


  Serial.println("AT+CMGR=1");    //Reads incoming sms

  x=0;
  do{
    while(Serial.available()==0);
    data[x++]=Serial.read(); 
    data[ x ] = '\0';
    if(data[x-1]==0x0D&&data[x-2]=='"')
    {
      x=0;
      data[ 0 ] = '\0';
    }
    Serial.print("data: [");
    Serial.print(data);
    Serial.println("]");

  }
  while(!(data[x-1]=='K'&&data[x-2]=='O'));

  data[x-3]='\0';        //finish the string before the OK

  Serial.println(data);    //shows the message


  delay(5000);

}   


13  Using Arduino / Programming Questions / Re: reading sms on: January 10, 2013, 08:40:45 am
with some modifications,seems to read sms and then stops,dont know why the loop stops checkin
Code:
AT+CMGF=1
AT+CMGR=1
data: [
ON
]

]
AT+CMGR=1

Code:
int led = 13;
int onModulePin = 9;        // the pin to switch on the module (without press on button)

int timesToSend = 1;        // Numbers of SMS to send
int count = 0;

int n_sms,x,sms_start;
char data[256];

void switchModule(){
  digitalWrite(onModulePin,HIGH);
  delay(2000);
  digitalWrite(onModulePin,LOW);
}

void setup(){

  Serial.begin(19200);                // UART baud rate
  delay(2000);
  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);
  switchModule();                    // switches the module ON

  for (int i=0;i < 5;i++){
    delay(5000);
  }

  Serial.println("AT+CMGF=1");         // sets the SMS mode to text

  delay(1000);
}

void loop(){


  Serial.println("AT+CMGR=1");    //Reads the incoming SMS's
  


 
  for (x=0;x < 255;x++){            
    data[x]='\0';                        
  }
  x=0;
  do{
    while(Serial.available()==0);
    data[x]=Serial.read();  
    x++;          
    if(data[x-1]==0x0D&&data[x-2]=='"'){
      x=0;
    }
  }
  while(!(data[x-1]=='K'&&data[x-2]=='O'));

  data[x-3]='\0';        //finish the string before the OK
  Serial.print("data: [");
  Serial.print(data);    //shows the message
  Serial.println("]");
  if(strcmp(data, "on") == 0)
  {
    Serial.println("Turning LED on");
    digitalWrite(led,HIGH);
  }
  if(strcmp(data, "off") == 0)
  {
    Serial.println("Turning LED off");
    digitalWrite(led,LOW); // Turn the pin off

   Serial.println("AT+CMGD=1,2"); //Deletes all recieved sms's only

  }    
}    
14  Using Arduino / Programming Questions / Re: reading sms on: January 10, 2013, 08:13:23 am
stops checking after ;
Code:
AT+CMGF=1
AT+CMGR

sketch
Code:
int led = 13;
int onModulePin = 9;        // the pin to switch on the module (without press on button)

int timesToSend = 1;        // Numbers of SMS to send
int count = 0;

int n_sms,x,sms_start;
char data[256];

void switchModule(){
  digitalWrite(onModulePin,HIGH);
  delay(2000);
  digitalWrite(onModulePin,LOW);
}

void setup(){

  Serial.begin(19200);                // UART baud rate
  delay(2000);
  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);
  switchModule();                    // switches the module ON

  for (int i=0;i < 5;i++){
    delay(5000);
  }

  Serial.println("AT+CMGF=1");         // sets the SMS mode to text

  delay(1000);
}

void loop(){


  Serial.println("AT+CMGR=1");    //Reads the first SMS
 


  
  for (x=0;x < 255;x++){            
    data[x]='\0';                        
  }
  x=0;
  do{
    while(Serial.available()==0);
    data[x]=Serial.read();  
    x++;          
    if(data[x-1]==0x0D&&data[x-2]=='"'){
      x=0;
    }
  }
  while(!(data[x-1]=='K'&&data[x-2]=='O'));

  data[x-3]='\0';        //finish the string before the OK
  Serial.print("data: [");
  Serial.print(data);    //shows the message
  Serial.println("]");
  if(strcmp(data, "on") == 0)
  {
    Serial.println("Turning LED on");
    digitalWrite(led,HIGH);
  }
  if(strcmp(data, "off") == 0)
  {
    Serial.println("Turning LED off");
    digitalWrite(led,LOW); // Turn the pin off



  }    
}    
15  Using Arduino / Programming Questions / Re: reading sms on: January 10, 2013, 07:58:37 am
ok,this is my full code,does not loop when checking for sms's,

Code:
int led = 13;
int onModulePin = 9;        // the pin to switch on the module (without press on button)

int timesToSend = 1;        // Numbers of SMS to send
int count = 0;

int n_sms,x,sms_start;
char data[256];

void switchModule(){
  digitalWrite(onModulePin,HIGH);
  delay(2000);
  digitalWrite(onModulePin,LOW);
}

void setup(){

  Serial.begin(19200);                // UART baud rate
  delay(2000);
  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);
  switchModule();                    // switches the module ON

  for (int i=0;i < 5;i++){
    delay(5000);
  }

  Serial.println("AT+CMGF=1");         // sets the SMS mode to text

  delay(1000);
}

void loop(){


  Serial.println("AT+CMGR");    //Reads the first SMS
 


  Serial.flush();
  for (x=0;x < 255;x++){           
    data[x]='\0';                       
  }
  x=0;
  do{
    while(Serial.available()==0);
    data[x]=Serial.read(); 
    x++;           
    if(data[x-1]==0x0D&&data[x-2]=='"'){
      x=0;
    }
  }
  while(!(data[x-1]=='K'&&data[x-2]=='O'));

  data[x-3]='\0';        //finish the string before the OK
   
  Serial.print("data: [");
  Serial.print(data);    //shows the message
  Serial.println("]");
  if(strcmp(data, "on") == 0)
  {
    Serial.println("Turning LED on");
    digitalWrite(led,HIGH);
  }
  if(strcmp(data, "off") == 0)
  {
    Serial.println("Turning LED off");
    digitalWrite(led,LOW); // Turn the pin off



  }   
}     
Pages: [1] 2 3