This is what is displayed on the serial monitor and how do i store the airtime balance message into a variable and send it as a message to another number
AT+CMGF=1
OK
AT+CNMI=2,2,0,0,0
OK
AT+CSCS="GSM"
OK
AT+
+CUSD: 0,"Your a/c is GHC1.95,SMS Bonus is 0.00GHC,Bonus a/c is 2.00GHC,IDD Bundle is 0.00GHC,BOR a/c 0.00GHC,Data Bonus is 0.00MB.internet bundle is 0.00MB.
This is the actual code
//Include Library because we are using digital pins for connection
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;
/*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
int 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");
delay(100);
//AT command to check airtime balance
SIM900.print("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);
}
}
//Function to SMS based on airtime status
void SendMessage(){
//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);
//Print on serial monitor
Serial.println("\n SMS Sent");
//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);
//Print on serial monitor
Serial.println("\n SMS Sent");
//ASCII code of CTRL+Z
SIM900.print((char)26);
delay(100);
}
}