The serial monitor displays OK after the AT command for checking airtime balance and begins displaying "+C" and gets stuck just there.It does not continue to display the airtime balance.I am using an arduino Uno.
//Include Library because we are using digital pins for connection
#include <SoftwareSerial.h>
#include "SIM900.h"
/Initializing digital pins for connection to serve as Rx and Tx
Rx pin is 7 and Tx pin is 8/
SoftwareSerial SIM900(7, 8 );
//Variable for storing incoming messsages content
char incoming_char=0;
//Variable to store airtime balance string
char airtime;
void setup()
{
// initialize digital pin 13 as an output
pinMode(13, OUTPUT);
// Baudrate for serial monitor
Serial.begin(19200);
//Baudrate for GSM shield
SIM900.begin(19200);
// Give time to log on to network.
delay(20000);
// Turn the LED on (HIGH is the voltage level)
digitalWrite(13, HIGH);
delay(100);
// Set SMS mode to text for GSM MODULE
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(100);
//Change Character Set to GSM
//SIM900.print("AT+CSCS="GSM"\r");
//AT command to check airtime balance
SIM900.println("AT+CUSD=1,"*124#"\r");
delay(100);
}
void loop()
{
//Send Message function intialization
// SendMessage();
// Now we simply display any text that the GSM shield sends out on the serial monitor
if(SIM900.available() >0)
{
//Get the character from the cellular serial port.
incoming_char=SIM900.read();
//Print the incoming character to the terminal.
Serial.print(incoming_char);
delay(1000);
}
}
//Function to SMS based on airtime status
void SendMessage(){
//Change Character Set to GSM
SIM900.print("AT+CSCS="GSM"\r");
//Storing credit balance details in airtime variable
airtime = SIM900.print("AT+CUSD=1,"*124#"\r");
//Conditional Statement for credit balance
if (airtime < 1.00){
//Turn the LED on (LOW is the voltage level)
digitalWrite(13, LOW);
delay(1000);
//Sets the GSM Module in text mode
SIM900.print("AT+CMGF=1\r");
//Delay of 100 milli seconds
delay(100);
//Phone number to send SMS
SIM900.print("AT+CMGS="+233246692584"\r");
delay(100);
//The SMS text you want to send
SIM900.print("Your a/c is Below GHC1.00,You have been DISCONNECTED !! ");
delay(100);
//ASCII code of CTRL+Z
SIM900.print((char)26);
delay(100);
}
else {
//Sets the GSM Module in text mode
SIM900.print("AT+CMGF=1\r");
//Delay of 100 milli seconds
delay(100);
//Phone number to send SMS
SIM900.print("AT+CMGS="+233246692584"\r");
delay(100);
//The SMS text you want to send
SIM900.print("Your a/c is Above GHC1.00,You are CONNECTED !! ");
delay(100);
//ASCII code of CTRL+Z
SIM900.print((char)26);
delay(100);
}
}