![](/media/cache/group/WIZnet_logo_001.jpg.50x50_q85.jpg)
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.
Materials
WIZwiki-W7500 ( MCU )
WizFi250-EVB ( Wi-Fi Module )
Sensor Shield
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.
Demo Video
For more detailed information, refer to this URL.
Diff: main.cpp
- Revision:
- 3:1f2938317c31
- Parent:
- 2:3a84959399d3
- Child:
- 4:6d1627cfb314
--- a/main.cpp Thu Jul 30 04:25:13 2015 +0000 +++ b/main.cpp Wed Aug 26 00:44:40 2015 +0000 @@ -6,35 +6,35 @@ #define SECURE WizFi250::SEC_AUTO -#define SSID "ssid" -#define PASS "key" +#define SSID "wizms1" +#define PASS "maker0701" #if defined(TARGET_WIZwiki_W7500) - #define SDA PA_10 - #define SCL PA_9 +// #define SDA PA_10 +// #define SCL PA_9 WizFi250Interface wizfi250(D1,D0,D7,D8,PA_12,NC,115200); Serial pc(USBTX,USBRX); #endif // an SPI sub-class that provides a constructed default -class I2CPreInit : public I2C -{ -public: - I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) - { - frequency(100000); - start(); - }; -}; +//class I2CPreInit : public I2C +//{ +//public: +// I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) +// { +// frequency(100000); +// start(); +// }; +//}; -I2CPreInit gI2C(SDA,SCL); -Adafruit_SSD1306_I2c gOled(gI2C,NC,0x78,64,128); +//I2CPreInit gI2C(SDA,SCL); +//Adafruit_SSD1306_I2c gOled(gI2C,NC,0x78,64,128); NTPClient ntpClient; HTTPClient httpClient; void parse(char buffer[], int *j, char *string); //FUNCTION TO PARSE HTTP GET DATA -char httpGetData[200]; //BUFFER TO HOLD DATA FROM HTTP GET REQUEST +char httpGetData[1024]; //BUFFER TO HOLD DATA FROM HTTP GET REQUEST int main() @@ -53,8 +53,8 @@ int j=0, returnCode; pc.baud(115200); - gOled.begin(); - gOled.clearDisplay(); +// gOled.begin(); +// gOled.clearDisplay(); wizfi250.init(); returnCode = wizfi250.connect(SECURE, SSID, PASS); @@ -90,12 +90,14 @@ parse(httpGetData,&j,latitude); parse(httpGetData,&j,longitude); parse(httpGetData,&j,timeZone); - gOled.printf("HTTP Data Received\r\n"); - gOled.display(); + //gOled.printf("HTTP Data Received\r\n"); + //gOled.display(); + printf("HTTP Data Received\r\n"); } else { //HTTP GET REQUEST ERRORED - gOled.printf("HTTP Error %d\r\n", r); - gOled.display(); +// gOled.printf("HTTP Error %d\r\n", r); +// gOled.display(); + printf("HTTP Error %d\r\n", r); return -1; } printf("Reading Time...\r\n"); @@ -111,9 +113,13 @@ wait(3.0); char buffer[80]; //BUFFER TO HOLD FORMATTED TIME DATA - 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 +// 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 + printf("%s, %s %s, %s\r\n",city,stateAbrv,zip,countryAbrv); //PRINT CITY STATE AND ZIP INFORMATION AND COUNTRY + printf("LAT:%s\r\nLONG:%s\r\n",latitude,longitude); //PRINT LATITUDE AND LONGITUDE + printf("Timezone:%s\r\n",timeZone); //PRINT TIMEZONE + wizfi250.disconnect(); //DISCONNECT FROM THE NETWORK while (1) { @@ -121,9 +127,10 @@ 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)); - gOled.printf("Univ Time Clock\r\n%s\r\n", buffer); - gOled.display(); - gOled.setTextCursor(0,40); +// gOled.printf("Univ Time Clock\r\n%s\r\n", buffer); +// gOled.display(); +// gOled.setTextCursor(0,40); + printf("Univ Time Clock\r\n%s\r\n", buffer); wait(1); } }