EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / GSM900A-Having problem with programming

GSM900A-Having problem with programming

|

Microcontroller › Arduino › GSM900A-Having problem with programming

  • This topic has 1 reply, 1 voice, and was last updated 9 years, 3 months ago by Aryan.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • February 28, 2016 at 6:24 pm #4329
    Aryan
    Participant

    I am doing a project in which i need that when i send a particuar msg from my phone to gsm module should return a specific message.

    My variable nam shows that it is equal to "status" in serial monitor, but fail to send me a msg . You can see the code below,pls help if you can . Thanks in advance. :)

    int temp4=0;
    int lenth,lenth1,i=0,temp=0;
     
    String str="";
    String nam="";
    String number="";
     
    String m="Status";  
    void setup() {
     Serial3.begin(9600);    
      Serial.begin(9600);
      Serial3.println("AT+CNMI=2,2,0,0,0");
      Serial3.println("AT+CMGF=1");
      delay(1000);
     
    }
     
      
    void loop()
    {
        while(temp!=0)
       {
         i=0;
         while(i<lenth)
           {
              if(str=='"')
                {
                  temp4++;
                }
                 if(temp4==1)
                     {
                       for(int j=0;j<15;j++)
                          {
                            number+=str;
                            i++;
                          }
                            temp4=2;
                     }
                      if(str=='*')
                       { 
                        i++; 
                         while(str!='#')
                         {
                           nam+=str;
                           i++;
                         }
                       }
                        i++;
          }
        Serial.print(nam);
       if (nam==m)
       {
        
        delay(1000);
        Serial3.println("AT+CMGF=1");    
      Serial3.println("AT+CMGS="+919463617625"r"); 
      Serial3.println("I am SMS from GSM Module");
       Serial3.println((char)26);
      
       }
      
        delay(2000);
        temp=0;
        temp4=0;
        nam="";
        lenth=0;
        str="";
        number="";
        delay(1000);
       }
    }
     void serialEvent3() 
    {
      while (Serial3.available()) 
      {
        char inChar = (char)Serial3.read(); 
        str+=inChar;
         lenth++;
        if (inChar == 'n')
        {      temp=1;  
          inChar=0;     
    }   
    }
    }
     
    March 1, 2016 at 11:50 am #13739
    Aryan
    Participant

    Well after a long time troubleshooting i found that problem was that i was not using delay function after AT commands.

    Working code enjoy :)

    #include<String.h>
    int temp4=0;
    int lenth,lenth1,i=0,temp=0;
     
    String str="";
    String nam="";
    String number="";
     
     
    String m="Status";  
    void setup() {
     
      pinMode (9,OUTPUT);
     Serial3.begin(9600);    
      Serial.begin(9600);
      Serial3.println("AT+CNMI=2,2,0,0,0");
      Serial3.println("AT+CMGF=1");
      delay(100);
     if (Serial3.available()>0)
       Serial.write(Serial3.read());
    }
     
      
    void loop()
    {
        while(temp!=0)
       {
         i=0;
         while(i<lenth)
           {
              if(str=='"')
                {
                  temp4++;
                }
                 if(temp4==1)
                     {
                       for(int j=0;j<15;j++)
                          {
                            number+=str;
                            i++;
                          }
                            temp4=2;
                     }
                      if(str=='*')
                       { 
                        i++; 
                         while(str!='#')
                         {
                           nam+=str;
                           i++;
                         }
                       }
                        i++;
          }
        Serial.print(nam);
       if (nam.compareTo(m)==0)
       {
       
      
       SendMessage();
       }
      
        delay(2000);
        temp=0;
        temp4=0;
        nam="";
        lenth=0;
        str="";
        number="";
        delay(1000);
       }
    }
     void serialEvent3() 
    {
      while (Serial3.available()) 
      {
        char inChar = (char)Serial3.read(); 
        str+=inChar;
         lenth++;
        if (inChar == 'n')
        {      temp=1;  
          inChar=0;     
    }   
    }
    }
     void SendMessage()
    {
      digitalWrite(9,HIGH);
      Serial3.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
      delay(1000);  // Delay of 1000 milli seconds or 1 second
      Serial3.println("AT+CMGS="+918557803648"r"); // Replace x with mobile number
      delay(1000);
      Serial3.println("I am SMS from GSM Module");// The SMS text you want to send
      delay(100);
       Serial3.println((char)26);// ASCII code of CTRL+Z
      delay(100);
    }
     
  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Epson crystal oscillators June 25, 2025
  • Adhesive Defibrillator Pad Cable June 25, 2025
  • Simple LED Analog Clock Idea June 24, 2025
  • Fun with AI and swordfish basic June 24, 2025
  • Microinverters and storeage batteries? June 23, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise