Pages: [1]   Go Down
Author Topic: gsm shield explaination. im a trying hard newbie.  (Read 295 times)
0 Members and 1 Guest are viewing this topic.
isabela, philippines.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 62
if you dont go, you will never know.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



Code:
/*
  GSM Send Sketch for Arduino
  
  Initializes GSM Module and sends an SMS to recipient
  
  The circuit:
  *Arduino pin 0 (RX) - GSM Module (TX)
  *Arduino pin 1 (TX) - GSM Module (RX)
  
 
char Rx_data[50];                    
unsigned char Rx_index = 0;        // what does unsigned char Rx_index = 0 means? as you can see the variable "Rx_index" didnt use.
int i = 0;
char msg[160];                          
int sig;                                    // int sig?    the variable "sig" did not used in the program, but if i remove it, its error compiling.

void setup() {
  Serial.begin(38400);                
  
  initGSM();                                  

  send_msg("09166120858", "Hello");  

void loop() {
  //none
}

void send_msg(char *number, char *msg)     // oh my god, i dont understand does codes  . plss god give me the answer
{
  char at_cmgs_cmd[30] = {'\0'};           // what '\0' means?
  char msg1[160] = {'\0'};
  char ctl_z = 0x1A;                            // what is 0x1A         

  sprintf(msg1, "%s%c", msg, ctl_z);
  sprintf(at_cmgs_cmd, "AT+CMGS=\"%s\"\r\n",number);
  
  sendGSM(at_cmgs_cmd);             
  delay(100);
  delay(100);
  delay(100);
  sendGSM(msg1);
  delay(100);
}

void sendGSM(char *string){
  Serial.write(string);
  delay(90);
}

void clearString(char *strArray) {
  int j;
  for (j = 100; j > 0; j--)
    strArray[j] = 0x00;
}

void send_cmd(char *at_cmd, char clr){
  char *stat = '\0';
  while(!stat){
    sendGSM(at_cmd);
    delay(90);
    readSerialString(Rx_data);
    
    stat = strstr(Rx_data, "OK");
  }
  if (clr){
    clearString(Rx_data);
    delay(200);
    stat = '\0';
  }
}

void initGSM(){
  
  send_cmd("AT\r\n",1);
//  send_cmd("ATE0\r\n",1);              // Turn off automatic echo of the GSM Module // what is automatic echo?

  send_cmd("AT+CMGF=1\r\n",1); // Set message format to text mode
  //Sucess
  
  Serial.println("Success");

  delay(1000);
  delay(1000);
  delay(1000);
}

void readSerialString (char *strArray) {
  
  if(!Serial.available()) {
    return;
  }
  
  while(Serial.available()) {
    strArray[i] = Serial.read();
    i++;
  }
}

« Last Edit: January 18, 2013, 07:54:18 am by jaylisto » Logged

jaylisto

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12520
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what the **** do this mean?...

Nothing. The entire code is commented out and the file may as well be empty as far as the compiler is concerned.

Perhaps you meant to close the comment at the end of the header?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 201
Posts: 8653
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.cplusplus.com/doc/tutorial/functions/

This will teach you about function calls.


http://arduino.cc/en/Reference/HomePage

Under "Data Types" read everything, particularly 'array'.

Under "Communication" read "Serial".
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

isabela, philippines.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 62
if you dont go, you will never know.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.cplusplus.com/doc/tutorial/functions/

This will teach you about function calls.


http://arduino.cc/en/Reference/HomePage

Under "Data Types" read everything, particularly 'array'.

Under "Communication" read "Serial".

oooowwww, brilliant!. your link answered some of my questions. you are genius. this codes only sends a message to my number, then what about if i send a message to the gsm shield making the led13 turns on? hopefully you can add a function that can do that.. i hope you know that..
Logged

jaylisto

isabela, philippines.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 62
if you dont go, you will never know.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


the code and questions updated.... since other questions are answered by the links.

pls help for the remaining question .  may God helps me too. still praying.
Logged

jaylisto

Pages: [1]   Go Up
Jump to: