Eduvance ThingSpeak code using ESP8266 and FRDM KL25Z.

Dependencies:   ESP8266 mbed

Fork of thingspeak by Eduvance IoTLabs

Revision:
1:8ab009672555
Parent:
0:34d3f68b920e
--- a/main.cpp	Sat Mar 18 09:00:35 2017 +0000
+++ b/main.cpp	Sat Jun 17 09:53:27 2017 +0000
@@ -4,31 +4,29 @@
 Serial pc(USBTX,USBRX);
 
 //POT sensor 
-AnalogIn pot(PTB0); 
+AnalogIn pot(PTB0);
 
 //wifi UART port and baud rate
 ESP8266 wifi(PTE0, PTE1, 115200); 
 
 //buffers for wifi library
-char snd[255],resp[1000];
+char resp[1000];
 char http_cmd[300], comm[300];
 
 int timeout = 8000; //timeout for wifi commands
 
 //SSID and password for connection
-#define SSID "eduvanceAP" //"AmeyaHotspot"//"IoTServer" //"AmeyaHotspot" //"Xperia S_f19d" 
-#define PASS "winteriscoming"  //"12345678" //"iotserver"  //"12345678" //"profpappu" 
+#define SSID "Eduvance" 
+#define PASS "eduvance123"  
 
 //Remote IP
 #define IP "184.106.153.149"
-//#define IP "https://api.thingspeak.com"
-//#define IP "192.168.0.25"
-//waterlevelue global variable
-float waterlevel = 0; 
 
-//Public and private keys for phant
-char* Update_Key = "4K5STYBPH6MC8O54";
-//char* Private_Key = "GPoWnRM60yidrB0e1pXD";
+//global variable
+float potvalue = 0; 
+
+//Update key for thingspeak
+char* Update_Key = "O1VOWGC3WXI981H6";
  
 //Wifi init function
 void wifi_initialize(void){
@@ -93,19 +91,15 @@
     wait(1);
     
     //create link 
-    sprintf(http_cmd,"/update?api_key=%s&field1=%f",Update_Key,waterlevel); 
+    sprintf(http_cmd,"/update?api_key=%s&field1=%f",Update_Key,potvalue); 
     pc.printf(http_cmd);
     
     pc.printf("******** Sending URL to wifi ********\r\n");
     wifi.sendURL(http_cmd, comm);   //cipsend and get command
     if (wifi.RcvReply(resp, timeout))    
         pc.printf("%s",resp);    
- 
-    pc.printf("No response while sending URL \r\n");
-    
-    //wifi.SendCMD("AT+CIPCLOSE"); //Close the connection to server
-    //wifi.RcvReply(resp, timeout);
-    //pc.printf("%s", resp);
+    else
+        pc.printf("No response while sending URL \r\n");
 }
 
 int main () {
@@ -114,10 +108,10 @@
     wifi_initialize();
     
     while (1) {
-        waterlevel = 255*pot.read();
-        pc.printf("Current waterlevel is = %.3f \r\n", waterlevel);
+        potvalue = 255*pot.read();
+        pc.printf("Current potvalue is = %.3f \r\n", potvalue);
         
         wifi_send();
-        //wait(5);
+        wait(30);
     }
 }
\ No newline at end of file