Problem with accent character and GSM shield

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 = ô

(http://www.ascii-code.com/)

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

Hi,

I did some more search and noticed that there is an AT command to configure the GSM modem in ISO 8859 Latin 1, witch is the ASCII chart I think I need.

My problem is that I don't know how to send direct AT command to the shield. I would like to do this at the beginning of my code :

send to GSM shield : AT+CSCS="8859-1"
Print what I get back
send to GSM shield : AT+CSCS?
print what I get back

I succeed wit this code :

#include <SoftwareSerial.h>
 
SoftwareSerial mySerial(2,3);
 
void setup()
{
  mySerial.begin(9600);                 
  Serial.begin(9600);                 
}
 
void loop()
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read()); 
 
}

But when I try to implement it with the code with the GSM.h library it doesn't work because there is a conflict between GSM.h and SoftwareSerial.h (I read a lot about it on the forum).

So, is there a way to send simple and direct AT command to the GSM modem?

Regards.

Ok, I succeeded in changing the character set by using this command at the beginning of my code :

theGSM3ShieldV1ModemCore.genericCommand_rq(PSTR("AT+CSCS="8859-1""));

But it does not solve my problem with accent character. I tried all character set and I have the same problem with all of them.

Is someone have an idea of what could cause this and what would be the solution?

Hi! I know its an old Tread, but have you fix your problem? I just ask because i got the exact same problem here with my GSM module...

Salut, je sais que c'est un vieux tread, mais as-tu résolu ton problème? Je te demande car j'ai exactement le même problème avec mon module GSM