Unable to Visualize using ThingsSpeak

10 vues (au cours des 30 derniers jours)
Nakul
Nakul le 25 Août 2025
Modifié(e) : Nakul le 9 Sep 2025
Respected All,
I am using Ardunio 2.3.6 for sending temperature and humiditiy data using (DHT11) and ESP 32. I am using ThingsSpeaks API for coding and have input the right API key and also started laptop's hotspot for connecting to ESP 32.
I have used to below code for completing this task.
#include <WiFi.h>
#include <HTTPClient.h>
#include <DHT.h>
// ===== USER CONFIG =====
const char* WIFI_SSID = "LAPTOP";
const char* WIFI_PASS = "J70524*";
String WRITE_API_KEY = "S627V5JFJI6I";
// =======================
#define DHTPIN 4 // GPIO4 on ESP32
#define DHTTYPE DHT11 // or DHT22
DHT dht(DHTPIN, DHTTYPE);
const char* server = "http://api.thingspeak.com/update";
unsigned long lastPost = 0;
const unsigned long postIntervalMs = 20000; // >= 15s required
void setup() {
Serial.begin(115200);
dht.begin();
WiFi.begin(WIFI_SSID, WIFI_PASS);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected. IP: ");
Serial.println(WiFi.localIP());
}
void loop() {
unsigned long now = millis();
Serial.println("Data sent to ThingSpeak.");
if (now - lastPost < postIntervalMs) return;
lastPost = now;
Serial.println("Data sent to ThingSpeak.");
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
String url = server + String("?api_key=") + WRITE_API_KEY +
"&field1=" + String(t, 1) +
"&field2=" + String(h, 1);
http.begin(url);
int httpCode = http.GET();
if (httpCode > 0) {
Serial.println("Data sent to ThingSpeak.");
} else {
Serial.println("HTTP Error: " + String(httpCode));
}
http.end();
}
Serial.print("Temp: ");
Serial.print(t, 1);
Serial.print(" °C, Humidity: ");
Serial.print(h, 1);
Serial.println(" %");
}
The output of this code is as under:-
Sketch uses 1042243 bytes (79%) of program storage space. Maximum is 1310720 bytes.
Global variables use 46588 bytes (14%) of dynamic memory, leaving 281092 bytes for local variables. Maximum is 327680 bytes.
esptool v5.0.0
Serial port COM9:
Connecting.....
Connected to ESP32 on COM9:
Chip type: ESP32-D0WD-V3 (revision v3.1)
Features: Wi-Fi, BT, Dual Core + LP Core, 240MHz, Vref calibration in eFuse, Coding Scheme None
Crystal frequency: 40MHz
MAC: f8:b3:b7:44:4f:cc
Uploading stub flasher...
Running stub flasher...
Stub flasher running.
Changing baud rate to 921600...
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00007fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x0010efff...
Compressed 25168 bytes to 16063...
Writing at 0x00001000 [ ] 0.0% 0/16063 bytes...
Writing at 0x00007250 [==============================] 100.0% 16063/16063 bytes...
Wrote 25168 bytes (16063 compressed) at 0x00001000 in 0.6 seconds (331.1 kbit/s).
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000 [ ] 0.0% 0/146 bytes...
Writing at 0x00008c00 [==============================] 100.0% 146/146 bytes...
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (490.6 kbit/s).
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000 [ ] 0.0% 0/47 bytes...
Writing at 0x00010000 [==============================] 100.0% 47/47 bytes...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (681.1 kbit/s).
Hash of data verified.
Compressed 1042384 bytes to 664444...
Writing at 0x00010000 [ ] 0.0% 0/664444 bytes...
Writing at 0x0001c60c [ ] 2.5% 16384/664444 bytes...
Writing at 0x000286db [> ] 4.9% 32768/664444 bytes...
Writing at 0x000301d2 [=> ] 7.4% 49152/664444 bytes...
Writing at 0x0003ff56 [=> ] 9.9% 65536/664444 bytes...
Writing at 0x00045a45 [==> ] 12.3% 81920/664444 bytes...
Writing at 0x0004b56a [===> ] 14.8% 98304/664444 bytes...
Writing at 0x00050b3c [====> ] 17.3% 114688/664444 bytes...
Writing at 0x00055f86 [====> ] 19.7% 131072/664444 bytes...
Writing at 0x0005b734 [=====> ] 22.2% 147456/664444 bytes...
Writing at 0x0006081b [======> ] 24.7% 163840/664444 bytes...
Writing at 0x00065f0c [=======> ] 27.1% 180224/664444 bytes...
Writing at 0x0006b4ba [=======> ] 29.6% 196608/664444 bytes...
Writing at 0x00070af1 [========> ] 32.1% 212992/664444 bytes...
Writing at 0x000766d8 [=========> ] 34.5% 229376/664444 bytes...
Writing at 0x0007badc [==========> ] 37.0% 245760/664444 bytes...
Writing at 0x0008106c [==========> ] 39.5% 262144/664444 bytes...
Writing at 0x00086546 [===========> ] 41.9% 278528/664444 bytes...
Writing at 0x0008bb3c [============> ] 44.4% 294912/664444 bytes...
Writing at 0x00090d01 [=============> ] 46.9% 311296/664444 bytes...
Writing at 0x00096188 [=============> ] 49.3% 327680/664444 bytes...
Writing at 0x0009bd3b [==============> ] 51.8% 344064/664444 bytes...
Writing at 0x000a160b [===============> ] 54.2% 360448/664444 bytes...
Writing at 0x000a6eae [================> ] 56.7% 376832/664444 bytes...
Writing at 0x000ac4be [================> ] 59.2% 393216/664444 bytes...
Writing at 0x000b1aa6 [=================> ] 61.6% 409600/664444 bytes...
Writing at 0x000b7469 [==================> ] 64.1% 425984/664444 bytes...
Writing at 0x000bcfaa [==================> ] 66.6% 442368/664444 bytes...
Writing at 0x000c28f6 [===================> ] 69.0% 458752/664444 bytes...
Writing at 0x000c7f67 [====================> ] 71.5% 475136/664444 bytes...
Writing at 0x000cd9e7 [=====================> ] 74.0% 491520/664444 bytes...
Writing at 0x000d39e5 [=====================> ] 76.4% 507904/664444 bytes...
Writing at 0x000d9560 [======================> ] 78.9% 524288/664444 bytes...
Writing at 0x000df7aa [=======================> ] 81.4% 540672/664444 bytes...
Writing at 0x000e9c43 [========================> ] 83.8% 557056/664444 bytes...
Writing at 0x000ef8e3 [========================> ] 86.3% 573440/664444 bytes...
Writing at 0x000f4c90 [=========================> ] 88.8% 589824/664444 bytes...
Writing at 0x000fa69c [==========================> ] 91.2% 606208/664444 bytes...
Writing at 0x00100052 [===========================> ] 93.7% 622592/664444 bytes...
Writing at 0x00105605 [===========================> ] 96.2% 638976/664444 bytes...
Writing at 0x0010b386 [============================> ] 98.6% 655360/664444 bytes...
Writing at 0x0010e7d0 [==============================] 100.0% 664444/664444 bytes...
Wrote 1042384 bytes (664444 compressed) at 0x00010000 in 11.7 seconds (711.5 kbit/s).
Hash of data verified.
Hard resetting via RTS pin...
However the ThingSpeak Channel is showing no visualization (screenshot attached).
Please help in solving this error message.
And thank you for reading this long post.
Nakul
  3 commentaires
Nakul
Nakul le 2 Sep 2025
thank you for the reply. please tell how to verify point number 1 2 3. I will verify and share the outputs.
Anmol
Anmol le 3 Sep 2025
Hi Nakul,
The following information can be checked:
  1. The output of the Serial.print() and Serial.println() statements which is displayed on the Serial Monitor.
  2. Try refreshing the ThingSpeak UI page after few minutes and check the Entries value above the plots, if it is increasing.
  3. Try referring to the example present in this link below:

Connectez-vous pour commenter.

Réponses (1)

Nakul
Nakul le 9 Sep 2025
Modifié(e) : Nakul le 9 Sep 2025
Dear Anmol
Thank you for the reply.
Here is output on serial monitor is attached as screenshot.
Serial.println() did not provide any output.
only output seen in the output tab is this:-
Sketch uses 1042243 bytes (79%) of program storage space. Maximum is 1310720 bytes.
Global variables use 46588 bytes (14%) of dynamic memory, leaving 281092 bytes for local variables. Maximum is 327680 bytes.
esptool v5.0.0
Serial port COM9:
Connecting.....
Connected to ESP32 on COM9:
Chip type: ESP32-D0WD-V3 (revision v3.1)
Features: Wi-Fi, BT, Dual Core + LP Core, 240MHz, Vref calibration in eFuse, Coding Scheme None
Crystal frequency: 40MHz
MAC: f8:b3:b7:44:4f:cc
Uploading stub flasher...
Running stub flasher...
Stub flasher running.
Changing baud rate to 921600...
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00007fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x0010efff...
Compressed 25168 bytes to 16063...
Writing at 0x00001000 [ ] 0.0% 0/16063 bytes...
Writing at 0x00007250 [==============================] 100.0% 16063/16063 bytes...
Wrote 25168 bytes (16063 compressed) at 0x00001000 in 0.6 seconds (331.1 kbit/s).
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000 [ ] 0.0% 0/146 bytes...
Writing at 0x00008c00 [==============================] 100.0% 146/146 bytes...
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (490.6 kbit/s).
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000 [ ] 0.0% 0/47 bytes...
Writing at 0x00010000 [==============================] 100.0% 47/47 bytes...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (681.1 kbit/s).
Hash of data verified.
Compressed 1042384 bytes to 664444...
Writing at 0x00010000 [ ] 0.0% 0/664444 bytes...
Writing at 0x0001c60c [ ] 2.5% 16384/664444 bytes...
Writing at 0x000286db [> ] 4.9% 32768/664444 bytes...
Writing at 0x000301d2 [=> ] 7.4% 49152/664444 bytes...
Writing at 0x0003ff56 [=> ] 9.9% 65536/664444 bytes...
Writing at 0x00045a45 [==> ] 12.3% 81920/664444 bytes...
Writing at 0x0004b56a [===> ] 14.8% 98304/664444 bytes...
Writing at 0x00050b3c [====> ] 17.3% 114688/664444 bytes...
Writing at 0x00055f86 [====> ] 19.7% 131072/664444 bytes...
Writing at 0x0005b734 [=====> ] 22.2% 147456/664444 bytes...
Writing at 0x0006081b [======> ] 24.7% 163840/664444 bytes...
Writing at 0x00065f0c [=======> ] 27.1% 180224/664444 bytes...
Writing at 0x0006b4ba [=======> ] 29.6% 196608/664444 bytes...
Writing at 0x00070af1 [========> ] 32.1% 212992/664444 bytes...
Writing at 0x000766d8 [=========> ] 34.5% 229376/664444 bytes...
Writing at 0x0007badc [==========> ] 37.0% 245760/664444 bytes...
Writing at 0x0008106c [==========> ] 39.5% 262144/664444 bytes...
Writing at 0x00086546 [===========> ] 41.9% 278528/664444 bytes...
Writing at 0x0008bb3c [============> ] 44.4% 294912/664444 bytes...
Writing at 0x00090d01 [=============> ] 46.9% 311296/664444 bytes...
Writing at 0x00096188 [=============> ] 49.3% 327680/664444 bytes...
Writing at 0x0009bd3b [==============> ] 51.8% 344064/664444 bytes...
Writing at 0x000a160b [===============> ] 54.2% 360448/664444 bytes...
Writing at 0x000a6eae [================> ] 56.7% 376832/664444 bytes...
Writing at 0x000ac4be [================> ] 59.2% 393216/664444 bytes...
Writing at 0x000b1aa6 [=================> ] 61.6% 409600/664444 bytes...
Writing at 0x000b7469 [==================> ] 64.1% 425984/664444 bytes...
Writing at 0x000bcfaa [==================> ] 66.6% 442368/664444 bytes...
Writing at 0x000c28f6 [===================> ] 69.0% 458752/664444 bytes...
Writing at 0x000c7f67 [====================> ] 71.5% 475136/664444 bytes...
Writing at 0x000cd9e7 [=====================> ] 74.0% 491520/664444 bytes...
Writing at 0x000d39e5 [=====================> ] 76.4% 507904/664444 bytes...
Writing at 0x000d9560 [======================> ] 78.9% 524288/664444 bytes...
Writing at 0x000df7aa [=======================> ] 81.4% 540672/664444 bytes...
Writing at 0x000e9c43 [========================> ] 83.8% 557056/664444 bytes...
Writing at 0x000ef8e3 [========================> ] 86.3% 573440/664444 bytes...
Writing at 0x000f4c90 [=========================> ] 88.8% 589824/664444 bytes...
Writing at 0x000fa69c [==========================> ] 91.2% 606208/664444 bytes...
Writing at 0x00100052 [===========================> ] 93.7% 622592/664444 bytes...
Writing at 0x00105605 [===========================> ] 96.2% 638976/664444 bytes...
Writing at 0x0010b386 [============================> ] 98.6% 655360/664444 bytes...
Writing at 0x0010e7d0 [==============================] 100.0% 664444/664444 bytes...
Wrote 1042384 bytes (664444 compressed) at 0x00010000 in 11.7 seconds (711.5 kbit/s).
Hash of data verified.
Hard resetting via RTS pin...
This example makes use of Arudrino hardware while i am using only esp-32 for this experiement.

Catégories

En savoir plus sur Write Data to Channel dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by