Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 8 months ago.
Thingspeak channel not updating
Hi, I am having trouble updating my thingepeak channel. Whenever I run my code, I have to physically click on the http link to update my channel. How can I update the channel without clicking the link.
Here's my code:
strcpy(snd,"AT+CIPMUX=1\n");Setting WiFi into MultiChannel mode wifi.SendCMD(snd); pc.printf(snd); wait(2.0); wifi.RcvReply(rcv, 1000); pc.printf("%s\n", rcv); wait(2); sprintf(snd,"AT+CIPSTART=4,\"TCP\",\"%s\",80\n",IP); Initiate connection with THINGSPEAK server pc.printf(snd); wait(3.0); wifi.RcvReply(rcv, 1000); pc.printf("%s\n", rcv); wait(2); strcpy(snd,"AT+CIPSEND=4,47\n"); Send Number of open connections,Characters to send wifi.SendCMD(snd); pc.printf(snd); wait(2.0); wifi.RcvReply(rcv, 1000); pc.printf("%s\n", rcv); wait(2); sprintf(snd,"GET https://api.thingspeak.com/update?api_key=NVG5E6ZAB970OMRF&field1=%1.3f\n", c); Post values to thingspeak pc.printf("%s",snd); wifi.SendCMD(snd); wait(2); wifi.RcvReply(rcv, 1000); pc.printf("%s", rcv); wifi.SendCMD("AT+CIPCLOSE"); Close the connection to server wifi.RcvReply(rcv, 1000); pc.printf("%s", rcv);
1 Answer
4 years, 11 months ago.
Hey Siddharth Pimprikar, were you able to find the cause of this issue? I am having the same issue right now. Need to click on the GET <link> which then opens up a new web page, and then only my Thingspeak channel gets updated. So curious to know if you were able to figure out what exactly the problem was. Will help me a lot. Thanks!
Have you try using /r/n to instead of /n ? And I can't really understand the meaning of code "%1.3f". Is that mean you want your value have three numbers after point, and keep whole value length is 1 (included point)?
posted by Wen-ting Lo 17 Mar 2017Do I use /r/n everywhere or just while executing the GET command? Do you think that CIPSEND=4,47 is the problem?
posted by Siddharth Pimprikar 17 Mar 2017Just imagine you use terminal and send these command by keyboard to the wifi module, and \r\n will show up in the place where you need to press Enter. Use it when you finish every single command, but some command may demand other char in the end, just check manual for the module. And I check your code again, the command CIPSEND=4,47 just set your TCP/IP. Since I didn't use this module before, I supposed that the problem is that you didn't execute sending(AT+CIPSEND\r\n) after the setting the sending( CIPSEND=4,47\r\n ). Here has a website show the AT command of this moudle
https://github.com/espressif/ESP8266_AT/wiki/CIPSEND
BTW, if you have no idea how to use AT command, you can search for the application note of this module.
posted by Wen-ting Lo 17 Mar 2017Thanks a lot! I will look into it!
posted by Siddharth Pimprikar 17 Mar 2017