Please, help with AT commands! (AT+CCLK)

Good day to everyone. I just bought an 3G/GPRS shield so I can send sms, mails, GPS position... I search in the internet how to ask for date (day and hour) cause I want to sen the date in the sms. In every web I found they said that the command is: "AT+CCLK" And this command should return me something like this: "+CCLK: yy/mm/dd hh:mm:ss" The problem is that i don't know how to use it. I try in different ways with out success. It could be something like this??

AT+CCLK?;
    +CCLK;
    
    Serial.print("AT+CCLK=\"");
    Serial.println (+CCLK);

The problem is that i don't know how to use it.

Just like any other AT command.

    Serial.print("AT+CCLK");

I tried to put that in the final part of my code (where I chose the data to send in the sms) but I receive "AT+CCLK" in my phone, not the hour...Thanks for your time again Paul...

I tried to put that in the final part of my code (where I chose the data to send in the sms) but I receive "AT+CCLK" in my phone, not the hour.

What code?

Clearly, what you send to the phone to talk to it, is going to be different from what you send to the phone as a text message.

I write the Serial.print(“AT+CCLK”); in “void loop2” but I don´t get the hour. With Serial.print(“AT+CMGS=”"); I send the sms to a phone number whit out problem but with AT+CCLK I can´t get what I want…
This is the code (you help me with it in another topic):

#include <Keypad.h>

//VARIABLES ENVIO DATOS
int led = 13;
int onModulePin = 2;        // Definimos el Pin 2 para activar o desactivar el modulo 3G (sin pulsar el botón)
int timesToSend = 1;        // Numero de sms a enviar
int count = 0;
char phone_number[]="*********";     // ********* numero que recibirá el sms


//VARIABLES TECLADO
const byte ROWS = 4; //4 filas
const byte COLS = 3; //3 columnas
char keys[ROWS][COLS] = {
  {
    '1','2','3'  }
  ,
  {
    '4','5','6'  }
  ,
  {
    '7','8','9'  }
  ,
  {
    '*','0','#'  }
};
byte rowPins[ROWS] = {
  7, 6, 5, 4}; // reserva de memoria en bytes, conectar a los pines de filas del teclado
byte colPins[COLS] = {
  10, 9, 8}; // reserva de memoria en bytes, conectar a los pines de columnas del teclado
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
char serialnumber[10]="6103722";
char usuario1[]="111#";
char usuario2[]="222#";
char usuario3[]="333#";
char usuario4[]="444#";
char usuario5[]="555#";
char attempt[]="0000";   // usado para comparar
int z=0;
int sal1 = 11; // salida led verde pin 11
int sal2 = 12; // salida led rojo pin 12
char attempt2[5]="0000";



//PROGRAMA
void setup()
{
  pinMode(sal1, OUTPUT);
  pinMode(sal2, OUTPUT);
  Serial.begin(115200); //Configura la velocidad del puerto serie
  keypad.setHoldTime(150); // Tiempo de pulsado de boton. Default is 1000mS
  keypad.setDebounceTime(30); // Tiempo de rebote de bootn. Default is 50mS
  Serial.println(" Introduzca PIN: ");
}
void leds()
{ 
  if (sal1 == LOW) 
    sal2 = HIGH;
  else 
  { 
    sal2 = LOW;
  }
}
void checkPIN()
{
  Serial.print("attempt: [");
  Serial.print(attempt);
  Serial.print("]");
  int correct = 0;
  if(strcmp(attempt, usuario1) == 0)
    correct = 1;
  else if(strcmp(attempt, usuario2) == 0)
    correct = 2;
  else if(strcmp(attempt, usuario3) == 0)
    correct = 3;
  else if(strcmp(attempt, usuario4) == 0)
    correct = 4;
  else if(strcmp(attempt, usuario5) == 0)
    correct = 5;

  if ( correct=!0)
  {   
    Serial.println("PIN OK");
    digitalWrite(11, HIGH); // activa un contacto
    for (int zz=0; zz<=4; zz++) // borrar el último código introducido
    {
      attempt[zz]=0;
    }
    switchModule();
    setup2();
    loop2();    
  }   
  else
  {
    Serial.println("PIN erroneo");
    digitalWrite(12, HIGH); // activa un contacto
    delay(1000);   
    digitalWrite(12, LOW);
    for (int zz=0; zz<=4; zz++) // borrar el último código introducido
    {
      attempt[zz]=0;
    }
    setup();
  }
}
void readKeypad()
{
  char key = keypad.getKey();
  if (key != NO_KEY)
  {
    switch(key)
    {
    case '*':
      z=0; 
      digitalWrite(12, LOW);
      digitalWrite(11, LOW);
      setup();
      break;
    case '#':
      delay(50);
      Serial.println(" ");
      checkPIN();
      break;
    default:
      attempt[z]=key;
      z++;
      attempt[z] = '\0'; // Add this to keep attempt NULL terminated (after making attempt larger)

    }
    Serial.print("*");
    leds();
  }
}
void loop()
{
  readKeypad();
}
void switchModule(){
  digitalWrite(onModulePin,HIGH);     //Para activar el módulo 3G, debemos enviarle un pulso de 2sg por el pin número 2 (lo mismo para apagar)
  Serial.println("Activando modulo 3G...");
  delay(2000);
  digitalWrite(onModulePin,LOW);
  Serial.println("Modulo 3G activado...");
}
void setup2(){
  Serial.begin(115200);               //Configuramos puerto UART
  delay(2000);
  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);
  for (int i=0;i< 5;i++){
    delay(5000);
  } 
  Serial.println("AT+CMGF=1");        //Seleccionamos el formato del sms (0=PDU 1=texto)
  delay(100);
}
void loop2(){

  while (count < timesToSend){
    delay(1500);                
    Serial.print("AT+CMGS=\"");   // send the SMS number
    Serial.print(phone_number);

    Serial.println("\"");       
    delay(1500); 

    Serial.print("Numero de serie: ");
    Serial.println (serialnumber);
    delay(1500); 

    Serial.print("Usuario: ");
    Serial.println (attempt);

    delay(500);
    Serial.write(0x1A);       //sends ++
    Serial.write(0x0D);
    Serial.write(0x0A);
    delay(5000);
    count++;
  }

}

Thanks

You should read a manual or something. Cause the manual I downloaded says clearly you should do this.

Serial.println("AT+CCLK?");

I read some manual on the net before post anything in the forum but any of them solve my problem. Maybe it tooks too much time to receive signal grom the GPS... Right now i'm trying to get the date with a DSL1307. Thanks for your answer.

dgelectron: I write the Serial.print("AT+CCLK"); in "void loop2" but I don´t get the hour. With Serial.print("AT+CMGS=\""); I send the sms to a phone number whit out problem but with AT+CCLK I can´t get what I want... This is the code (you help me with it in another topic):

Your code doesn't have CCLK in it. Nice try.

Yeah, that's the cpde before write the AT+CCLK... I thought that wasnt needed to explain... Nice answer ;)

Thanks.

+CCLK is the respond of the gprs module after you send the AT+CCLK

Did you try this yet?

Serial.println("AT+CCLK?");

Hi Liudr.

Untill now i've been working with the clock DSL1307 but for some reason (probably cable connections) it's not 100% reliable.

Yeah, I tried with

Serial.println("AT+CCLK?");

But it doesnt work. I don't know what I'm doing wrong. Can please post a super small code that should work?

Thanks so much.

Serial.print("AT+CCLK?\r\n");

hola, espero que esto les pueda servir, he buscado mucho y este es el que me funcionó perfectamente.

https://arduino.stackexchange.com/questions/52356/arduino-receive-response-from-sim800h-to-atcclk-command/75462#75462

You do know that AFTER you send +CCLK?, the modem will return the time string.

YOU have to write a block of code to parse (separate) the time values out - then do whatever you have to do.

It’s just like sending “AT\r” and receiving “OK\r” back. It’s just serial traffic, you have to handle it.