“LTE A7670G Initial Configuration”
--------------FOR VOID SETUP------------------------------
//Defining the Serial connection
#define SerialAT Serial2
void setup{
//Powering the LTE
pinMode(16, OUTPUT);
digitalWrite(16, HIGH);
//Turn on the LTE
pinMode(21, OUTPUT);
digitalWrite(21, HIGH);
delay(1000);
digitalWrite(21, LOW);
//Serial Config of LTE
SerialAT.begin(115200,SERIAL_8N1,47,48);
//AT Configuration for connecting to a SIM operator, and work with SMS receiving data
SerialAT.println("AT+CFUN=1"); // Operacion FULL
delay(1000);
SerialAT.println("AT+CREG=1"); // registro de operador automatico
delay(1000);
SerialAT.println("AT+COPS=0"); // registro de operador automatico
delay(1000);
SerialAT.println("AT+CNMP=2"); // Uso de banda automatica
delay(1000);
SerialAT.println("AT+CMGF=1"); // sms modo texto desde incio
delay(1000);
//Borrar todos los sms
SerialAT.println("AT+CNMI=1,2,0,0,0"); // modo de recibir sin guardar
delay(1000);
SerialAT.println("AT+CMGL=\"REC UNREAD\""); // registro de operador automatico
delay(1000);
}
--------EXAMPLE CODE OF WORK---------------------
//Study this code for SMS reception and control, change the variables or create it, for guide purpose
void ALARMAS(){
if(SerialAT.available()>0){
// Serial buffer
while(SerialAT.available()){
incomingByte = SerialAT.read();
buffer += incomingByte;
}
delay(10);
buffer.toUpperCase(); // uppercase the message received
Serial.print(buffer);
//flagDel=1;
}
///////////////////////LADO MOTOR ALARMAS///////////////////////////////////////////
if(buffer.indexOf("CPDCLM1")>-1){ //LMFL = Fallo en lado motor de tornillo
digitalWrite(DO0, HIGH); // ROJO LADO MOTOR
digitalWrite(DO2, HIGH); // SEMAFORO Y SIRENA
delay(1000);
//flagDel=1;
}
if(buffer.indexOf("CPDCLM0")>-1){ //LMOK = Lado motor de tornillo OK
digitalWrite(DO0, LOW); // Set CH2 to low (0V)
digitalWrite(DO2, LOW); // Set CH2 to low (0V)
delay(1000);
}
///////////////////////LADO LIBRE ALARMAS///////////////////////////////////////////
if(buffer.indexOf("CPDCLL1")>-1){ //LMFL = Fallo en lado motor de tornillo
digitalWrite(DO1, HIGH); // Set CH2 to low (0V)
digitalWrite(DO2, HIGH); // Set CH2 to low (0V)
delay(1000);
//flagDel=1;
}
if(buffer.indexOf("CPDCLL0")>-1){ //LMOK = Lado motor de tornillo OK
digitalWrite(DO1, LOW); // Set CH2 to low (0V)
digitalWrite(DO2, LOW); // Set CH2 to low (0V)
delay(1000);
}
///////////////////////SEMAFORO SOLO///////////////////////////////////////////
if(buffer.indexOf("CPDCSM1")>-1){ //LMFL = Fallo en lado motor de tornillo
digitalWrite(DO2, HIGH); // Set CH2 to low (0V)
delay(1000);
//flagDel=1;
}
if(buffer.indexOf("CPDCSM0")>-1){ //LMOK = Lado motor de tornillo OK
digitalWrite(DO2, LOW); // Set CH2 to low (0V)
delay(1000);
}
//////////////////////////////////////////////////////////////////////////////
if(buffer.indexOf("+CREG: 3")>-1){ //VUELVE A TRATAR DE REGISTRAR CONEXION
SerialAT.println("AT+CREG=1");
delay(1000);
}
if(buffer.indexOf("+CREG: 2")>-1){ //VUELVE A TRATAR DE REGISTRAR CONEXION
SerialAT.println("AT+CREG=1");
delay(1000);
}
if(buffer.indexOf("+CMS ERROR: 500")>-1){ //EN CASO DE ERROR 500 (SIM FUERA) PARPADEA, OCUPA SIM Y REINICIO
digitalWrite(DO0, HIGH); // Set CH2 to low (0V)
digitalWrite(DO1, HIGH);
delay(1000);
digitalWrite(DO0, LOW); // Set CH2 to low (0V)
digitalWrite(DO1, LOW);
delay(1000);
digitalWrite(DO0, HIGH); // Set CH2 to low (0V)
digitalWrite(DO1, HIGH);
delay(1000);
digitalWrite(DO0, LOW); // Set CH2 to low (0V)
digitalWrite(DO1, LOW);
delay(1000);
digitalWrite(DO0, HIGH); // Set CH2 to low (0V)
digitalWrite(DO1, HIGH);
delay(1000);
digitalWrite(DO0, LOW); // Set CH2 to low (0V)
digitalWrite(DO1, LOW);
delay(1000);
}
buffer=""; //Limpia el buffer para evitar ciclado de ram
}