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