Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user

Retrive Retrieve value from thinkspeakThingSpeak using ESP8266 with Arduino setup

I just started learning esp8266ESP8266 and in my first project I am successfully able to send data to thinkspeakThingSpeak.com using esp8266ESP8266 with following code:

uploadData() {
  String apiKey = "ESDS8678890SDDS";
  String myData = "45.5"; // example of data to send
  if (espClient.connect(server,80)) { 
    String postStr = apiKey; 
    postStr +="&field1=";
    postStr += String(myData);
    postStr += "\r\n\r\n";
 
    espClient.print("POST /update HTTP/1.1\n");
    espClient.print("Host: api.thingspeak.com\n");
    espClient.print("Connection: close\n");
    espClient.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
    espClient.print("Content-Type: application/x-www-form-urlencoded\n");
    espClient.print("Content-Length: ");
    espClient.print(postStr.length());
    espClient.print("\n\n");
    espClient.print(postStr);
    Serial.print(postStr);
    Serial.print("My Data: ");
    Serial.print(myData);
    Serial.print("\n");
  }
  espClient.stop();
}

But I have no idea how to retrieve data from thinkspeakThingSpeak using ESP8266.

// Using XXXXX here as my channel is private
GET https://api.thingspeak.com/channels/XXXXXX/fields/1.json?results=2 

I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.

Help would be appreciated. Thanks

Thanks.

Retrive value from thinkspeak using ESP8266 with Arduino setup

I just started learning esp8266 and in my first project I am successfully able to send data to thinkspeak.com using esp8266 with following code:

uploadData() {
String apiKey = "ESDS8678890SDDS";
String myData = "45.5"; // example of data to send
if (espClient.connect(server,80)) { 
String postStr = apiKey; 
postStr +="&field1=";
postStr += String(myData);
postStr += "\r\n\r\n";
 
espClient.print("POST /update HTTP/1.1\n");
espClient.print("Host: api.thingspeak.com\n");
espClient.print("Connection: close\n");
espClient.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
espClient.print("Content-Type: application/x-www-form-urlencoded\n");
espClient.print("Content-Length: ");
espClient.print(postStr.length());
espClient.print("\n\n");
espClient.print(postStr);
Serial.print(postStr);
Serial.print("My Data: ");
Serial.print(myData);
Serial.print("\n");
}
espClient.stop();
}

But I have no idea how to retrieve data from thinkspeak using ESP8266.

// Using XXXXX here as my channel is private
GET https://api.thingspeak.com/channels/XXXXXX/fields/1.json?results=2 

I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.

Help would be appreciated. Thanks

Retrieve value from ThingSpeak using ESP8266 with Arduino setup

I just started learning ESP8266 and in my first project I am successfully able to send data to ThingSpeak.com using ESP8266 with following code:

uploadData() {
  String apiKey = "ESDS8678890SDDS";
  String myData = "45.5"; // example of data to send
  if (espClient.connect(server,80)) {
    String postStr = apiKey;
    postStr +="&field1=";
    postStr += String(myData);
    postStr += "\r\n\r\n";
    espClient.print("POST /update HTTP/1.1\n");
    espClient.print("Host: api.thingspeak.com\n");
    espClient.print("Connection: close\n");
    espClient.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
    espClient.print("Content-Type: application/x-www-form-urlencoded\n");
    espClient.print("Content-Length: ");
    espClient.print(postStr.length());
    espClient.print("\n\n");
    espClient.print(postStr);
    Serial.print(postStr);
    Serial.print("My Data: ");
    Serial.print(myData);
    Serial.print("\n");
  }
  espClient.stop();
}

But I have no idea how to retrieve data from ThingSpeak using ESP8266.

// Using XXXXX here as my channel is private
GET https://api.thingspeak.com/channels/XXXXXX/fields/1.json?results=2 

I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.

Help would be appreciated.

Thanks.

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user

I just started learning ESP8266esp8266 and in my first project I am successfully able to send data to thinkspeak.com using ESP8266esp8266 with following code:

uploadData() {
String apiKey = "ESDS8678890SDDS";
String myData = "45.5"; // example of data to send
if (espClient.connect(server,80)) { 
String postStr = apiKey; 
postStr +="&field1=";
postStr += String(myData);
postStr += "\r\n\r\n";

espClient.print("POST /update HTTP/1.1\n");
espClient.print("Host: api.thingspeak.com\n");
espClient.print("Connection: close\n");
espClient.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
espClient.print("Content-Type: application/x-www-form-urlencoded\n");
espClient.print("Content-Length: ");
espClient.print(postStr.length());
espClient.print("\n\n");
espClient.print(postStr);
Serial.print(postStr);
Serial.print("My Data: ");
Serial.print(myData);
Serial.print("\n");
}
espClient.stop();
}

But I have no idea how to retrieve data from thinkspeak using ESP8266.

// Using XXXXX here as my channel is private

// Using XXXXX here as my channel is private
GET https://api.thingspeak.com/channels/XXXXXX/fields/1.json?results=2 

I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.

Help would be appreciated. Thanks

I just started learning ESP8266 and in my first project I am successfully able to send data to thinkspeak.com using ESP8266 with following code:

uploadData() {
String apiKey = "ESDS8678890SDDS";
String myData = "45.5"; // example of data to send
if (espClient.connect(server,80)) { 
String postStr = apiKey; 
postStr +="&field1=";
postStr += String(myData);
postStr += "\r\n\r\n";

espClient.print("POST /update HTTP/1.1\n");
espClient.print("Host: api.thingspeak.com\n");
espClient.print("Connection: close\n");
espClient.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
espClient.print("Content-Type: application/x-www-form-urlencoded\n");
espClient.print("Content-Length: ");
espClient.print(postStr.length());
espClient.print("\n\n");
espClient.print(postStr);
Serial.print(postStr);
Serial.print("My Data: ");
Serial.print(myData);
Serial.print("\n");
}
espClient.stop();
}

But I have no idea how to retrieve data from thinkspeak using ESP8266.

// Using XXXXX here as my channel is private

GET https://api.thingspeak.com/channels/XXXXXX/fields/1.json?results=2 

I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.

Help would be appreciated. Thanks

I just started learning esp8266 and in my first project I am successfully able to send data to thinkspeak.com using esp8266 with following code:

uploadData() {
String apiKey = "ESDS8678890SDDS";
String myData = "45.5"; // example of data to send
if (espClient.connect(server,80)) { 
String postStr = apiKey; 
postStr +="&field1=";
postStr += String(myData);
postStr += "\r\n\r\n";

espClient.print("POST /update HTTP/1.1\n");
espClient.print("Host: api.thingspeak.com\n");
espClient.print("Connection: close\n");
espClient.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
espClient.print("Content-Type: application/x-www-form-urlencoded\n");
espClient.print("Content-Length: ");
espClient.print(postStr.length());
espClient.print("\n\n");
espClient.print(postStr);
Serial.print(postStr);
Serial.print("My Data: ");
Serial.print(myData);
Serial.print("\n");
}
espClient.stop();
}

But I have no idea how to retrieve data from thinkspeak using ESP8266.

// Using XXXXX here as my channel is private
GET https://api.thingspeak.com/channels/XXXXXX/fields/1.json?results=2 

I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.

Help would be appreciated. Thanks

Post Migrated Here from electronics.stackexchange.com (revisions)
Source Link
Vicky Arora
  • 121
  • 1
  • 1
  • 4

Retrive value from thinkspeak using ESP8266 with Arduino setup

I just started learning ESP8266 and in my first project I am successfully able to send data to thinkspeak.com using ESP8266 with following code:

uploadData() {
String apiKey = "ESDS8678890SDDS";
String myData = "45.5"; // example of data to send
if (espClient.connect(server,80)) { 
String postStr = apiKey; 
postStr +="&field1=";
postStr += String(myData);
postStr += "\r\n\r\n";

espClient.print("POST /update HTTP/1.1\n");
espClient.print("Host: api.thingspeak.com\n");
espClient.print("Connection: close\n");
espClient.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
espClient.print("Content-Type: application/x-www-form-urlencoded\n");
espClient.print("Content-Length: ");
espClient.print(postStr.length());
espClient.print("\n\n");
espClient.print(postStr);
Serial.print(postStr);
Serial.print("My Data: ");
Serial.print(myData);
Serial.print("\n");
}
espClient.stop();
}

But I have no idea how to retrieve data from thinkspeak using ESP8266.

// Using XXXXX here as my channel is private

GET https://api.thingspeak.com/channels/XXXXXX/fields/1.json?results=2 

I think I have to use the above GET string to get the fields data. But I don't know how to create the request string.

Help would be appreciated. Thanks