Go Down

Topic: USSD code and response (Read 3413 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.

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