hello
how to use AT+CUSD to check balance ???
AT+CUSD command question
Moderator: Benj
AT+CUSD command question
Last edited by EtsDriver on Mon Mar 12, 2018 7:18 am, edited 1 time in total.
Reason: SPLITTED FROM Send and receive serial data via GSM
Reason: SPLITTED FROM Send and receive serial data via GSM
-
- Posts: 444
- Joined: Tue Apr 15, 2014 4:19 pm
- Location: Kajaani, Finland
- Has thanked: 345 times
- Been thanked: 227 times
- Contact:
Re: AT+CUSD command question
Hi and welcome to forums.
The AT+CUSD will work only if SIM supports it.
Firstly, if you put your SIM card into phone and there is new option in menu that has SIM card logo or similar, this is the menu you want to get to using the AT+CUSD commands. If the menu is not availabe, AT+CUSD is most likely not then the option.
Some SIM providers dont provide it and you must then use regular SMS to get the balance. (Like in here, most operators accept messages like "SALDO" "TOTAL" "BAL" "BALANCE" and send you back a SMS containing the balance information).
To check balance with AT+CUSD you must first send enable USSD AT command to modem using SendCommand.
This will enable your USSD services/features on the SIM card.
If you receive message "OK" from modem, you may now get the menu options. Replace the CODE with your operators USSD code for the SIM card.
You get response like:
After that you select your correct menu option;
And return should contain the message what provides balance.
PS.
You may try what kind code your device accepts. In the old days, the Service Provider gave a list of these provided with the SIM card (the little book that people throw away). Some providers provide list on their website on the codes (mobile menu code).
And here in Finland, Telia provides the little booklet as pdf, and it seems to no more have the codes as the USSD:s are dying out on the cards. Only using text message you can get your balance it seems. :/
The AT+CUSD will work only if SIM supports it.
Firstly, if you put your SIM card into phone and there is new option in menu that has SIM card logo or similar, this is the menu you want to get to using the AT+CUSD commands. If the menu is not availabe, AT+CUSD is most likely not then the option.
Some SIM providers dont provide it and you must then use regular SMS to get the balance. (Like in here, most operators accept messages like "SALDO" "TOTAL" "BAL" "BALANCE" and send you back a SMS containing the balance information).
To check balance with AT+CUSD you must first send enable USSD AT command to modem using SendCommand.
Code: Select all
AT+CUSD=1
This will enable your USSD services/features on the SIM card.
If you receive message "OK" from modem, you may now get the menu options. Replace the CODE with your operators USSD code for the SIM card.
Code: Select all
AT+CUSD=1,"<CODE>"
You get response like:
Code: Select all
+CUSD: 1, "1. Load more balance.2.Check balance.3.Customer service number.",64
After that you select your correct menu option;
Code: Select all
AT+CUSD=1,"<OPTION>"
Code: Select all
+CUSD: 1, "Your balance on <today> is 0 EUR. In this month, you have used calls 750 minutes, sent 1.2Million text messages, driven to moon and back with your car and got old milk carton in your fridge.",64
You may try what kind code your device accepts. In the old days, the Service Provider gave a list of these provided with the SIM card (the little book that people throw away). Some providers provide list on their website on the codes (mobile menu code).
And here in Finland, Telia provides the little booklet as pdf, and it seems to no more have the codes as the USSD:s are dying out on the cards. Only using text message you can get your balance it seems. :/
Ill just keep the good work up!
Re: AT+CUSD command question
thanks
but i want to know how extract the balance from the string i received ?? in flowcode
but i want to know how extract the balance from the string i received ?? in flowcode
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: AT+CUSD command question
Can you give us an example of the string you receive and we should be able to help you parse the numeric balance from that.
Probably something like parse through until you get a character in the range of '0' to '9' and then from there using a standard string to float type conversion routine.
Here's a simple example to collect a numeric value contained in a string into a sub string. You can then call the String to Float function if you need the value as a numeric variable.
Probably something like parse through until you get a character in the range of '0' to '9' and then from there using a standard string to float type conversion routine.
Here's a simple example to collect a numeric value contained in a string into a sub string. You can then call the String to Float function if you need the value as a numeric variable.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: AT+CUSD command question
i want to check balance by sensing message to gsm and the gsm send to my phone number the account balance
we use "AT+CUSD=1,\"*211#\""
but when i use receive string eblocks the string show me OK only
but in really it contain +CUSD "your balance is 209IQD .... " after one line
how can i extract that line contain +CUSD .... ??
we use "AT+CUSD=1,\"*211#\""
but when i use receive string eblocks the string show me OK only
but in really it contain +CUSD "your balance is 209IQD .... " after one line
how can i extract that line contain +CUSD .... ??
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: AT+CUSD command question
Hello,
ReceiveString will read up to a new line character, maybe call the function a second time to collect the next part of the reply.
ReceiveString will read up to a new line character, maybe call the function a second time to collect the next part of the reply.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel