ThingSpeak Channel Does Not Update Automatically when using ESP8266 with AT Commands and C Programming Language
6 次查看(过去 30 天)
显示 更早的评论
I am very new to this area. My small project is as follows:
- MCU: NXP
- ESP8266 module
- C programming language with AT Commands for ESP8266
- IDE: Online Mbed Complier
- ThingSpeak Cloud Server
My goal is simply to simply read data (measurement) from a sensor and push it to ThingSpeak cloud. Part of my code with AT commands for ESP8266 module is as follows:
//Sending Data to the Cloud Server via ESP8266 WiFi Module
strcpy(snd,"AT+CIPMUX=0\n\r"); //AT+CIPMUX: Enabling Single Channel Mode
wifi.SendCMD(snd);
wait(1);
wifi.RcvReply(rcv, 1000);
wait(1);
sprintf(snd,"AT+CIPSTART=4,\"TCP\",\"%s\",80\n",CloudIP); //Establish TCP connection w/ Cloud Server
wait(1);
wifi.RcvReply(rcv, 1000);
wait(1);
strcpy(snd,"AT+CIPSEND=100\n\r"); //Set length of the data that will be sent
wifi.SendCMD(snd);
pc.printf("%s\r", rcv);
wait(1);
wifi.RcvReply(rcv, 1000);
pc.printf("%s\r", rcv);
wait(1);
//Pushing the data acquired from HC-SR04 Ultrasonic Sensor to Cloud Server via API
sprintf(snd,"GET https://api.thingspeak.com/update?api_key=3LV9GHWHJYDZNWEH&field1=%f \r\n\r\n", dist_percent);
pc.printf("%s\r",snd);
wifi.SendCMD(snd);
wait(1);
wifi.RcvReply(rcv, 1000);
pc.printf("%s\r", rcv);
Before this, I do initialization part for connecting my ESP module to my Wifi router. That works fine. No issues.
Problem: I need to click on the GET link as shown in the screenshot below, in order to update my ThingSpeak cloud server. I have tried many AT commands but none seems to automatically update cloud. Everytime, I have to open terminal (TeraTerm) and then double click on the link, which then opens a new web page with just a single digit. Then after I go back to my ThingSpeak Channel dashboard, I see the new value. Else, channel does not automatically update itself. Please note that I am only updating (writing the channel), not reading from it or anything.
(Screenshot with the GET link. When I double click on it, only then does my ThingSpeak Channel gets updated).
Is there a way to automate this? Am I missing any AT command or anything else? I apologize, I am new to programming ESP module and ThingSpeak server. So, your help will be much appreciated. Thank you for your time.
0 个评论
回答(1 个)
Vinod
2019-12-6
Have you looked at the examples in the ThingSpeak Communication Library? Specifically, this example might be a useful starting point.
0 个评论
社区
更多回答在 ThingSpeak Community
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Read Data from Channel 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!