Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: WIZnetInterface mbed
Fork of TCPClient_HelloWorld by
Prerequisite
This example is for obtainning and printting data from server(OpenWeatherMap). WIZwiki-W7500ECO is TCP client mode.
To implement this function, you need a Platform board, network Interface board.
- WIZwiki-W7500ECO from WIZnet (Platform board and Ethernet I/F board) http://wizwiki.net/wiki/doku.php?id=products:wizwiki-w7500eco:start
Hardware Configuration
WIZwiki-W7500ECO Pin map

Software
Select the city
main.cpp
#include "mbed.h"
#include "EthernetInterface.h"
int main() {
int phy_link;
printf("Wait a second...\r\n");
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};
EthernetInterface eth;
eth.init(mac_addr); //Use DHCP
eth.connect();
do{
phy_link = eth.ethernet_link();
printf("...");
wait(2);
}while(!phy_link);
printf("\r\n");
printf("IP Address is %s\r\n", eth.getIPAddress());
TCPSocketConnection sock;
sock.connect("api.openweathermap.org", 80);
char http_cmd[] = "GET /data/2.5/weather?q=Seoul,kr HTTP/1.0\n\n";
sock.send_all(http_cmd, sizeof(http_cmd)-1);
char buffer[400];
int ret;
while (true) {
ret = sock.receive(buffer, sizeof(buffer)-1);
if (ret <= 0) break;
buffer[ret] = '\0';
printf("Received %d chars from server: %s\n", ret, buffer);
}
sock.close();
eth.disconnect();
}
Images

Changes
| Revision | Date | Who | Commit message |
|---|---|---|---|
| 0:af541535ef54 | 2016-05-30 | jehoon | TCP Client Example, WIZwiki-W7500.; It will get weather of South Korea from openweathermap.org; |
