Geolocation and NTP Example for WizFi250 on WIZwiki-W7500

Dependencies:   Adafruit_GFX HTTPClient NTPClient WizFi250Interface mbed

System Diagram

I want to make a watch, that can check my location and time. So I decide to make this watch using Wi-Fi module(WizFi250) and Cortex-M0 MCU(WIZwiki-W7500). For getting geolocation of this watch, I used ip-api.com which geolocation server and I used NTP server for getting current time. This picture is system diagram of my project.

https://c1.staticflickr.com/1/535/18550462294_5055005f04_c.jpg

Materials

WIZwiki-W7500 ( MCU )

https://c4.staticflickr.com/4/3925/19135560186_bd20acc860_z.jpg

WizFi250-EVB ( Wi-Fi Module )

https://c1.staticflickr.com/1/331/18975741359_366b5494b7_n.jpg

Sensor Shield

https://c4.staticflickr.com/4/3692/18974815038_9fda4569f1_n.jpg

SSD1306 OLED

Refer to this URL.

https://developer.mbed.org/components/Adafruit-OLED-128x32/

Hardware Configuration

UART0 RX/TX/CTS/RTS pins of WIZwiki-W7500 board are used to control WizFi250 which Wi-Fi module and It use I2C SDA/SCL pins for using SSD1306 OLED.

https://c4.staticflickr.com/4/3913/19010999888_3b30c685dd_c.jpg

/media/uploads/kaizen/20150731_084716.png

Demo Video

For more detailed information, refer to this URL.

http://www.life4iot.com/2015/07/08/wizfi250-geolocation-and-ntp-example-on-wizwiki-w7500-of-mbed-platform/?lang=en

Revision:
1:741b858c0b92
Parent:
0:bc0fe324d7e2
Child:
2:3a84959399d3
--- a/main.cpp	Thu Jun 25 05:20:13 2015 +0000
+++ b/main.cpp	Fri Jun 26 11:04:33 2015 +0000
@@ -11,10 +11,10 @@
 
 
 #if defined(TARGET_WIZwiki_W7500)
-#define SDA                  PA_10
-#define SCL                  PA_9
-WizFi250Interface wizfi250(D1,D0,D7,D8,PA_12,NC,115200);
-
+    #define SDA                  PA_10
+    #define SCL                  PA_9
+    WizFi250Interface wizfi250(D1,D0,D7,D8,PA_12,NC,115200);
+    Serial pc(USBTX,USBRX);
 #endif
 
 
@@ -39,9 +39,6 @@
 
 int main()
 {
-    S_UART_Init(115200);
-
-
     time_t ctTime; //system time structure
     char success[10]={0};  //success first
     char countryFull[20]={0}; //Full Country Name
@@ -55,6 +52,10 @@
     char timeZone[30]={0}; //timeZone
     int j=0, returnCode;
 
+    pc.baud(115200);
+    gOled.begin();
+    gOled.clearDisplay();
+
     wizfi250.init();
     returnCode = wizfi250.connect(SECURE, SSID, PASS);
 
@@ -89,13 +90,12 @@
         parse(httpGetData,&j,latitude);
         parse(httpGetData,&j,longitude);
         parse(httpGetData,&j,timeZone);
-        printf("GEOLOCATION DATA RECIEVED\r\n");
-        printf("success : %s, countryFull : %s, countryAbrv : %s, stateAbrv : %s\r\n",success, countryFull, countryAbrv, stateAbrv);
-        printf("stateFull : %s, city : %s, zip : %s, latitude : %s\r\n",stateFull, city, zip, latitude);
-        printf("longitude : %s, timeZone : %s\r\n",longitude, timeZone);
+        gOled.printf("HTTP Data Received\r\n");
+        gOled.display();
     } 
     else { //HTTP GET REQUEST ERRORED
-        printf("HTTP Error %d\r\n", r);
+        gOled.printf("HTTP Error %d\r\n", r);
+        gOled.display();
         return -1;
     }
     printf("Reading Time...\r\n");
@@ -111,9 +111,9 @@
     wait(3.0);
 
     char buffer[80]; //BUFFER TO HOLD FORMATTED TIME DATA
-    printf("%s, %s %s\r\n",city,stateAbrv,zip); //PRINT CITY STATE AND ZIP INFORMATION
-    printf("%s\r\nLAT:%s\r\nLONG:%s\r\n",countryAbrv,latitude,longitude); //PRINT COUNTRY and LATITUDE AND LONGITUDE 
-    printf("Timezone:\r\n%s\r\n",timeZone); //PRINT TIMEZONE
+    gOled.printf("%s, %s %s, %s\r\n",city,stateAbrv,zip,countryAbrv); //PRINT CITY STATE AND ZIP INFORMATION AND COUNTRY
+    gOled.printf("LAT:%s\r\nLONG:%s\r\n",latitude,longitude); //PRINT LATITUDE AND LONGITUDE 
+    gOled.printf("Timezone:%s\r\n",timeZone); //PRINT TIMEZONE
 
     wizfi250.disconnect(); //DISCONNECT FROM THE NETWORK 
     while (1) {
@@ -121,7 +121,9 @@
         ctTime = time(NULL)+(3600*9);  //TIME with offset for eastern time KR
         //FORMAT TIME FOR DISPLAY AND STORE FORMATTED RESULT IN BUFFER
         strftime(buffer,80,"%a %b %d\r\n%T %p %z\r\n %Z\r\n",localtime(&ctTime));
-        printf("Univ Time Clock\r\n%s\r\n", buffer);
+        gOled.printf("Univ Time Clock\r\n%s\r\n", buffer);
+        gOled.display();
+        gOled.setTextCursor(0,40);
         wait(1);
     }      
 }