Sending SMS using a Old sony phone

Trying to use Arduino mega 1280 to send AT command so that the Sony phone can send sms to alert another user .

#define num_to_char(number) ((number) < 10 ?
('0' + (number)) :
(('A' - 10) + (number)) )

#define first_four(byte) (0x0F & (byte))
#define last_four(byte) ((0xF0 & (byte)) >> 4)
#define hexdump_a(byte) num_to_char( last_four(byte))
#define hexdump_b(byte) num_to_char(first_four(byte))

int timesToSend = 1;
int count = 0;

void setup(){

Serial.begin(9600); // the GPRS baud rate

}

void loop(){

while (count < timesToSend){
send_sms("Hello World");

count++;
}
}

void hexdump_byte(unsigned char byte)
{
Serial.print(hexdump_a(byte), BYTE);
Serial.print(hexdump_b(byte), BYTE);
}

void send_sms(char *data)
{
size_t data_length, x;
char c, l;
long i;
long n;

data_length = strlen(data);
i = data_length * 7;

if (i & 0x07) i = (i & ~0x07) + 0x08;

i = i / 8;

Serial.println("AT+CMGF=0");
delay(1500);

delay(1500);
Serial.println(i + 14);
delay(1500);

Serial.print("0011000B91195289940000AA");
hexdump_byte(data_length & 0xFF);

l = 0;
n = 0;

for (x = 0; x < data_length; x++)
{
if (data[x] == '$') data[x] = 0x02;

n |= (data[x] & 0x7F) << l;
l += 7;

if (l >= 8)
{
hexdump_byte(n & 0xFF);
l -= 8;
n >>= 8;
}
}

if (l != 0)
{
hexdump_byte(n & 0xFF);
}

Serial.println(0x1A, BYTE);
}

Complied and uploaded to Arduino Mega 1280 with no error. But no reaction seems to be happening to the phone.

Hardware Detail
Arduino Mega 1280
Sony Ericsson T68I

Connection Detail
T68I pin 4 RX to Phone Pin 1 TX
T68I pin 5 TX to Phone Pin 0 RX
T68I pin 10 to GND
T68I pin 11 to 5V

What could be the problem ?

Trying to use Arduino mega 1280

The Mega has 4 hardware serial ports. Serial is connected to the FTDI chip, so you can debug applications. Why are you using that port to talk to the phone, completely disabling the ability to debug the application?

PaulS:

Trying to use Arduino mega 1280

The Mega has 4 hardware serial ports. Serial is connected to the FTDI chip, so you can debug applications. Why are you using that port to talk to the phone, completely disabling the ability to debug the application?

Thanks for the reply, noted that it will disable the ability to debug, i have tried using serial1 before just that i could debug while connecting to the handphone but it still don't response to the AT commands Sended.

Would appreciate more if you could enlighten me on the SMS part -_-

but it still don't response to the AT commands Sended.

So, here is a call to send an AT command.

Serial.println("AT+CMGF=0");

And the code to get the response, if there was one is where?

PaulS:

but it still don't response to the AT commands Sended.

So, here is a call to send an AT command.

Serial.println("AT+CMGF=0");

And the code to get the response, if there was one is where?

Hi PaulS i switched the pins and changed my coding to serial1 and added some line in bold to see the incoming msg from the phone.

#include <string.h>

#define num_to_char(number) ((number) < 10 ?
('0' + (number)) :
(('A' - 10) + (number)) )

#define first_four(byte) (0x0F & (byte))

#define last_four(byte) ((0xF0 & (byte)) >> 4)

#define hexdump_a(byte) num_to_char( last_four(byte))
#define hexdump_b(byte) num_to_char(first_four(byte))

int timesToSend = 1;
int count = 0;
char incoming_char=0;

void setup(){

Serial.begin(9600);
Serial1.begin(9600);

}

void loop(){

while (count < timesToSend){
send_sms("Hello World");

count++;
}
** if(Serial1.available() >0)**
** {**
** incoming_char=Serial1.read(); **
** Serial.print(incoming_char); **
** }**
}

void hexdump_byte(unsigned char byte)
{
Serial1.print(hexdump_a(byte), BYTE);
Serial1.print(hexdump_b(byte), BYTE);
}

void send_sms(char *data)
{
size_t data_length, x;
char c, l;
long i;
long n;

data_length = strlen(data);
i = data_length * 7;

if (i & 0x07) i = (i & ~0x07) + 0x08;

i = i / 8;

Serial1.println("AT+CMGF=0");
delay(1500);
delay(1500);
Serial1.println(i + 14);
delay(1500);
Serial1.print("0011000B91195289940000AA");
hexdump_byte(data_length & 0xFF);

l = 0;
n = 0;

for (x = 0; x < data_length; x++)
{
if (data[x] == '$') data[x] = 0x02;

n |= (data[x] & 0x7F) << l;
l += 7;

if (l >= 8)
{
hexdump_byte(n & 0xFF);
l -= 8;
n >>= 8;
}
}

if (l != 0)
{
hexdump_byte(n & 0xFF);
}
Serial1.println(0x1A, BYTE);
}

At my Serial monitor i am able to see
24
0011000B91195289940000AA0BC8329BFD065DDF723619

The handphone still dun response to what was send

Does the t68i support text mode in favour of PDU mode? If so, setting the operating mode to AT+CMGF=1 instead of AT+CMGF=0 will mean you can send texts like so:

AT+CMGS="01234567890" (phone number)
carriage return

carriage return

And it'll send.

When posting code, please do it properly. Select the # icon BEFORE pasting your code.

What is this supposed to be?
if (l >= 8)

hi hcanning, i have tried AT+CMFG=1 then add in AT+CMGS to send in clear text but it does not seems react either. I also Issue AT+CMFG=? to the phone which a website says the phone would reply me which mode it supports but nothing came back to the serial monitor.

Hi Pauls, I edited the smiley away, would be more careful when pasting the code.

Just wondering if there is command that i could issue to check the connectivity between Arduino and the phone ? Something like Ping ??

Are you sure that 9600 is the correct speed?