Go Down

Topic: Reset (or unplug power) Module GSM A6 ==> program won't work again !!!!!!!! (Read 1 time) previous topic - next topic

Reska

Hello everyone,

I have a problem with my GSM A6 Module, the program runs well but when I reset the module or unplug and plug the power supply, it does not work again !!!! until I upload a sketch which use serial monitor to communicate with the module by AT command, and then I upload again my program to work again ! is it problem of synchronization between arduino and the module at the beginning when powered up ?? what would make the module works only one time until it is powered off ? please can you help me guys !
thankx !





this is the program based on a youtube channel :


#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(4800);
 mySerial.begin(9600);  
 pinMode(9, OUTPUT);
 digitalWrite(9,HIGH);    
 delay(3000);
 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;
}

void SMS_On() {

mySerial.println("AT+CMGF=1");
//mySerial.write(0x0D);  // hex equivalent of Carraige return    
//mySerial.write(0x0A);  // hex equivalent of newline  
delay(1000);
mySerial.print("AT+CMGS=\"mynumber");
mySerial.print(char(34));  // "
mySerial.print(char(13));  // CR
mySerial.print('\r');  // hex equivalent of newline
delay(1000);
mySerial.println("Motor On");
//mySerial.write(0x0D);  // hex equivalent of Carraige return    
//mySerial.write(0x0A);  // hex equivalent of newline  
delay(500);
mySerial.println(char(26));  //ctrl_z
//mySerial.write(0x0D);  // hex equivalent of Carraige return    
//mySerial.write(0x0A);  // hex equivalent of newline  
}


void SMS_Off() {

mySerial.println("AT+CMGF=1");
//mySerial.write(0x0D);  // hex equivalent of Carraige return    
//mySerial.write(0x0A);  // hex equivalent of newline
delay(1000);
mySerial.print("AT+CMGS=\"mynumber");
mySerial.print(char(34));  // "
mySerial.print(char(13));  // CR
mySerial.print('\r');  // hex equivalent of newline
delay(1000);
mySerial.println("Motor Off);
//mySerial.write(0x0D);  // hex equivalent of Carraige return    
//mySerial.write(0x0A);  // hex equivalent of newline  
delay(500);
mySerial.println(char(26));  //ctrl_z
//mySerial.write(0x0D);  // hex equivalent of Carraige return    
//mySerial.write(0x0A);  // hex equivalent of newline  
}  

void loop()
{

   while(1)
   {
       if(mySerial.available()>0)
       {
           Buff[BuffIndex] = mySerial.read();    
       
           if((Buff[BuffIndex-1] == 'O') && (Buff[BuffIndex] == 'n'))
           {
               //Serial.print('\n');
               //Serial.write(Buff[BuffIndex-1]);
               //Serial.write(Buff[BuffIndex]);
               Act=true;
               if(Act==true)
               {
               SMS_On();
               digitalWrite(9,LOW);
               Act=false;  
               }                    
           }
           
           if( (Buff[BuffIndex-2] == 'O') && (Buff[BuffIndex-1] == 'f') && (Buff[BuffIndex] == 'f'))
           {
               //Serial.print('\n');
               //Serial.write(Buff[BuffIndex-2]);
               //Serial.write(Buff[BuffIndex-1]);
               //Serial.write(Buff[BuffIndex]);
               Act=false;
               if(Act==false)
               {
               SMS_Off();
               digitalWrite(9,HIGH);
               Act=true;  
               }        
           }

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

delay(10);
}

KASSIMSAMJI

faced same problem years back before i made a switch to sim 800l , A6 gsm lacks flash memory to store those parameters , price gone cheap too
Expert To Be: Machine Learning And Computer/Machine Vision (ML/CV/MV)

sai_srikar

faced same problem years back before i made a switch to sim 800l , A6 gsm lacks flash memory to store those parameters , price gone cheap too
thank you,i should have seen this message before

Go Up