PSOC5 LP + SIM800A GSM module Interfacing to read Time and Date using AT+CCLK?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Y_r
Level 4
Level 4
50 replies posted 50 sign-ins 25 replies posted

Hello Everyone,

I have been trying to get a system consisting of PSOC5 LP and SIM800A GSM module communicating to each other over a dedicated UART channel, and another UART channel for communication between PSOC5 LP and PC.

I have a problem where I need to read the date and time from the GSM module using AT commands and then store the date and time values (which come as a string as a response from the GSM module) as global variables to be used program a RTC connected to the system.

I have followed this tutorial and can see that I can see the date and time from the module while interfacing with an Arduino manually.

I am aware of how to send AT commands to GSM module, but can't seem to understand how to read or parse or store the responses from the GSM module in response to the AT commands.

 

Can anyone help me to read and store (to then reformat the string later) the time and date from the GSM module using PSOC5 LP?

 

I am attaching a simple two_uarts_mod project, which I could use to manually send the AT commands and read the time and date (but can't seem to find a way for the PSOC to read the response back from the GSM module). 

 

Thanks and Regards,
Yash

0 Likes
1 Solution
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Y_r,

Attached is updated project. Remember, that I don't have the module, and it is simulated by the UART terminal. Upon start, the PCoC sends a message to request a time/Clock

AT+CCLK?

Once you see this message on the Terminal, type a response (followed by LF+CR)

+CCLK: "22/09/11,05:30:43-01"

 

The PSoC shall receive this response and parse it into individual year, month, etc... and display it on terminal for debugging.

SIM800_02a_UART.png

 

View solution in original post

8 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Y_r,

You can use this project as an example

UART string reception garbage value

 

It shows how to receive a  LF or CR terminated strings from the UART Terminal. I believe that NMEA strings are the same. Once a compete NMEA string is received, parse it to extract data.

0 Likes
Y_r
Level 4
Level 4
50 replies posted 50 sign-ins 25 replies posted

Hi @odissey1 , @Len_CONSULTRON , @MotooTanaka san,

I followed the project which you pointed out to as a reference and tried to send a simple "AT\r\n" command to the GSM module, but I could only see the local echo being printed onto the terminal.

When I tried to use the debug view in Eclipse to see if the control was reaching for the IsCharReady() in the attached firmware (minimal build attached), it was not going into the function loop for checking the response.

Can you please let me know what i could be doing wrong here or what else needs to be added/modified to get the response from the GSM ("OK\r\n" in this case) and store it to a buffer?

Thanks and Regards,
Yash

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Y_r,

Attached is a demo project of receiving and extracting the Timestamp data from the SIM800 using PSoC5 Prototyping Board Kit-059. The Kit should be connected to the UART terminal, emulating the SIM800, and the following message must be typed (followed by LF, CR)

+CLTS: "22/09/11,05:30:43-01"  

This should represent typical SIM800 response for the Timestamp request 'AT+CLTS=?'.

PSoC5 UART receives this message and extracts parameters for year, Month, day, hour, minute, second and time zone, converts them into integers and stores in the global Timestamp buffer for the future use.

      The code is based on the SIM800 AT Command Manual v1.10, as I don't have the actual hardware module.

Project Archive is attached.

/odissey1

Figure 1. Project schematic. By default 57kbd communication is used to communicate to the UART Terminal.  SIM800_01a_A.png

 

Figure 2. UART output following sent Timestamp string: +CLTS: "22/09/11,05:30:43-01"  

SIM800_01a_UART.png

Figure 3. CY8CKIT-059 connection to UART Terminal. Note that no physical connection to Pins 12.6 and 12.7 exist, as communication is handled by the USB-UART converter built into the KitProg.

SIM800_01a_Kit-059.png

Y_r
Level 4
Level 4
50 replies posted 50 sign-ins 25 replies posted

Hi @odissey1 .

Thanks for sharing yet another sample project with me and I can confirm that I see the same output as you have mentioned.

But I believe the firmware you shared is kind of opposite to what I wanted help with.

The current firmware takes +CLTS: "22/09/11,05:30:43-01" as input and stores the values into variables and prints it onto the terminal.
But my app request was to be able to send "AT+CCLK?" command to the SIM800 module, which retrieves the network local time and date and then prints them onto the terminal, like below:
Y_r_0-1662972702496.png

I would like to store this retrieved time and date from the "response of the AT+CCLK?" and then use those stored values later for configuring an RTC attached to my PSOC.

Hope this clarifies on what issue I am facing.

Regards.
Yash

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Y_r,

Attached is updated project. Remember, that I don't have the module, and it is simulated by the UART terminal. Upon start, the PCoC sends a message to request a time/Clock

AT+CCLK?

Once you see this message on the Terminal, type a response (followed by LF+CR)

+CCLK: "22/09/11,05:30:43-01"

 

The PSoC shall receive this response and parse it into individual year, month, etc... and display it on terminal for debugging.

SIM800_02a_UART.png

 

Y_r
Level 4
Level 4
50 replies posted 50 sign-ins 25 replies posted

Hi @odissey1 ,

Thanks for the help.

I managed to get the project working, utilizing two UARTS, one between PC and PSOC and another between PSOC and SIM800A module.

And then use the received buffer to program an attached RTC module.


Thanks for your help.

Regards.
Yash

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Y_r,

glad it worked. Since you have an experience with SIM800 module, does it need a fee or registration to send/receive SMS messages? 

0 Likes
Y_r
Level 4
Level 4
50 replies posted 50 sign-ins 25 replies posted

Hi @odissey1 ,

Yes. you would need to recharge the SIM card in the SIM800 module, with an appropriate voice, SMS or data plan, depending upon the carrier plans on offer.

PS: Make sure the SIM or Carrier Network you tend to use still supports the 2G infrastructure since SIM800 module only supports 2G telecom protocol.

Regards.
Yash