The logic is quite simple, We just look for consecutive occurrence of commads like @C1, @C2 or CMD. Whenever the if condition is satisfied the code can take an action like turning ON or OFF a device which might be useful in building automation application for example.
This code is applicable for SIM800,SIM808,SIM908,SIM800C,SIM800H,SIM900A etc all modules as AT commands remain the same.
For more in depth explanation of the concept or live demo look at this video,
ARDUINO CODE:
unsigned char Buff[250]; unsigned char BuffIndex; void setup() { Serial.begin(9600); Serial.println("GSM Tutorial, Valetron Systems @www.raviyp.com "); delay(3000); Serial.println("AT+CMGF=1"); delay(3000); Serial.println("AT+CNMI=2,2,0,0,0"); memset(Buff, ' ', 250); // Initialize the string BuffIndex=5; } void loop() { while(1) { if(Serial.available()>0) { Buff[BuffIndex] = Serial.read(); if( (Buff[BuffIndex-2] == '@') && (Buff[BuffIndex-1] == 'C') && (Buff[BuffIndex] == '1')) { Serial.println("Command 1"); } if( (Buff[BuffIndex-2] == '@') && (Buff[BuffIndex-1] == 'C') && (Buff[BuffIndex] == '2')) { Serial.println("Command 2"); } if( (Buff[BuffIndex-2] == 'C') && (Buff[BuffIndex-1] == 'M') && (Buff[BuffIndex] == 'D')) { Serial.println("Command CMD"); } BuffIndex++; if(BuffIndex>250) { BuffIndex=5; } } } }
Also see:
- SIM800 series Bluetooth AT commands
- Footprint compatible 2G, 3G, 4G modules for using in your M2M designs
- 868 MHz frequency is not license free in India – LoRa in India
- SIM900/SIM800 not working – Possible reasons – Tips n Tricks