Hello,
I would like someone to help me with the Gsm 900A code.
I am trying to save the incoming messages content in a variable, so I could then take an action due to the message.
Here is the code, I could not continue from here:
// Including Libraries
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);
unsigned char Text[300];
int count = 0;
void setup() {
// Setup Serial Bode Rate
Serial.begin(9600);
mySerial.begin(9600);
RecieveMessage();
}
void loop() {
while(mySerial.available())
{
Text[count++] = mySerial.read();
if (count == 300)
{break;
count=0;}
}
Serial.write(Text,300);
//delay(200);
cleartext();
}
void cleartext(){
for(int i = 0; i<count; i++)
Text[i] = 0;
}
void SendMessage()
{
mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"+218917495294\"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
void RecieveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000);
}