LED COontrol Using Thingspeak

Dependencies:   ESP8266 mbed

Fork of ESP8266-FRDM-KL25Z-THINGSPEAK by Karkhana Makerspace

Revision:
5:7d9cea3f910f
Parent:
3:1722a03793c6
--- a/main.cpp	Tue May 22 05:02:54 2018 +0000
+++ b/main.cpp	Fri Jul 06 07:56:21 2018 +0000
@@ -15,17 +15,17 @@
 int timeout = 5000; //timeout for wifi commands
 
 //SSID and password for connection 
-#define SSID "Karkhana"     
+#define SSID "Airtel WeFe"     
 #define PASS "Karkhana2018"  
 void control_led(void);
 //Remote IP
-#define IP "184.106.153.149"          // IP for thingspeak server. Remains same for al codes using thingspeak
+#define IP "192.168.0.105"          // IP for thingspeak server. Remains same for al codes using thingspeak
 //#define IP "192.168.0.25"
 //waterlevelue global variable
 int ledstatus=0;
 
 //Public and private keys for phant
-char* Update_Key = "QRCE7DOPVY3I49YN";                   // Copy the read key for your channel and paste it here.
+//char* Update_Key = "QRCE7DOPVY3I49YN";                   // Copy the read key for your channel and paste it here.
 //char* Private_Key = "GPoWnRM60yidrB0e1pXD";
  
 //Wifi init function. Sets the module to connect to wifi accesspoint with ssid and password mentioned above
@@ -82,7 +82,7 @@
 void wifi_send(void){
     
     pc.printf("******** Starting TCP connection on IP and port ********\r\n");
-    wifi.startTCPConn(IP,80);    //cipstart
+    wifi.startTCPConn(IP,1880);    //cipstart
     wifi.RcvReply(resp, timeout);
     if (wifi.RcvReply(resp, timeout))    
         pc.printf("%s",resp);    
@@ -91,7 +91,7 @@
     wait(1);
     
     //create link 
-    sprintf(http_cmd,"/channels/501352/fields/1.json?api_key=%s&results=2",Update_Key);              // Forms the url for transmitting to thingspeak server. the format can be seen on thingspeak site as well
+    sprintf(http_cmd,"/status?");              // Forms the url for transmitting to thingspeak server. the format can be seen on thingspeak site as well
     pc.printf(http_cmd);
     
     pc.printf("******** Sending URL to wifi ********\r\n");
@@ -117,7 +117,7 @@
     ledstatus=int(resp[length-13]);
     pc.printf("LED Status is %c\r\n",resp[length-13]);
     pc.printf("LED status is %d\r\n",ledstatus);
-    if(resp[length-13]==49){
+    if(resp[length-13]==116){
         pc.printf("LED ON");
         rled=0;
         }