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

Committer:
stkim92
Date:
Thu Apr 13 01:50:52 2017 +0000
Revision:
2:25b14c11c06c
Parent:
1:f0c1fe04502c
added WIZwiki-W7500ECHO

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stkim92 1:f0c1fe04502c 1 https://mbed.org/users/mbed_official/code/mbed-dev/#e13f6fdb2ac4