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.
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!
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
Call me.
Recharge me.
End
So I cant display this message in the virtual terminal.
Please I need help.
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.
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! [/quote] full code please