Component: Real Time Clock (ESP32) (Real Time Clock)

From Flowcode Help
Jump to navigationJump to search
Author Matrix TSL
Version 1.0
Category Real Time Clock


Real Time Clock (ESP32) component

Allows an ESP32 device to act as a RTC with NTP type server synchronisation. Requires a WIFI network connection with internet access to synchronise. Provides simulation using local PC system time.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_RTC_ESP32.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_RTC_ESP32.fcfx

Detailed description

No detailed description exists yet for this component

Examples

A simple example that shows how to connect the ESP device to a network and synchronise the internal clock with an internet based NTP time server every hour.

FC6 Icon.png ESP32 RTC NTP Example


The internal clock can drift over time and so it is important to sync regularily with the NTP time server.


For low power operations or when internet connectivity may be intermittent a 32.768KHz crystal can be used with the ESP32 device to improve the internal clock accuracy over time.

The crystal is fitted between pins IO32 and IO33 and must have 12pF capacitors to ground. The crystal must also be enabled by editing the sdkconfig file in the project compilation directory.






Macro reference

GetDate

Fc9-comp-macro.png GetDate
Collects the day of the month as a numeric value in the range of 1 - 31. 
Fc9-u8-icon.png - BYTE Return


GetDateString

Fc9-comp-macro.png GetDateString
Collects the current date and returns it as a string. e.g. "DD/MM/YY" or "MM/DD/YY" 
Fc9-bool-icon.png - BOOL USFormat
Select date format: 0=DD/MM/YY, 1=MM/DD/YY 
Fc9-string-icon.png - STRING Return


GetHours

Fc9-comp-macro.png GetHours
Collects the current hour as a numeric value in the range of 0 - 23. 
Fc9-u8-icon.png - BYTE Return


GetMins

Fc9-comp-macro.png GetMins
Collects the current minute as a numeric value in the range of 0 - 59. 
Fc9-u8-icon.png - BYTE Return


GetMonth

Fc9-comp-macro.png GetMonth
Collects the month as a numeric value in the range of 1 - 12. 
Fc9-u8-icon.png - BYTE Return


GetSecs

Fc9-comp-macro.png GetSecs
Collects the current second as a numeric value in the range of 0 - 59. 
Fc9-u8-icon.png - BYTE Return


GetTimeString

Fc9-comp-macro.png GetTimeString
Collects the current time and returns it as a string. e.g. "HH:MM" or "HH:MM:SS" 
Fc9-bool-icon.png - BOOL IncludeSeconds
0=Dont Include Seconds, 1=Include Seconds in the String 
Fc9-string-icon.png - STRING Return


GetYear

Fc9-comp-macro.png GetYear
Collects the year as a numeric value in the range of 0 - 99. 
Fc9-u8-icon.png - BYTE Return


Initialise

Fc9-comp-macro.png Initialise
Configures the timeserver variable as well as sets the timezone offset in seconds. 
Fc9-void-icon.png - VOID Return


QueryTimeServer

Fc9-comp-macro.png QueryTimeServer
Attempt to collect the local time from the selected time server. The ESP WIFI must be connected to a network with internet to allow this to work. Returns true if the time server synchronised correctly with the ESP. 
Fc9-bool-icon.png - BOOL Return


ReadDate

Fc9-comp-macro.png ReadDate
 
Fc9-u8-icon.png - BYTE Unit
 
Fc9-u8-icon.png - BYTE Return


ReadTime

Fc9-comp-macro.png ReadTime
 
Fc9-u8-icon.png - BYTE Unit
 
Fc9-u8-icon.png - BYTE Return


SetDate

Fc9-comp-macro.png SetDate
Manually sets the current date. Useful for when WIFI / NTP commnication is not available. 
Fc9-u8-icon.png - BYTE Date
Day of the month ranging from 1 to 31 
Fc9-u8-icon.png - BYTE Month
Month ranging from 1 to 12 
Fc9-u8-icon.png - BYTE Year
Year ranging from 0 to 99 
Fc9-void-icon.png - VOID Return


SetTime

Fc9-comp-macro.png SetTime
Manually sets the current time. Useful for when WIFI / NTP commnication is not available. 
Fc9-u8-icon.png - BYTE Hour
Hour ranging from 0 to 23 
Fc9-u8-icon.png - BYTE Min
Minute ranging from 0 to 59 
Fc9-u8-icon.png - BYTE Sec
Second ranging from 0 to 59 
Fc9-void-icon.png - VOID Return


SetTimeServer

Fc9-comp-macro.png SetTimeServer
Overwrites the default time server setting allowing for multiple time servers to be queried. 
Fc9-string-icon.png - STRING TimeServer
e.g. "pool.ntp.org" 
Fc9-void-icon.png - VOID Return


SetUTCOffset

Fc9-comp-macro.png SetUTCOffset
Allows the UTC Offset to be defined in seconds. e.g. for BST use 3600 or for UTC+2 use 7200 or for UTC-2 use -7200 
Fc9-s32-icon.png - LONG UTCOffset
Time offset in seconds 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-10-icon.png Time Server
Default time server URL. Set as part of the initialise macro. Can be overridden using the SetTimeServer macro. 
Fc9-type-21-icon.png UTC Offset
Offset in seconds from UTC. Set as part of the initialise macro. Can be overridden using the SetUTCOffset macro. 
Fc9-type-21-icon.png Number of Retries
Sets the number of retries to connect to the SNTP server before giving up