Forum >Replies by wahmalik85
userhead wahmalik85
Replies (15)
  • You Reply: Thank you Grey,

    I did not think of this before ^______^
  • You Reply: why there is no answer?
    :(
  • You Reply: up!!!
  • You Reply: Thank you Jose for your replaying.

    I can connect to GPRS successfully in my office, but when I go out by car to different locations, some locations the signal goes out and it is stop sending data.
    So I need sometimes to reconnect automatically without resetting the module.

    best wishes;
  • You Reply: no answer :(

    I have problem of losing GSM/GPRS connection, is there any suggestions to solve this problem?
    How I can to reconnect again?
  • You Reply: [quote="Jose"]
    let me know if you can keep the GPS while GPRS or SMS is enable without cold resetting.
    I'll give it a go in my side.
    [/quote]

    Yes, I get the GPS coordinates and send them to SMS and GPRS without resetting between GPS and GSM.

    ^_^

    best regards.
  • You Reply: Hi,

    I found 2 problems I faced.
    1- I missed to type double quote (") before ** and after.
    what I did is:
    Code: Select all
    Serial.println("777xxxxxx");
    the right is:
    Code: Select all
    Serial.println("\"777xxxxxx\"");
    2- the buffer size of serial was to small (64), so I can not send more than 64 character to the Module, so the AT command considered not complete.
    the result would be like:
    Code: Select all
    +CMS ERROR: 302
    :)
  • You Reply: Here is the code:
    Code: Select all
    
    #include <Arduino.h>
    #include <Wire.h>
    
    
    char aux_str[30];
    char aux;
    
    char latitude[15];
    char longitude[15];
    
    char inChar;
    int index;
    char inData[200];
    
    
    char par1 [20];
    char par2 [20];
    char par3 [20];
    char par4 [20];
    char par5 [20];
    char par6 [20];
    
    int loop_no = 0;
    
    /****************************************************************SMS********************/
    char phone_no[20];
    char inSMS[200];
    
    boolean msgFound = false;
    /**************************************************************************************/
    
    void setup()
     {
       
       //Init the driver pins for GSM function
        pinMode(3,OUTPUT);
        pinMode(4,OUTPUT);
        pinMode(5,OUTPUT);
       //Output GSM Timing 
        digitalWrite(5,HIGH);
        delay(1500);
        digitalWrite(5,LOW); 
        
        // Use these commands instead of the hardware switch 'UART select' in order to enable each mode
        // If you want to use both GMS and GPS. enable the required one in your code and disable the other one for each access.
        digitalWrite(3,LOW);//enable GSM TX?RX
        digitalWrite(4,HIGH);//disable GPS TX?RX
        delay(2000);
        Serial.begin(9600);
        
        delay(5000);//call ready
        delay(5000);
        delay(5000);
        
        
        start_GSM();
        
        delay(5000);
        
        start_GPS();
      
        delay(500);
        
     }
     void loop()    
     {    
       
       
       read_GPS();
       delay(2000);
       /****************************************************************SMS*******************/
       SendReadSMSComm();
       
       if(msgFound)
        {
          //Serial.println("message will be send");
          sendSMS();
          delay(1000);
          DeleteAllMSGs();
        }
       /**************************************************************************************/
       if(loop_no > 0 )
       {
         send_GPRS();
       }else{
         loop_no ++;
       }
       delay(15000);
       msgFound = false;
    
     }
    
    
    /****************************************************************SMS********************/
    
     void SendReadSMSComm()
     {
         Serial.println("AT");
         delay(1000);
         Serial.println("AT+CMGR=1");
         delay(3000);
         readSMS();
         strtok(inSMS, ",");
         strcpy(phone_no,strtok(NULL, ",")); // Gets **
         printBuff();
     }
     void readSMS()
     {
       index=0;
       while(Serial.available() > 0) // Don't read unless
                                                      // there you know there is data
       {
         if(index < 199) // One less than the size of the array
         {
           inChar = Serial.read(); // Read a character
           
           inSMS[index] = inChar; // Store it
           index++; // Increment where to write next
           inSMS[index] = '\0'; // Null terminate the string
         }
       }
       
       if(index > 20)
       {
          msgFound = true;
       }else{
         msgFound = false;
       }
     }
     
     
     void DeleteAllMSGs()
     {
          Serial.println("AT");
          delay(1000);
          Serial.println("AT+CMGD=1,4");
          delay(5000);
          printBuff();
     }
     
     void sendSMS()
     {
        Serial.println("AT");
        delay(1000);
        //Send message
        Serial.println("AT+CMGF=1");
        delay(1000);
        Serial.print("AT+CMGS=");//Change the receiver **
        Serial.println("777xxxxxx");
        delay(1000);
        Serial.print("lat=");//the message you want to send
        Serial.print(latitude);
        Serial.print(",lon=");
        Serial.print(longitude);
        delay(1000);
        Serial.write(26);
        delay(1000);
        Serial.println();
        printBuff();
     }
     
     /**********************************************************************************/
     
     void start_GSM(){
         //Configuracion GPRS Claro Argentina
        Serial.println("AT");
        delay(2000);
        //printBuff();
        Serial.println("AT+CREG?");
        delay(2000);
        //printBuff();
        Serial.println("AT+SAPBR=3,1,\"APN\",\"Fast-Internet\"");
        delay(2000);
        //printBuff();
        Serial.println("AT+SAPBR=3,1,\"USER\",\"net\"");
        delay(2000);
        //printBuff();
        Serial.println("AT+SAPBR=3,1,\"PWD\",\"net\"");
        delay(2000);
        //printBuff();
        Serial.println("AT+SAPBR=3,1,\"Contype\",\"GPRS\"");
        delay(2000);
        //printBuff();
        Serial.println("AT+SAPBR=1,1");
        delay(10000);
        //printBuff();
        Serial.println("AT+HTTPINIT");
        delay(2000);
        //printBuff();
        Serial.println("AT+HTTPPARA=\"CID\",1");
        delay(2000);
        //printBuff();
        clearBuff();
       
     }
     
     void send_GPRS(){
              
       
              
              
              Serial.print("AT+HTTPPARA=\"URL\",\"xxxxx.com/gps/geo2_1.php?lat=");
              Serial.print(latitude);
              
              Serial.print("&lon=");
              Serial.print(longitude);
              
              Serial.print("&par1=");
              Serial.print(par1);
              
              Serial.print("&par2=");
              Serial.print(par2);
              
              Serial.print("&par3=");
              //Serial.print("ok");
              Serial.print(par3);
              
              Serial.print("&par4=");
              //Serial.print("3555");
              Serial.print(par4);
              
              Serial.print("&par5=");
              //Serial.print("50251");
              Serial.print(par5);
              
              Serial.print("&par6=");
              //Serial.print("0.001");
              Serial.print(par6);
              
              
    
              Serial.println("\"");
              delay(2000);
              //waitTillResp();
              Serial.println("AT+HTTPACTION=0"); //now GET action
              delay(2000);
              
              //waitTillResp();
              clearBuff();
     }
     
     
     void start_GPS(){
         //Configuracion en Inicializacion GPS
        Serial.println("AT");
        delay(1000);
        Serial.println("AT+CGPSIPR=9600");// (set the baud rate)
        delay(1000);
        Serial.println("AT+CGPSPWR=1"); // ?turn on GPS power supply?
        delay(1000);
        Serial.println("AT+CGPSRST=1"); //?reset GPS in autonomy mode?
        delay(10000); //delay para esperar señal del GPS
     }
     
     void read_GPS(){
        
        
        Serial.println("AT+CGPSINF=0");
        //printBuff();
        
        read_String();
        
        
        strtok(inData, ",");
        
        strcpy(longitude,strtok(NULL, ",")); // Gets longitude
        strcpy(latitude,strtok(NULL, ",")); // Gets latitude
        strcpy(par1,strtok(NULL, ",")); 
        strcpy(par2,strtok(NULL, ",")); 
        strcpy(par3,strtok(NULL, ",")); 
        strcpy(par4,strtok(NULL, ",")); 
        strcpy(par5,strtok(NULL, ",")); 
        strcpy(par6,strtok(NULL, ",")); 
        
        convert2Degrees(latitude);
        convert2Degrees(longitude);
     }
     
      
     
     void read_String() {
          index=0;
          
          while(Serial.available() > 0) // Don't read unless
                                                      // there you know there is data
       {
           if(index < 199) // One less than the size of the array
           {
               inChar = Serial.read(); // Read a character
               inData[index] = inChar; // Store it
               index++; // Increment where to write next
               inData[index] = '\0'; // Null terminate the string
           }
       }
     }
     
     int8_t convert2Degrees(char* input){
    
        float deg;
        float minutes;
        boolean neg = false;    
    
        //auxiliar variable
        char aux[10];
    
        if (input[0] == '-')
        {
            neg = true;
            strcpy(aux, strtok(input**, "."));
    
        }
        else
        {
            strcpy(aux, strtok(input, "."));
        }
    
        // convert string to integer and add it to final float variable
        deg = atof(aux);
    
        strcpy(aux, strtok(NULL, '\0'));
        minutes=atof(aux);
        minutes/=1000000;
        if (deg < 100)
        {
            minutes += deg;
            deg = 0;
        }
        else
        {
            minutes += int(deg) % 100;
            deg = int(deg) / 100;    
        }
    
        // add minutes to degrees 
        deg=deg+minutes/60;
    
    
        if (neg == true)
        {
            deg*=-1.0;
        }
    
        neg = false;
    
        if( deg < 0 ){
            neg = true;
            deg*=-1;
        }
        
        float numeroFloat=deg; 
        int parteEntera[10];
        int cifra; 
        long numero=(long)numeroFloat;  
        int size=0;
        
        while(1){
            size=size**;
            cifra=numero%10;
            numero=numero/10;
            parteEntera[size-1]=cifra; 
            if (numero==0){
                break;
            }
        }
       
        int indice=0;
        if( neg ){
            indice++;
            input[0]='-';
        }
        for (int i=size-1; i >= 0; i--)
        {
            input[indice]=parteEntera[i]+'0'; 
            indice++;
        }
    
        input[indice]='.';
        indice++;
    
        numeroFloat=(numeroFloat-(int)numeroFloat);
        for (int i=1; i<=6 ; i++)
        {
            numeroFloat=numeroFloat*10;
            cifra= (long)numeroFloat;          
            numeroFloat=numeroFloat-cifra;
            input[indice]=char(cifra)+48;
            indice++;
        }
        input[indice]='\0';
    
    
    }
     
     /*****************************/
     void clearBuff(){
       while( Serial.available() > 0) 
          {
            Serial.read();    // Clean the input buffer
          }
     }
     
     
    void printBuff()
    {
        delay(1000);
        while( Serial.available() > 0) 
        {
          Serial.print((char)Serial.read());
          
        }
         Serial.println("");
        delay(1000);
        clearBuff();
    }
    
    
    void waitTillResp(){
       int d = 0;
       while(Serial.available() < 1 && d != 10){
         delay(1000);
         d++;
       }
       printBuff();
    }
    
  • You Reply: Thank you Jose,

    I increased the buffer size to 128 and I get the full message.
  • You Reply: [quote="Jose"]
    I believe this is is caused because the shield is already initialized. Try to reset the shield once before using it and waiting for the LEDs to shut down.
    [/quote]

    The tool work now after yours note, thank you.

    [quote="Jose"]
    As for the message, I am thinking.. Could it be because the Serial buffer is full?
    Do you get the whole list when manually inputting the AT commands?
    [/quote]

    from the tool, all 3 messages were read successfully, so is the problem from the serial buffer size?

    I deleted 2 messages and left one message on the inbox and the problem still occurred.
  • You Reply: Thank you Jose for your replay.

    I tried the tool, and it couldn't to connect with the Arduino.
    Code: Select all
    Sending AT query..
     
    
    Invalid or no response from the device. Please check the modem port and the baud rate.Disconnecting port COM4.
    
    There are more than 2 messages in the inbox but what I get from the serial is what I mention before.
    The output corrupted before the message body.

  • You Reply: ammm, Thank you for your replay.
  • You Reply: Hi all,

    I included the library of SoftwareSerial.h in OBD.cpp file:

    [code]#include <Arduino.h>
    #include <avr/pgmspace.h>
    #include <SoftwareSerial.h>

    SoftwareSerial mySerial(10, 11); // RX, TX

    #include "OBD.h"[/code]

    and modified the original serial of uno to software serial in OBD.h file in the line 17

    [code]#ifndef OBDUART
    #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega644P__)
    #define OBDUART Serial1
    #else
    #define OBDUART mySerial
    #endif
    #endif[/code]

    and it complied successfully.
    But when I attach the OBD adapter to software serial, the communication between OBD adapter and Arduino is faild and stuck on  this loop:

    [code]// initiate OBD-II connection until success
        while (!obd.init()); [/code]

    is there any solution for this?

    thank you.
  • You Reply: Thank you Grey.

    There is no local store/shop to sell these stuff in my city, so I buy these stuff from the internet store like dfrobot  :) .

    next time I'll ask for it.

    Thank you again.
  • You Reply: Thank you Jose for your replying.

    I increase the power from 7 volts to 12 volts, and it is worked now with some issues.
    I upload the sketch for making call from arduino, and it is worked, but sometimes the STATS led light on and the board does not make the call, when I make a call from my cell phone to the SIM card on the module, I get that ** may be off or out the coverage area. I reset the board many times until it work again.

    I notice that I must make 2 reset, first one will make STATS LED off, the second one will make the STATS LED on.

    When I upload the sketch of driving the gsm mode via the USB interface, the module work correctly but I cant send AT commands through Serial Monitor or CoolTerm tool, it return nothing in Serial Monitor, in CoolTerm just Dots appear in the screen and nothing else.