The Smart Watch using SSD1306 and I2C. The Time obtain using SNTP protocol from NTP Server.
Dependencies: WIZnetInterface SNTPClinet mbed-dev
You are viewing an older revision! See the latest version
Homepage
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
connecting 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