The Smart Watch using SSD1306 and I2C. The Time obtain using SNTP protocol from NTP Server.
Dependencies: WIZnetInterface SNTPClinet mbed-dev
Prerequisite
This example is to obtain a time from NTP server using SNTP protocol.
To implement this function, you need a Platform board and OLED.
Below are what we used.
- WIZwiki-W7500 from WIZnet (Platform board)
- OLED from WIZnet
Hardware Configuration
WIZwiki-W7500 Pin map
OLED (from WIZnet)
Wiring Table
OLED | W7500 |
SCL | PA_9 |
SDA | PA_10 |
GND | GND |
VCC | VCC |
Software
Define Pins
SSD1306.h
#if defined(TARGET_WIZwiki_W7500) #define SDA PA_10 #define SCL PA_9 #endif
Connect to NTP server
main.cpp
SNTPClient sntp("time.nist.gov", 40); // timezone: Korea, Republic of sntp.connect();
Get Time
main.cpp
if(sntp.getTime(&ntptime) == true) { pc.printf("%d-%d-%d, %d:%d:%d\r\n", ntptime.yy, ntptime.mo, ntptime.dd, ntptime.hh, ntptime.mm, ntptime.ss); wait(1.0); } else { while(sntp.getTime(&ntptime) != true) { //break; } }
Caution
watchout pins setting
History
added WIZwiki-W7500ECHO
2017-04-13, by stkim92 [Thu, 13 Apr 2017 01:50:52 +0000] rev 2
added WIZwiki-W7500ECHO
change a mbed-src to mbed-dev
2017-04-13, by stkim92 [Thu, 13 Apr 2017 01:14:01 +0000] rev 1
change a mbed-src to mbed-dev
The Smart Watch using SSD1306 and I2C.; The Time obtain using SNTP protocol from NTP Server.
2015-06-26, by eunkyoungkim [Fri, 26 Jun 2015 00:56:23 +0000] rev 0
The Smart Watch using SSD1306 and I2C.; The Time obtain using SNTP protocol from NTP Server.