Hi,
I'm using the Arduino GSM R3 Shield over an Arduino UNO R3 to send and receive SMS message from the Arduino serial console. I'm using an hybrid code from the two examples for sending and receiving SMS and it works well :
// libraries
#include <GSM.h>
// PIN Number
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSM_SMS sms;
char remoteNumber[20]; // Holds the emitting number
void setup()
{
// initialize serial communications
Serial.begin(9600);
Serial.println("SMS Messages Receiver");
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop()
{
//pour envoyer un message texte
char c;
// If there are any SMSs available()
if (sms.available())
{
Serial.println("separator");
Serial.println("numero");
// Get remote number
sms.remoteNumber(remoteNumber, 20);
Serial.println(remoteNumber);
// This is just an example of message disposal
// Messages starting with # should be discarded
if(sms.peek()=='#')
{
Serial.println("Discarded SMS");
sms.flush();
}
// Read message bytes and print them
Serial.println("separator");
Serial.println("message");
while(c=sms.read())
Serial.print(c);
// Serial.println("\nEND OF MESSAGE");
// delete message from modem memory
sms.flush();
// Serial.println("MESSAGE DELETED");
// Serial.println("Waiting for messages");
}
//delay(1000);
if (Serial.available() > 0)
{
char remoteNumber[20]; // telephone number to send sms
readSerial(remoteNumber);
Serial.println(remoteNumber);
// sms text
Serial.print("Now, enter SMS content: ");
char txtMsg[200];
readSerial(txtMsg);
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(txtMsg);
// send the message
sms.beginSMS(remoteNumber);
sms.print(txtMsg);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
Serial.println("Waiting for messages");
}
}
/*
Read input serial
*/
int readSerial(char result[])
{
int i = 0;
while(1)
{
while (Serial.available() > 0)
{
char inChar = Serial.read();
if (inChar == '\n')
{
result[i] = '\0';
Serial.flush();
return 0;
}
if(inChar!='\r')
{
result[i] = inChar;
i++;
}
}
}
}
My problem is when I'm sending SMS with accent character (I'm form Quebec, Canada, we all speak french in here) the text is displayed as HEX value of the ASCII character instead of the ASCII value itself. It does this only with certain character like ô and à, but not with è.
Here is a print of the serial console for a test without and with accents :
With accent :
message
test without accents
Without accents :
message
00740065007300740020007700690074006800200061006300630065006E007400730020003A002000E9002000E0002000E8002000F4
The HEX sentence is this one : "test with accents : é à è ô"
00E9 = é
00E0 = à
00E8 = è
00F4 = ô
In the same way, when I want to send a sentence with some accent character, it doesn't works.
Can someone help me with this problem? I would like the shield to send my the correct ASCII character in the same format all the time, and I would want it to be able to send all the different characters in the same format too.
Regards
LR