InternetTime
The InternetTime sketch is a simplifies version of the ntpTest sketch. It does not use the library's SNTP client, but directly queries an NTP time server from pool.ntp.org to get the current "UNIX time" (seconds since 1/1/1970, UTC (GMT)).The sketch then uses the Arduino's internal timer to keep relative time. The clock is re-synchronized roughly once per day. This minimizes NTP server misuse/abuse.
The RTClib library (a separate download, and not used here) contains functions to convert UNIX time to other formats if needed.
To avoid unnecessary loading of NTP servers, please perform the time synchronization as infrequently as possible. Once per day or longer should be plenty to maintain reasonably accurate time.
Before you run the sketch, edit it to replace the dummy SSID and password with your own:
#define WLAN_SSID "yourNetwork" // cannot be longer than 32 characters! #define WLAN_PASS "yourPassword"
Also, make sure that the right wireless security scheme is selected (unsecured, WEP, WPA, or WPA2)
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2 #define WLAN_SECURITY WLAN_SEC_WPA2
Here's a sample of the Serial Monitor output of InternetTime. You should see something similar:
Hello, CC3000! RX Buffer : 131 bytes TX Buffer : 131 bytes Initialising the CC3000 ... Firmware V. : 1.19 MAC Address : 0x08 0x00 0x28 0x01 0xA8 0x8A Deleting old connection profiles Attempting to connect to fios63 Started AP/SSID scan Connecting to fios63...Waiting to connect...Connected! Request DHCP IP Addr: 192.168.1.23 Netmask: 255.255.255.0 Gateway: 192.168.1.1 DHCPsrv: 192.168.1.1 DNSserv: 192.168.1.1 Locating time server... Attempting connection... Connect to 62.116.162.126:123 connected! Issuing request... Awaiting response...OK Current UNIX time: 1378987424 (seconds since 1/1/1970 UTC) Current UNIX time: 1378987439 (seconds since 1/1/1970 UTC) Current UNIX time: 1378987454 (seconds since 1/1/1970 UTC) Current UNIX time: 1378987469 (seconds since 1/1/1970 UTC) … etc …
Text editor powered by tinymce.