Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Take RTC time from SIM900 via SMS

Status
Not open for further replies.

garagedog

Newbie level 5
Joined
Jan 6, 2014
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
88
Hi,

Previously I wanted to update sim900 RTC via network time [ and I thank again all of you helped me in this forum,

Now I'm trying to add RTC time stamp to the SMS so that I can include the time the SMS was sent, so it will be a big help if anybody could let me know how to properly store receiving UART data to a string using mikroC.



Thank you.
 

You can use AT+CCLK? command to get time and date from SIM900. Parse and extract time and use strcat() function to concatanate time to your SMS message.
 
Last edited:
Hi, I tried with "AT+CCLK?" , but where I fail is storing the uart response to a string.
 
Last edited:

Post your code. You have to use Interrupt Service Routine and dump the UART data to a array. Later you have to parse this array and extract string related to time.
 

Before you use "AT+CCLK?" command you have to use "AT+CLTS=1" for only once.

This command will enable the module to remember the setting forever and each time the module reboots, module will send ACK to basestation to get timestamp at the beginning and the basestation will return the correct package.

After this use the command AT+CCLK? and capture the data as said earlier by Mr Jayanth..
 

Hi, sorry it took me days to reply, here is my code:

void main()
{

unsigned char output[20];
TRISB.LATB0 = 0; //make PORTB pin 0 output
PORTB.LATB0 = 1;
Delay_ms(1000);
PORTB.LATB0 = 0;
Delay_ms(15000);

UART1_Init(9600); // initialize UART1
Delay_ms(100);
UART1_Write_text("ATE1\r\n");
Delay_ms(5000);




UART1_Write_text("AT+CCLK?\r\n");
if (UART1_Data_Ready() == 1)
{ // if data is received
UART1_Read_Text(output, "+2", 10); // reads text until +2 is found
Delay_ms(500);
UART1_Write_text("AT+CMGF=1\r\n");
Delay_ms(500);
UART1_Write_Text("AT+CMGS=\"0737071248\"\r\n");
Delay_ms(500);
UART1_Write_Text(output);
UART1_Write_text("\r\n");
UART1_Write(0x1A);
Delay_ms(5000);
}

}

this works fine in proteus simulation with data I enter through virtual terminal, but it doesn't work when I program it to my pic. I also tried the UART interrupt examples but what I cannot figure out is how to enable a UART interrupt only when I send "AT+CCLK?" to gsm module. I'm really messed up with the problem hope you could help me.

Thanks.
 

Before sending AT+CCLK?\r enable UART receive interrupt using

Code C - [expand]
1
RCIE_bit = 1; INTCON = 0xC0;

. Three sec after sending the command use

Code C - [expand]
1
RCIE_bit = 0;

to disable the interrupt.


Edit: It took me 10 minutes to write a working code. Contact me at internetuser2k11(at)gmail(dot)com

Test the attached .hex file. It is compiled for PIC18F452 at 8 MHz external OSC and 9600 bps baudrate.

101264d1390210277-gettime.png
 

Attachments

  • getTime.png
    getTime.png
    99.8 KB · Views: 196
  • Get Time.rar
    91.1 KB · Views: 112
Last edited:

@jayanth : Can you post the C Code for the same here
 

I have also tried the same i have not to sent message of that time reading rather right now i want it to display om LCD but not getting proper data
 

code is attached here with
 

Attachments

  • sim900_RTC with PIC18.txt
    2.3 KB · Views: 131

Lot of thanks for your guidance mr. jayanth.devarayanadurga, I made it :)
 

Before you use "AT+CCLK?" command you have to use "AT+CLTS=1" for only once.

This command will enable the module to remember the setting forever and each time the module reboots, module will send ACK to basestation to get timestamp at the beginning and the basestation will return the correct package.

After this use the command AT+CCLK? and capture the data as said earlier by Mr Jayanth..

Thanks a lot for your information.Now I can get the updated time from the Modem.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top