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 / Replies / Working code

Working code

|

Microcontroller › Arduino › GSM900A-Having problem with programming › Working code

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);
}
 

RSS Recent Posts

  • Why aren’t the power windows in my 2006 Volkswagen Polo 2006 working despite repairing the control unit circuit board? May 20, 2026
  • Relay question May 20, 2026
  • Battery discharger May 20, 2026
  • Difference between TTL, RS232 and RS485 May 20, 2026
  • Phone Charger 5v to 12v May 19, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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