SIM900 and SIM800 GSM modules provide a set of commands to check the balance of the SIM card. Here they are,
Before you dial a USSD code, you need to enable USSD commands and response notification using the command AT+CUSD=1.
Once you enter AT+CUSD=1 and receive a OK string as response , your USSD command response notification will be enabled and for the next USSD code you enter you will get a response notification.Â
Now in this example  i have used Vodafone SIM card to check the balance. There are two ways to do it,
- #Option 1: Using the standard number *111# and get a USSD response string with multiple options to select, and selecting the balance check in the options.Â
- #Option 2: Using the shortcut number *111*2# and get a direct balance information string as a USSD response.Â
Â
#Option 1 Â :
Â

Enable USSD
Now to check balance using a two step process, you have to first enable the command USSD command response using command AT+CUSD=1 followed by \r\n or carriage return.
– You shoud get a response as OK.Â
Â
Dial the commandÂ
Next dial the USSD code of your respective SIM card, in my case it is *111#, using the command AT+CUSD=1,”*111#” followed by \r\n or carriage return.
– You should get a response as shown in above image. Here the network gives you multiple options to select, like Tariff details or Balance check etc.Â
Â
Dial the selected option numberÂ
In the response above, we need to check balance so we need to dial 2 since it is the corresponding code for checking balance as shown in options.
Select 2 as the next input using the command AT+CUSD=1,”2″Â followed by \r\n or carriage return.
– You will receive response as OK followed by the balance information.Â
Â
#Option 2Â : (Note this might not always work with all network operators)
 
Â
Enable USSD
Now to check balance using the shortcut method, you have to first enable the command USSD command response using command AT+CUSD=1 followed by \r\n or carriage return.
– You should get a response as OK.Â
Â
Dial the commandÂ
Next dial the USSD code of your respective SIM card along with the option value, in my case it is *111*2#, using the command AT+CUSD=1,”*111*2#” followed by \r\n or carriage return.
– You will receive response as OK followed by the balance information.Â
Â
Â
