Go Down

Topic: USSD code and response (Read 4729 times) previous topic - next topic

bule

How to send: AT+CUSD=1,"*121#"
And I get this response:+CUSD: 2,"Stanje na Vasem racunu je 1.00 din. Kredit mozete dopuniti do 18.06.2014. Pozovite *111# i proverite koja vas ponuda ceka.",15

I need to extract text and forward to number who sent request.

mlbraga82

Hi Bule!
I'm doing a project to turn on/off a desktop computer by SMS and I needed know how to send a USSD message and read the response. My solution is :

Using a GSM library: (SIM900)

          gsm.SimpleWriteln(F("AT+CUSD=1,\"*121#\""));   //sending AT+CUSD=1,"*121#"
          delay(5000);
          char resp[100];
          gsm.read(resp, 100); //this command will send the response to the serial port and, at the same time, copy to "resp" string
          Serial.println(resp);

You can split the string using something like that:

int i=5;   //begin of string split =5, in this case
char newString[ ];
do{
   newString=resp;
   i++;
} while (i<20);  // End of string split =20, in this case

Then, now you have a newString with a text that you want.

I hope that will be usefull.

Regards!


ricardorams

Hi!
I am tested your code, but it doesn't work very well. I have an arduino Mega, and my code is

#include "SIM900.h"
#include "SoftwareSerial.h"
#include "inetGSM.h";

int i=0;
InetGSM inet;
char state[50], msg[50], resp[40], newString[33];
int numdata;
int flag=0;   


void setup()
{
gsm.SimpleWriteln("AT+CUSD=1,\"*120#\"");   //sending AT+CUSD=1,"*121#"
          delay(5000);
          char resp[100];
          gsm.read(resp, 100); //this command will send the response to the serial port and, at the same time, copy to "resp" string
          Serial.println(resp);
}

void loop() {
int i=5;   //begin of string split =5, in this case
char newString[50];
do{
   i++;
 } while (i<20);  // End of string split =20, in this case
}

I changed the pins in SIM900.h to send a receive the signals between arduino mega and shield sim900.

I opened the virtual terminal, but I cant receive the ussd message. I am in Ecuador, so if you send this message in your  cellphone, you receive this text
1. Call me.
2. Recharge me.
3. End
So I cant display this message in the virtual terminal.
Please I need help.

avanmedia

hi my friends
you know , when you send an at command to sim900 or 908 , it response you with an specific answer, so here you wana send a message to the number who has sent a message to you.
first you should read last sms:
--> AT+CMGR=1
SIM900 response you with a long string like this :
+CMGD: etc.
in this response you can see the number like : +98916....
i tested it with atmega8 and the number starts from 22th character

code in bascom:

N2 = 1
N3 = 1
Print "AT+CMGR=1"
Do
V = Waitkey()
N2 = N2 + 1                                                 '
X(n2) = V


Loop Until N2 = 18



If Chr(v) = "+" Then

Do

U(n3) = Waitkey()

N3 = N3 + 1

Loop Until N3 = 67
End If

For I = 22 To 31
   In_number = In_number + Chr(u(i))
Next I


then you can send your CUSD response to in_number.

hope it be useful.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy