Balance of GSM USB Modem using USSD

Are there some tools or commands I can use to send USSD codes for checking balance and data balance of the GSM SIM Card in my USB modem (Mobile broadband dongle)?


These are some Apps with USSD balance check support:

Prepaid Manager

Prepaid Manager

Prepaid Manager is an applet for the GNOME Desktop that allows you to check and top up the balance of GSM mobile prepaid SIM cards. It is a simple and minimalistic app with USSD balance check and topup being all that it does. But on the flip side, it is a very dated application and haven't received any new updates in a long time. And if your provider isn't supported, you'll have to manually configure it as described on their homepage. To install, click here:

Prepaid Manager App on Ubuntu Software

Or run the following command:

sudo apt install prepaid-manager-applet

Modem Manager GUI

Modem Manager GUI

Modem Manager GUI is a complete solution to manage and monitor mobile network based modems. It packs quite a lot of features, and USSD support is just one of them. For a complete list of features, visit their official homepage. To install, click here:

Modem Manager GUI App on Ubuntu Software

Or run the following command:

sudo apt install modem-manager-gui

V Mobile Broadband

V Mobile Broadband

V Mobile Broadband is the original Vodafone Mobile Connect software for Linux rewritten to be compatible with Network Manager by Vodafone's open source Betavine Connection Manager team. Unfortunately, it doesn't seem to be very actively maintained at the moment and isn't available in Ubuntu repos. However, you may try your luck building the project from source. Check out their GitHub page.

Warning: v-mobile-broadband depends on wader, which replaces Ubuntu's default modemmanager. So, if you encounter problems with the new setup and decide to uninstall v-mobile-broadband, don't forget to reinstall modemmanager package.


Sources

  • In Ubuntu, is there an application like “Huawei Mobile Partner” for broadband dongle modems?

You can use the command-line utility gammu for this purpose. If the USSD code to get your balance is (say) *901#, you would execute:

gammu getussd "*901#"

For installation and configuration instructions and more details, see here.


You can use AT commands directly to query your balance via USSD. For that, use any serial terminal program that lets you communicate with your modem directly (putty, minicom etc.).

I chose atinout because it integrated nicely with the command line. First you install it:

sudo apt-get install ruby-ronn;
git clone git://git.code.sf.net/p/atinout/code atinout;
cd atinout;
make;
sudo checkinstall make install;

Then, if you use ModemManager (the default under Ubuntu Linux), you might have to disable it first to allow atinout to access your modem:

sudo stop modemmanager;

Now, to send a USSD code for balance query to the network (say, *901#) and display the result, you would use this command:

atinout - /dev/ttyUSB1 - < <(echo "AT+CUSD=1,\"*901#\",15") && sleep 4 && \
atinout - /dev/ttyUSB1 - < <(echo "AT");

This assumes that your modem is at /dev/ttyUSB1. The AT command in the second atinout command is just to get the unsolicited USSD answer displayed as a side effect, which should have arrived after the sleep.

For the case that querying your balance requires operating a USSD menu: this is also possible with atinout, see this answer.


You can do them with the package modem-manager-gui. But it is only available for 13.10. In other versions you have to manage them in Terminal with the package modemmanager.

If you are in Ubuntu 13.10:

sudo apt-get install modem-manager-gui modemmanager

In other versions of Ubuntu you can do it with the application prepaid-manager-applet

sudo apt-get install prepaid-manager-applet