ThingSpeak not showing any data from my ESP32!

7 ビュー (過去 30 日間)
Matheus Bitencourt
Matheus Bitencourt 2020 年 11 月 17 日
コメント済み: Vinod 2020 年 11 月 17 日
It seems like the site isn't receiving any data. The graphics are empty!
Could you please help me? Here's the source code!
Thanks so much!
#ifdef __cplusplus
extern "C" {
#endif
uint8_t temprature_sens_read();
#ifdef __cplusplus
}
#endif
uint8_t temprature_sens_read();
#include <WiFi.h>
String apiKey = "BE7U15RJYY57AV91"; // Enter your Write API key from ThingSpeak
const char *ssid = "Ashish"; // replace with your wifi ssid and wpa2 key
const char *pass = "12345678";
const char* server = "api.thingspeak.com";
WiFiClient client;
void setup()
{
Serial.begin(115200);
delay(10);
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}
void loop()
{
int h = 0;
float t =0;
h = hallRead();
t = ((temprature_sens_read()-32)/1.8); //changing temperature parameter to celsius
if (client.connect(server,80)) // "184.106.153.149" or api.thingspeak.com
{
String postStr = apiKey;
postStr +="&field1=";
postStr += String(h);
postStr += "&field2=";
postStr += String(t);
postStr += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
Serial.print("Hall: ");
Serial.println(h);
Serial.print("Temperature:");
Serial.print(t);
Serial.println(" C");
Serial.println("%. Send to Thingspeak.");
}
client.stop();
Serial.println("Waiting...");
delay(10000);
}

回答 (1 件)

Vinod
Vinod 2020 年 11 月 17 日
I strongly recommend using the ThingSpeak library and starting from the examples provided with it.
  2 件のコメント
Matheus Bitencourt
Matheus Bitencourt 2020 年 11 月 17 日
Thank you so much.
After using ThingSpeak library, I was able to upload the data!
However, I can't upload more than ONE field for Channel. Can you help me? https://www.mathworks.com/matlabcentral/answers/651273-unable-to-send-data-to-two-fields-at-the-same-channel-can-you-help-me
Vinod
Vinod 2020 年 11 月 17 日
Did you try this example?

サインインしてコメントする。

コミュニティ

その他の回答  ThingSpeak コミュニティ

カテゴリ

Help Center および File ExchangeREST API についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by