Transmit data from mbed to thingspeak using wifi module

Dependencies:   HTTPClient WiflyInterface mbed

Revision:
0:2474e21be40b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 12 05:21:53 2018 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "WiflyInterface.h"
+#include "HTTPClient.h"
+
+
+WiflyInterface wifly(p9, p10, p30, p29, "Don", "don123456", WPA);
+Serial pc (USBTX, USBRX);
+AnalogIn moisture(p15);
+DigitalOut myled1(LED1);
+HTTPClient http;
+//I2C tempsensor(p28, p27); //sda, sc1
+//const int addr = 0x90;
+//char config_t[2];
+//char temp_read[2];
+//float temp;
+
+
+
+
+int main() {
+    
+    wifly.init(); //Use DHCP
+ 
+    wifly.connect();
+    
+    pc.printf("\nClient IP Address is %s\n\r", wifly.getIPAddress());
+   
+    
+    
+    float value=0;
+    
+
+while(1) {
+
+    
+    //char buf[24];
+        
+        char urlBuffer[100];
+        //sprintf (buf, value1);
+        value = moisture;
+        
+        int value1 = (int)(value * 1000);
+        sprintf(urlBuffer, "https://api.thingspeak.com/update?api_key=KQ8Z2C2RTE2B2FWV&field1=%d", value1); //url for update thingspeak data
+        printf("Send to %s\r\n", urlBuffer);
+        //http.get
+        http.get(urlBuffer, urlBuffer, 100);
+       
+       wait(16); // limited by ThingSpeak's API
+ 
+}
+}
\ No newline at end of file