f
Dependencies: Adafruit_GFX HTTPClient WIZnetInterface mbed
Revision 0:758720663484, committed 2018-04-30
- Comitter:
- wiznetw7500
- Date:
- Mon Apr 30 05:03:25 2018 +0000
- Commit message:
- fff
Changed in this revision
diff -r 000000000000 -r 758720663484 Adafruit_GFX.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adafruit_GFX.lib Mon Apr 30 05:03:25 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/nkhorman/code/Adafruit_GFX/#7fb1d4d3525d
diff -r 000000000000 -r 758720663484 HTTPClient.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPClient.lib Mon Apr 30 05:03:25 2018 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/kaizen/code/HTTPClient/#9ba72b4d7ffc
diff -r 000000000000 -r 758720663484 WIZnetInterface.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WIZnetInterface.lib Mon Apr 30 05:03:25 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/teams/WIZnet/code/WIZnetInterface/#c91884bd2713
diff -r 000000000000 -r 758720663484 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 30 05:03:25 2018 +0000 @@ -0,0 +1,80 @@ +#include "mbed.h" +#include "EthernetInterface.h" +#include "Adafruit_SSD1306.h" +#include "HTTPClient.h" + + +#if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P) + uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x53, 0xAE, 0x90}; +#endif +// W7500 onboard LED & Init +DigitalOut rled(LED1,1); +DigitalOut gled(LED2,0); +DigitalOut bled(LED3,1); +AnalogIn Sensor(A0); +// I2C Class +I2C i2c(PA_10,PA_9); + +// OLED Class +Adafruit_SSD1306_I2c gOled(i2c,NC,0x78,64,128); +Serial pc(USBTX, USBRX); + +EthernetInterface eth; + +// Declare TCP Connection Class +TCPSocketConnection sock; + +DigitalOut myled(D1); + + + +int main() { + + + + int phy_link; + printf("Wait a second...\r\n"); + + eth.init(mac_addr); //Use DHCP + +printf("Check Ethernet Link\r\n"); + /*while(1) //Wait link up + { + if(eth.link() == true) + break; + }*/ + printf("Link up\r\n"); + + eth.connect(); + + printf("IP Address is %s\r\n\r\n", eth.getIPAddress()); + printf("MASK Address is %s\r\n\r\n", eth.getNetworkMask()); + printf("GATEWAY Address is %s\r\n\r\n", eth.getGateway()); + printf("MAC Address is %s\r\n\r\n", eth.getMACAddress()); + while(1){ + // TCP socket connect to openweather server + //TCPSocketConnection sock; + char send_data[1024]; + int CDS_data=3000; + sock.connect("api.thingspeak.com", 80); + + sprintf(send_data, "GET http://api.thingspeak.com/update?key=0Q8S3KCULT7GUDVR&field1=%d HTTP/1.0\n\n",CDS_data); + // GET method, to request weather forecast + // char http_cmd[] = "GET /update?api_key=0Q8S3KCULT7GUDVR&field1=2000 HTTP/1.0\n\n"; + + + sock.send_all(send_data, sizeof(send_data)-1); + + // get data into buffer + char buffer[2048]; + 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); + } + printf("\r\n\r\n"); + } +}
diff -r 000000000000 -r 758720663484 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Apr 30 05:03:25 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/994bdf8177cb \ No newline at end of file