Are you wondering how to check the SIM card balance using USSD code using AT commands, You have come to the right place. This post is about showing how to use USSD code in SIM900 or SIM800 GSM modules.

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. 

 

 




About the Author

is the author of this blog and is an Embedded systems design engineer by profession & Founder @ Valetron Systems Pvt Ltd


Email:This email address is being protected from spambots. You need JavaScript enabled to view it.

Find us on Google+

HIRE ME FOR YOUR PROJECT AS A FREELANCER

 

EasyEDA: Free Circuit Design Software

  • Easy Schematic Capture
  • Powerful Circuit Simulation
  • Online PCB design

Design Your Circuit and PCB here:

https://easyeda.com/editor

Cheap PCB Manufacturing

Electronic Components Online Store