If a new SIM card is inserted to your phone, when the phone restarts, it will ask us to set date and time. In SIM900-TTL GSM/GPRS modem also, we can set the date and time. Since there is no user interface, some AT commands are used to set and read the date and time from modem. Different methods are there to input AT commands to SIM900-TTL GSM/GPRS modem. Here we will use an Arduino mega to input the AT commands. I used SIM900-TTL GSM/GPRS modem from Rhydolabz.
Important : SIM card should be inserted to the slot provided on top of modem. Antenna should be fitted to modem.
Circuit is done as shown in the diagram. Modem requires two voltage sources. One is Vinterface and other is Vin. Vin is given from a DC power supply which is capable of handling an output current of 1A. Vinterface is given from 5V pin of arduino. RX pin of modem is connected to the TX pin of Arduino and TX pin of modem is connected to the RX pin of arduino.
Arduino program to run the test command
Now upload the following program to your arduino board. Before pressing the upload button, either turn off the GSM modem or disconnect the modem pins connected to the RX and TX pins of arduino. Otherwise, uploading will fail.
void setup()
{
Serial.begin(2400);
Serial.write("AT+CMGF=1\r"); //set GSM to text mode
delay(1500);
Serial.write("AT+CCLK=?\r"); //Test command
while(1)
{
if(Serial.available())
{
Serial.write(Serial.read());
}
}
}
void loop()
{
}
If the uploading is successfull, open your serial monitor. Serial monitor will display OK. Don't forget to change the baud rate to 2400. Otherwise serial monitor will display an unexpected result.
Arduino program to read current date and time from modem
To read current date and time, upload the following program to your arduino board. Before pressing the upload button, either turn off the GSM modem or disconnect the modem pins connected to the RX and TX pins of arduino. Otherwise, uploading will fail.
void setup()
{
Serial.begin(2400);
Serial.write("AT+CMGF=1\r"); //set GSM to text mode
delay(1500);
Serial.write("AT+CCLK?\r"); //Read command
while(1)
{
if(Serial.available())
{
Serial.write(Serial.read());
}
}
}
void loop()
{
}
If the uploading is successfull, open your serial monitor. Serial monitor will display current date and time. Don't forget to change the baud rate to 2400. Otherwise serial monitor will display an unexpected result.
If you want to change the date and time already set in the modem, upload the following program to your arduino board. Before pressing the upload button, either turn off the GSM modem or disconnect the modem pins connected to the RX and TX pins of arduino. Otherwise, uploading will fail.
void setup()
{
Serial.begin(2400);
Serial.write("AT+CMGF=1\r"); //set GSM to text mode
delay(1500);
Serial.write("AT+CCLK=\"99/12/12,04:06:30+08\"\r"); //Set date and time YY/MM/DD,hh:mm:ss+zz
while(1)
{
if(Serial.available())
{
Serial.write(Serial.read());
}
}
}
void loop()
{
}
If the uploading is successfull, open your serial monitor. Old date and time will be replaced by the new date and time given as input. Don't forget to change the baud rate to 2400. Otherwise serial monitor will display an unexpected result.
Now read the current date and time by uploading corresponding arduino program. Date and time displayed will be the new date and time.

Circuit is done as shown in the diagram. Modem requires two voltage sources. One is Vinterface and other is Vin. Vin is given from a DC power supply which is capable of handling an output current of 1A. Vinterface is given from 5V pin of arduino. RX pin of modem is connected to the TX pin of Arduino and TX pin of modem is connected to the RX pin of arduino.
Arduino program to run the test command
Now upload the following program to your arduino board. Before pressing the upload button, either turn off the GSM modem or disconnect the modem pins connected to the RX and TX pins of arduino. Otherwise, uploading will fail.
void setup()
{
Serial.begin(2400);
Serial.write("AT+CMGF=1\r"); //set GSM to text mode
delay(1500);
Serial.write("AT+CCLK=?\r"); //Test command
while(1)
{
if(Serial.available())
{
Serial.write(Serial.read());
}
}
}
void loop()
{
}
If the uploading is successfull, open your serial monitor. Serial monitor will display OK. Don't forget to change the baud rate to 2400. Otherwise serial monitor will display an unexpected result.
Arduino program to read current date and time from modem
To read current date and time, upload the following program to your arduino board. Before pressing the upload button, either turn off the GSM modem or disconnect the modem pins connected to the RX and TX pins of arduino. Otherwise, uploading will fail.
void setup()
{
Serial.begin(2400);
Serial.write("AT+CMGF=1\r"); //set GSM to text mode
delay(1500);
Serial.write("AT+CCLK?\r"); //Read command
while(1)
{
if(Serial.available())
{
Serial.write(Serial.read());
}
}
}
void loop()
{
}
If the uploading is successfull, open your serial monitor. Serial monitor will display current date and time. Don't forget to change the baud rate to 2400. Otherwise serial monitor will display an unexpected result.
Arduino program to update date and time
If you want to change the date and time already set in the modem, upload the following program to your arduino board. Before pressing the upload button, either turn off the GSM modem or disconnect the modem pins connected to the RX and TX pins of arduino. Otherwise, uploading will fail.
void setup()
{
Serial.begin(2400);
Serial.write("AT+CMGF=1\r"); //set GSM to text mode
delay(1500);
Serial.write("AT+CCLK=\"99/12/12,04:06:30+08\"\r"); //Set date and time YY/MM/DD,hh:mm:ss+zz
while(1)
{
if(Serial.available())
{
Serial.write(Serial.read());
}
}
}
void loop()
{
}
If the uploading is successfull, open your serial monitor. Old date and time will be replaced by the new date and time given as input. Don't forget to change the baud rate to 2400. Otherwise serial monitor will display an unexpected result.
Now read the current date and time by uploading corresponding arduino program. Date and time displayed will be the new date and time.
dont open picture:(
ReplyDeleteok
ReplyDeleteMake positive your contraptions are connected all over with interior the universal through the way of implies of utilizing our +500 systems. Set up your chosen systems or utilize the foremost capable sign to be had to your apparatus to create beyond any doubt a reliable connection.
ReplyDelete