GSM A6 is able to send SMS but doesn't receive

a6

#23

Finally I found a sollution, I make the module send me an SMS in setup just after I plug it … it seems that he was not capable of identifing the characters to use ( latin ) that’s why he send ascii codes instead of messages !
About the repetition of characters in serial monitor I didn’t found a solution to it despite I use mySerial.println(“ATE0&W\r\n”); delay(500); in setup ! if only you can help me in this repetition

this is the programm :

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX-Pin10, TX-Pin11
unsigned char Buff[250];
unsigned char BuffIndex;
boolean Act = false;

void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
pinMode(3,INPUT_PULLUP);
pinMode(9, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(9,HIGH);
digitalWrite(5,LOW);
delay(20000);
//mySerial.println(“AT\r\n”);
//delay(500);
//mySerial.println(“AT+CMGF=1”);
//delay(3000);
// mySerial.println(“AT+CNMI=2,2,0,0,0”);
memset(Buff, ‘\0’, 250); // Initialize the string
BuffIndex=5;
// mySerial.println(“ATE0\r\n”);
mySerial.println(“ATE0&W\r\n”);
delay(500);
// mySerial.println(“AT&W\r\n”);

for (int i = 1; i <= 15; i++) 
    {
      mySerial.print("AT+CMGD=");
      mySerial.println(i);
      delay(200);
// Not really necessary but prevents the serial monitor from dropping any input
      while(mySerial.available()) 
      Serial.write(mySerial.read());
    }
    SMS_Ready();

}

void SMS_Marche() {
mySerial.println(“AT+CMGF=1”);
delay(1000);
mySerial.print("AT+CMGS=“0021621683213”);
mySerial.print(char(34)); // "
mySerial.print(char(13)); // CR
mySerial.print(’\r’); // hex equivalent of newline
delay(1000);
mySerial.println(“Motor On”);
delay(500);
mySerial.println(char(26)); //ctrl_z
}

void SMS_Arret() {
mySerial.println(“AT+CMGF=1”);
delay(1000);
mySerial.print("AT+CMGS=“0021621683213”);
mySerial.print(char(34)); // "
mySerial.print(char(13)); // CR
mySerial.print(’\r’); // hex equivalent of newline
delay(1000);
mySerial.println(“Motor Off”);
delay(500);
mySerial.println(char(26)); //ctrl_z
}

void SMS_Test_Moteur() {
mySerial.println(“AT+CMGF=1”);
delay(1000);
mySerial.print("AT+CMGS=“0021621683213”);
mySerial.print(char(34)); // "
mySerial.print(char(13)); // CR
mySerial.print(’\r’); // hex equivalent of newline
delay(1000);
mySerial.println(“Contacteur actif”);
delay(500);
mySerial.println(char(26)); //ctrl_z
}

void SMS_Ready() {
mySerial.println(“AT+CMGF=1”);
delay(1000);
mySerial.print("AT+CMGS=“0021621683213”);
mySerial.print(char(34)); // "
mySerial.print(char(13)); // CR
mySerial.print(’\r’); // hex equivalent of newline
delay(1000);
mySerial.println(“GSM Ready”);
delay(500);
mySerial.println(char(26)); //ctrl_z
}

void loop()
{

  while(1)
  {

      if ((digitalRead(3)==LOW) && (Act==false))
          {
          digitalWrite(5,LOW);
          SMS_Test_Moteur();
          }
       if (digitalRead(3)==HIGH)
       {
         digitalWrite(5,HIGH);
         Act==true;
       }
      if(mySerial.available()>0)
      {
          Buff[BuffIndex] = mySerial.read();    
      
          //  Serial.print('\n');
          Serial.write(Buff[BuffIndex-2]);
          Serial.write(Buff[BuffIndex-1]);
          Serial.write(Buff[BuffIndex]);

if((Buff[BuffIndex-1] == ‘O’) && (Buff[BuffIndex] == ‘n’))
{

              SMS_Marche();
              digitalWrite(9,LOW);
              digitalWrite(5,HIGH);
        
          }
          
      else if( (Buff[BuffIndex-2] == 'O') && (Buff[BuffIndex-1] == 'f') && (Buff[BuffIndex] == 'f'))
          {


              SMS_Arret();
              digitalWrite(9,HIGH);
              digitalWrite(5,LOW);
  
          }

          BuffIndex++;
          if(BuffIndex>250) 
          {
              BuffIndex=5;
          }
      }
  }

delay(10);
}


#24

To stop echo, during GSM initialization Send “ATE0\r\n” command immediately after sending AT\r\n.


#25

Hi Gangusa,
I did what you told me but nothing has changed :confused: look here is a shot !
the module works well now expect that echo mode remain actif and the module send me 2 messages instead of one haha (maybe problem in the programm)


#26

Just comment below lines in loop and check… :roll_eyes:


#27

the buffer seems empty, it’s scorlling down with blank display !


#28

a shot with internal while (1)
difference is on the delay(10) wich is not included in the while (1) loop


#29

@Reska I told you to remove those lines from the code… Comment mean you should use // like below … :slightly_smiling_face:


#30

when I comment those serial monitor lines, the module does not send or receive anymore even when usind an other programm ! until I downloaded the programm of test At command as I do every time when the module doesn’t respond by sending AT and wait until OK response and then I download again the programm needed so it works :

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // TX-Pin11, RX-Pin10
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
}

void loop()
{

while(mySerial.available()) 
{
  Serial.write(mySerial.read());   //Forward what Software Serial received to Serial Port
}
while(Serial.available())
{
  mySerial.write(Serial.read());  //Forward what Serial received to Software Serial Port
} 
 delay(10);  

}

but this time, he does not works with my programm despite he respond by ok in this test programm until I tried to use ATD+mynumber to call so it display a long line of question mark : ???
then when I downoaded the main program it works this time with those seril monitor lines commented !

I hope you understand my long boring reply Gangusa :stuck_out_tongue: haha !