Fail to Retrieve channel description

Serial.println("AT");
delay(1000);
Serial.print("AT+CIPSTART=3,\"TCP\",\"api.thingspeak.com\",80\r\n");
delay(3000);
Serial.print("AT+CIPSEND=3,");
Serial.print(68);
Serial.print("\r\n");
delay(2000);
Serial.print("GET /channels/");
Serial.print(channel_id);
Serial.print("/feeds.json?api_key=");
Serial.print(mystringchar);
Serial.print("&results=0 HTTP/1.1\r\n");
Serial.print("Host:");
Serial.print(DST_IP);
Serial.println(); //web link
delay(300);
unsigned long lastRead = millis();
while (millis() - lastRead < 5000) {
while (Serial.available())
{
if (Serial.find("description\":\""))
{
String message = Serial.readStringUntil('$');
Serial.flush();
Serial.println(message);
}
}
This code was working fine for our production since 3 years but presently we are unable to retrive description .please do suggest us .
we are using sim-800c and esp8266-12f

Respuestas (2)

Vinod
Vinod el 28 de Sept. de 2020

0 votos

Have you checked your GSM module to see that it still has data capacity? Nothing has changed on ThingSpeak early August that can be linked to what you are seeing.
Are you able to connect to any other site using the SIM-800C?

4 comentarios

Asha Rani
Asha Rani el 2 de Oct. de 2020
yes there is a data capacity but it should not be a problem with wifi module
Vinod
Vinod el 4 de Oct. de 2020
Editada: Vinod el 5 de Oct. de 2020
I am unable to reproduce the issue. Try this in your browser. This is the same request as you are trying to make from your device:
https://thingspeak.com/channels/366768/feeds.json?api_key=DoesNotMatter&results=0
Can you confirm that if you make the REST call using your Browser, POSTMAN or cURL from a desktop, you get the correct result?
Asha Rani
Asha Rani el 8 de Oct. de 2020
yes i am able to read the data
Vinod
Vinod el 8 de Oct. de 2020
Since the response is correct from POSTMAN and cURL, I suspect the issue is on your device code. I have pasted the Arduino sketch in my answer below that you can modify and try on your device.

Iniciar sesión para comentar.

Vinod
Vinod el 5 de Oct. de 2020
Editada: Vinod el 5 de Oct. de 2020
Here's a working Arduino Sketch I have tried on an ESP32. It can be modified as needed for your device.
#include <WiFi.h>
const char* ssid = "YourSSIDHere";
const char* password = "YourWifiPasswordHere";
WiFiClient client;
const char* host = "api.thingspeak.com";
void setup() {
Serial.begin(115200);
delay(100);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}
void loop() {
delay(5000);
if (!client.connect(host, 80)) {
Serial.println("connection failed");
return;
}
String url = "/channels/366768/feeds.json?api_key=DoesNotMatter&results=0&headers=false";
Serial.print("Requesting URL: ");
Serial.println(url);
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(500);
while(client.available()){
String line = client.readStringUntil('{');
line = client.readStringUntil('}');
Serial.print(line);
while(client.available()){client.readStringUntil('\r');}
Serial.print("\r\n");
}
delay(10000);
}

2 comentarios

Asha Rani
Asha Rani el 11 de Oct. de 2020
we are using ESP-8266 without the WiFi shield in the productionand the device has been working fine in the field but now we are facing issue for new production.
Vinod
Vinod el 15 de Oct. de 2020
Editada: Vinod el 15 de Oct. de 2020
If existing devices are working fine but new production devices are not, I would suggest looking at what might be different on the new devices. It could be that one of the libraries you use has changed, or something about the hardware (available memory, memory partitions, etc.?) has changed causing you to see different results.

Iniciar sesión para comentar.

Comunidades de usuarios

Más respuestas en  ThingSpeak Community

Categorías

Más información sobre Read Data from Channel en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 26 de Sept. de 2020

Editada:

el 15 de Oct. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by