I am trying to run a simple program using Arduino UNO and SIM900A GSM module, which will receive a digit in text message and if the comparison is valid then the pin no. 12 should be high (Led connected on the PIN).
Issue: i see the GSM module getting initialized for receiving, i even see the messages i sent on the serial monitor, but the data sent seems to be unprocessed since there is no change in any pins values, nor anything is printed on the serial monitor.
#include <SoftwareSerial.h>
//use TX to 9 and RX to 10
SoftwareSerial mySerial(9, 10);
int ledRED = 12;
void setup()
{
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
pinMode(ledRED,OUTPUT);
ReceiveMessage();
}
void loop()
{
if (mySerial.available()>0)
Serial.write(mySerial.read());
storeData();
}
void ReceiveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000);
mySerial.println("GSM SUCCESSFULLY CONFIGURED FOR RECEIVING");
}
void storeData()
{
while (Serial.available())
{
int inNo = Serial.read();
if(inNo=='3')
{
digitalWrite(ledRED,1); // making Pin 12 high if data received is 'C'
mySerial.println("RED ON"); // printing the same on the Serial monitor
}
}
}
Can anyone please look at the code and determine what is wrong here and help me fix it.
Thanx in Advance.