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

Files at this revision

API Documentation at this revision

Comitter:
stkim92
Date:
Thu Apr 13 01:50:52 2017 +0000
Parent:
1:f0c1fe04502c
Commit message:
added WIZwiki-W7500ECHO

Changed in this revision

SSD1306.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f0c1fe04502c -r 25b14c11c06c SSD1306.h
--- a/SSD1306.h	Thu Apr 13 01:14:01 2017 +0000
+++ b/SSD1306.h	Thu Apr 13 01:50:52 2017 +0000
@@ -6,6 +6,11 @@
 #define SCL                  PA_9
 #endif
 
+#if defined(TARGET_WIZwiki_W7500ECO)
+#define SDA                  PA_10
+#define SCL                  PA_9
+#endif
+
 I2C i2c(SDA, SCL);
 
 void send_cmd(uint8_t cmd){
diff -r f0c1fe04502c -r 25b14c11c06c main.cpp
--- a/main.cpp	Thu Apr 13 01:14:01 2017 +0000
+++ b/main.cpp	Thu Apr 13 01:50:52 2017 +0000
@@ -5,14 +5,14 @@
 
 #if defined(TARGET_WIZwiki_W7500)
     EthernetInterface eth;
- /*   DigitalOut led1(LED1);
-    DigitalOut led2(LED2);
-    DigitalOut led3(LED3);
-    DigitalOut led4(LED4); */
     DigitalIn  sw(PC_0);
-
+#endif
 
+#if defined(TARGET_WIZwiki_W7500ECO)
+    EthernetInterface eth;
+    DigitalIn  sw(PC_0);
 #endif
+
 TCPSocketConnection sock;
 
 DigitalOut myled(PA_6);