GSM shield - send sms

Hello everyone,

I am a bit lost with my GSM shield. I am trying to send a simple SMS but nothing happens.

My final goal is to use a multi-operator card but i'm currently using my own sim card to make it simple.

I use SIM800h chip and a compatible arduino board (DUE equivalant named Flip&Click) but it's not important. CurrentlyI can send commands and get answers from my GSM shield.

I can see the answers using the serial monitor, and this is the commands I use ( +the answer at the next line) :


AT+CPIN=\"ABCD\" //Indicate my pin code AT+CPIN="ABCD" OK


AT+COPN //Reading operator names (strange, there is no "SFR" (my sim card network (France))). AT+COPN +COPN: "20201","COSMOTE" +COPN: "20205","vodafone" +COPN: "20209","Q-TELECOM"

OK


AT+COPS? // Current operator, well here we have "SFR" +COPS: 0,0,"SFR"

OK


AT+CSCS? // Encoding (I guess) +CSCS: "IRA"

OK


AT+CMGF=1 // Set text mode AT+CMGF=1 OK


AT+CMGS=\"+336xxxxxxxx\"\r // Giving my number AT+CMGS="+336xxxxxxxx"


Test sms from BLE2 Click !" + (char)26 // My message !


I wait around 30 seconds before sending commands. CMGS retourn "!" (it's the end of the message body). I refered to the AT command user guide and I don't think my commands are wrong. I'm french, please forgive my poor english level :'( Is it normal that SFR is not in the operator list ? Why CMGS only returns "!" ?

When I use my multi-operator sim card it's even worse.. I can't set text mode... It returns ERROR :o I tryed to use GSM mode but that also doesn't work. There is a way to be sure we have the correct operator selected ? COPS command is enouth to check ? I also tryed to send a message using my phone and the multi-operator card ==> the card is working fine.

I hope someone will help me, I already asked on the french forum but no replys..

Thank you !

Here is my code :

      // Enter pin code
      delay(30000);
      commandStringGSM = "AT+CPIN=\"XXXX\"";
      Serial1.print(commandStringGSM + "\n");
      delay(1000);
      readFromGsm();
      delay(1000);
      Serial.print(inputStringGSM);


      // Read operator names
      delay(3000);
      commandStringGSM = "AT+COPN";
      Serial1.print(commandStringGSM + "\n");
      delay(1000);
      readFromGsm();
      delay(1000);
      Serial.print(inputStringGSM);

      
      // Return the currently selected operator
      delay(3000);
      commandStringGSM = "AT+COPS?";
      Serial1.print(commandStringGSM + "\n");
      delay(1000);
      readFromGsm();
      delay(1000);
      Serial.print(inputStringGSM);


      // Return the current character set (GSM, or IRA, or HEX etc)
      delay(3000);
      commandStringGSM = "AT+CSCS?";
      Serial1.print(commandStringGSM + "\n");
      delay(1000);
      readFromGsm();
      delay(1000);
      Serial.print(inputStringGSM);

      // Set text mode
      delay(3000);
      commandStringGSM = "AT+CMGF=1";
      Serial1.print(commandStringGSM + "\n");
      delay(1000);
      readFromGsm();
      delay(1000);
      Serial.print(inputStringGSM);


      // Phone number to send message
      delay(3000);
      commandStringGSM = "AT+CMGS=\"+336XXXXXXXX\"\r";
      Serial1.print(commandStringGSM);
      delay(1000);
      readFromGsm();
      delay(1000);
      Serial.print(inputStringGSM);


      // Message
      delay(1000);
      commandStringGSM = "Test sms from BLE2 Click !" + (char)26;
      Serial1.print(commandStringGSM+'\n');
      delay(1000);
      readFromGsm();
      delay(1000);

      Serial.print(inputStringGSM);

//And my reading functing which is somewhere else but working fine.
void readFromGsm(){

  incomingByteGSM = 0;
  inputStringGSM = "";
  delay(1000);
    while(Serial1.available() > 0){
      incomingByteGSM = Serial1.read();
      inputStringGSM += String(incomingByteGSM);
      delay(50);
    }
}

I'm french, please forgive my poor english level

Why don't you ask in the French language section, where people are more likely to understand you AND be familiar with the various carriers?

Niconnexion:
I hope someone will help me, I already asked on the french forum but no replys…

That’s why…

But if you don’t even read my post you wont be likely to understand me, obviously !
Is it forbidden to post here as a french person ?

If anyone wants more details about my issue I can explain.
I understand english perfectly, I’m just bad at making long stuff like this post…
I just said sorry in case I made some mistakes in my post.

Is it forbidden to post here as a french person ?

Not at all, and your English is nothing that you need to apologize for. I did read your post, just not all the way to the end. Sorry about that.

I suspect that the fact that your carrier does not show up in the list returned by AT+COPN is going to cause you problems. But, I've only visited France three times, and never with a cell phone, so I do not know enough about the French systems to be able to help you.

Thank you for your comment.

I will try to add my network to the list, I hope it will solve my issue. There is probably a note about how to do it in the AT command guide.

Do you know if it's possible to disable Unsolicited Result Codes ? Sometimes I have "Call ready", "Sms ready", "RDY" in my serial monitor. These random results will impede me if I want to check the result code by comparing it to a String.

This way:

if(answer == "AT+CMGF=1\nOK\r\n"){ ==>good answer} else { ==>bad answer, try again}

If the answer is "AT+CMGF=1\nOK\r\nCall Ready\r\n" my way to check the result will never be valid due to these unsolicited results coming in my reading function.

due to these unsolicited results coming in my reading function.

I doubt that they are "unsolicited results". You need to understand that serial data processing is meant to be asynchronous, and you are trying to force it into a synchronous pattern.

The response to a given AT command ends with the \r\n after the OK. So, if you see OK in the response, read two more characters. If they are the \r\n, stop reading more data as a response to the last command.

This method is working with my BLE shield because this one is clever enouth to not spam the serial bus :P BLE just answer when I send a command, so I thought my method was great to check if the answer is the expected one...

AT command guide call it "Unsolicited Result Codes", not me :P

But yes, I can check the answer by stoping my function when characters are \r\n, good tip !

When you say I'm trying to force it into a synchronous pattern you mean I'm trying to force communication between me and my shield in a "one at a time" system ? Yes... I'm trying to, to make it easy to control, and easy to use.

My readFromGsm() function stops when there is nothing on the serial bus that's why I dont get all the operators in my list (with COPN command). Because I think my GSM shield take a little break during the transmission (like if it was sending packets of data, with precise amount of data ? with a pause between each packet ?).

When I call my readFromGsm() twice I get the rest of the list... sometimes... Still a lot of strange stuff here....

Thank you again !