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

pin map

OLED (from WIZnet)

/media/uploads/stkim92/oled.png

Wiring Table

OLEDW7500
SCLPA_9
SDAPA_10
GNDGND
VCCVCC

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

no such method: docs