-->
Page 1 of 2

thingspeak with new sdk

PostPosted: Sat Jan 31, 2015 4:49 am
by alonewolfx2
i am trying to post data to thingspeak with new at example from 0.9.5 sdk and i didnt make it work. the code working with my local server but it seems something wrong with my request so thingspeak loging not working. here is code.
i tried on sockettest3 and i connect thingspeak with this ip and just send "GET /update?key=mykey&field1=9" and its updating. so i wrote this code. anyone have any idea?
Code: Select all#define TCPSERVERIP   "184.106.153.149"
#define TCPSERVERPORT 80

static void ICACHE_FLASH_ATTR
at_tcpclient_connect_cb(void *arg)
{
   struct espconn *pespconn = (struct espconn *)arg;
   #ifdef PLATFORM_DEBUG
   at_port_print("TCP client connect\r\n");
   #endif
   espconn_regist_sentcb(pespconn, at_tcpclient_sent_cb);
   //espconn_regist_recvcb(pespconn, at_tcpclient_recv);
   espconn_regist_disconcb(pespconn, at_tcpclient_discon_cb);
   char payload[128];
//1
   os_sprintf(payload,"GET /update?key=mykey&field1=9");
   #ifdef PLATFORM_DEBUG
   at_port_print(payload);
   #endif
   espconn_sent(pespconn, payload, strlen(payload));
}


also i tried this code with host and other parameters but its not working too.(with os_delay and without os_delay not working.)
Code: Select allstatic void ICACHE_FLASH_ATTR
at_tcpclient_connect_cb(void *arg)
{
   struct espconn *pespconn = (struct espconn *)arg;
   #ifdef PLATFORM_DEBUG
   at_port_print("TCP client connect\r\n");
   #endif
   espconn_regist_sentcb(pespconn, at_tcpclient_sent_cb);
   //espconn_regist_recvcb(pespconn, at_tcpclient_recv);
   espconn_regist_disconcb(pespconn, at_tcpclient_discon_cb);
   char payload[128];
//1
   os_sprintf(payload,"GET /update?key=mykey&field1=9 HTTP/1.1\r\n");
   #ifdef PLATFORM_DEBUG
   at_port_print(payload);
   #endif
   espconn_sent(pespconn, payload, strlen(payload));
   os_delay_us(500*1000);
//2
   os_sprintf(payload,"Host: api.thingspeak.com\r\n");
   #ifdef PLATFORM_DEBUG
   at_port_print(payload);
   #endif
   espconn_sent(pespconn, payload, strlen(payload));
   os_delay_us(500*1000);
//3
      os_sprintf(payload,"Accept: */*\r\n");
   #ifdef PLATFORM_DEBUG
   at_port_print(payload);
   #endif
   espconn_sent(pespconn, payload, strlen(payload));
   os_delay_us(500*1000);
//4
   os_sprintf(payload,"User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n");
   #ifdef PLATFORM_DEBUG
   at_port_print(payload);
   #endif
   espconn_sent(pespconn, payload, strlen(payload));
   os_delay_us(500*1000);
//5
   os_sprintf(payload,"\r\n");
   #ifdef PLATFORM_DEBUG
   at_port_print(payload);
   #endif
   espconn_sent(pespconn, payload, strlen(payload));
   os_delay_us(500*1000);
}

Re: thingspeak with new sdk

PostPosted: Mon Feb 02, 2015 10:10 pm
by Athena
How about refer to IOT_Demo which in folder "example"
http://bbs.espressif.com/viewtopic.php?f=5&t=154

refer to "user_esp_platform_upgrade_begin"

and the define of "pheadbuffer"

Re: thingspeak with new sdk

PostPosted: Tue Feb 03, 2015 2:42 am
by piontec
ThingSpeak worked like a charm for me, see here: https://github.com/piontec/esp_rest/blob/master/user/user_main.c#L111, but it was when my esp could get an IP from the server ;)

Re: thingspeak with new sdk

PostPosted: Tue Feb 03, 2015 3:47 am
by alonewolfx2
which sdk you are using?
piontec wrote:ThingSpeak worked like a charm for me, see here: https://github.com/piontec/esp_rest/blob/master/user/user_main.c#L111, but it was when my esp could get an IP from the server ;)