Results for
Need code to collect data of waterflow sensor using ESP 8266 and to stoe it in ThingSpeak cloud
Ciao a Tutti,qualche mese fa avevo costruito una stazione meteo con un esp32 e vari sensori.
Tutto funzionava, adesso però ho riprovato, e non funziona più. Ho provato a creare un canale nuovo con nuovo ID canale, nuovo ID Client, nuovo Utente (uguale al Client) e nuova Password. si connette (ho inserito un comando se connesso a MQTT scrivi.....) ma non publica i dati.
Non reisco a saltarne fuori, ècambiato qualche cosa?
grazie a tutti
Hello,
could it be that there is currently is a stability problem with the MQTT-Broker? I can establisth a connection successfully using the MQTTX client (web and win64 installation). I tried all possible ports an connection types. It disconnects all the time after a few seconds of establishing a connection successfully. So it was not possible to subscribe any item. I do not think the problem is in my side... By the way, protocol verision 3.1.1 ist supported, 5.0 not, am I right?
Maybe you could give me a hint,
Best regards,
Manfred
in the below code write is working fine, but read is failing ( 404 error) can you please help me reslove this.
/*
Go to thingspeak.com and create an account if you don't have one already.
After logging in, click on the "New Channel" button to create a new channel for your data. This is where your data will be stored and displayed.
Fill in the Name, Description, and other fields for your channel as desired, then click the "Save Channel" button.
Take note of the "Write API Key" located in the "API keys" tab, this is the key you will use to send data to your channel.
Replace the channelID from tab "Channel Settings" and privateKey with "Read API Keys" from "API Keys" tab.
Replace the host variable with the thingspeak server hostname "api.thingspeak.com"
Upload the sketch to your ESP32 board and make sure that the board is connected to the internet. The ESP32 should now send data to your Thingspeak channel at the intervals specified by the loop function.
Go to the channel view page on thingspeak and check the "Field1" for the new incoming data.
You can use the data visualization and analysis tools provided by Thingspeak to display and process your data in various ways.
Please note, that Thingspeak accepts only integer values.
You can later check the values at https://thingspeak.com/channels/2005329
Please note that this public channel can be accessed by anyone and it is possible that more people will write their values.
*/
#include <WiFi.h>
const char *ssid = "xxxx"; // Change this to your WiFi SSID
const char *password = "xxxxx"; // Change this to your WiFi password
const char *host = "api.thingspeak.com"; // This should not be changed
const int httpPort = 80; // This should not be changed
const String channelID = "2805914"; // Change this to your channel ID
const String writeApiKey = "xxxxxxxxxxxxxxxx"; // Change this to your Write API key
const String readApiKey = "xxxxxxxxxxxxxxxx"; // Change this to your Read API key
// The default example accepts one data filed named "field1"
// For your own server you can ofcourse create more of them.
int field1 = 20;
//int field1 = 20;
int numberOfResults = 1; // Number of results to be read
int fieldNumber = 1; // Field number which will be read out
void setup() {
Serial.begin(115200);
while (!Serial) {
delay(100);
}
// We start by connecting to a WiFi network
Serial.println();
Serial.println("******************************************************");
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void readResponse(NetworkClient *client) {
unsigned long timeout = millis();
while (client->available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client->stop();
return;
}
}
// Read all the lines of the reply from server and print them to Serial
while (client->available()) {
String line = client->readStringUntil('\r');
Serial.print(line);
}
Serial.printf("\nClosing connection\n\n");
}
void loop() {
NetworkClient client;
String footer = String(" HTTP/1.1\r\n") + "Host: " + String(host) + "\r\n" + "Connection: close\r\n\r\n";
// WRITE --------------------------------------------------------------------------------------------
if (!client.connect(host, httpPort)) {
return;
}
client.print("GET /update?api_key=" + writeApiKey + "&field1=" + field1 + footer);
readResponse(&client);
delay(200);
// READ --------------------------------------------------------------------------------------------
String readRequest = "GET /channels/" + channelID + "/fields/" + fieldNumber + ".json?results=" + numberOfResults + " HTTP/1.1\r\n" + "Host: " + host + "\r\n"
+ "Connection: close\r\n\r\n";
if (!client.connect(host, httpPort)) {
return;
}
client.print(readRequest);
readResponse(&client);
// -------------------------------------------------------------------------------------------------
//++field1;
delay(10000);
}
Thingspeak

Thingspeak channel shows a "watch" - "un-watch" selection box. What does this do?
Thanks
Dear Sir,
I login my channel in a device using my user name and password (also client id & password) but when I also login using the same user name and password in another device, the first one connection was forced disconnected. I want to publish via thinkspeak mqtt by using the two devices. Please advise how I can do it. Can I use the same thinkspeak user name to login? Is it needed to have another thinkspeak user to login? In this case, please also advise. Many thanks.
Aaron
I have a device that via GPRS publish correctly, after autentication to the server mqtt3.thingspeak.com , a lot of datas like:
.{"sensorDatas":[{"flag":"COUNT","value":1},...........,{"flag":"AI1","value":25.80}]}
I configure a correct Channel with a field called AI1, but I can't fill it with that value 25.80.
I am sure that the device communicate to the server the string {"flag":"AI1","value":25.80} but nothing.
Could you tell me what I have to do? Probably I have to write some software code, may someone help me?
Are there some examples for a beginner like me?
Thank you very much
Hello
I am trying to connect Thingspeak to ibfluxdb. Is that possible? how you do that??
I am using a micro:bit device with ESP8266 for a IOT project, but cannot connect thingspeak recently.
The conncection is unstable, I can hardly connect to thingspeak for days, somehow it works last night for 30 mins and then it fails.
The program does not change and I have included a 25 sec delayed between each data sending.
Please advice why and how to fix it. Thank you.
I am using the ELECFREAKS IOT:bit Expansion Board with micro:bit to record data, it worked normally but in this week I tested again, and discover no data is uploaded to the channel ie.no entries in channel. The code in makecode are the same as before and the wifi is work, I cannot find the reason that cause this failure.
I am using the free option with 4 channels available. I do not have any channels listed, but when I want to create a new channel it gives me an error massage to say that I have used up my 4 channels and need to purchase units to create additional channels.
Hello
I have 3 devices (IOT board using SIM7600 module) sending one value to Thingsspeak. Have been working just fine a couple of years. However 14/11-24 I receive http error code 406 for all 3 devices.
The http get is working just fine when testing directly in the browser (https://api.thingspeak.com/update?api_key=xxxxx&field1=33), the server return the entrie number.
However, when running the same address via SIM7600 I receive - +HTTPACTION: 0,406,0
Any tips for the 406 error code?
Hello, I am wondering why I have over 12000 messages (writes)per day to a channel which I only update all 8 fields every 20 minutes. Or are these statistic timely delayed? Since testing I might have more writes, but now with my ready weather station only every 20 minutes my data will be updated. Wetterbox Channel ID: 2391212 Access: Public Can you explain this to me? Thank you for your help. Regards, Julian
I am considering to upgrade to HOME license. Does the HOME license provides more widgets (including a text message widget), in addition to the 4 basic widgets in the FREE version?
Hi,
I don't know why really. Why is there seems a difference between daily average that calculated with .csv file that has exported directly from the channel.
and calculation with the ThingSpeak Daily Average API, there is a lot of difference at the moment.
Why does this happens, and how should I fix this issue?
Attached image file is daily average that has been retrived through the API,
And attached excel file is raw data from the channel.
Thank you.



My Licensed avvount has expired. When I go to my expired license page, I select "Revert To Free Account", I get the following message:
Only administrators of this license are allowed to renew units on this ThingSpeak license. If you want to continue to collect data in your ThingSpeak channels, contact your license administrator.
Aren't I the license administrator? or do I need to contact someone at Thingspeak/MathWorks?
Hi, My data send to thingspeak is not received/updated for the last 6 hours on the charts and dials. All worked well till about 6 hour ago. I am using Node-red and the API Url: https://thingspeak.com
Any help please?
Greetings Gert
To solve issues around the browsers blocking 3p cookies and having different behavior across different browsers, the ThingSpeak website is now served from https://thingspeak.mathworks.com. There are no changes required from devices or users. Just log in and use the service as you always did.
I left the code unchanged, modifying only secrets.h.
I am using an ESP32-WROOM -32U
Connection to network succeeds, but ThingSpeak.writeFields fails every time, with HTTP error code 400.
The sketch I am really trying to use is loosely based on this example, accesses Time and Weather info with no problems, but ThingSpeak.writeFields fails with HTTP error code 301.
This is my first attempt to use ThingSpeak.
Is this example sketch still valid, or must I look elsewhere? Suggestions please.
Hi everyone,
I'm working on a school project where I need to send sensor data from my Arduino to a Power BI REST API using ThingsHTTP. I've been trying to get this to work, but I'm running into errors like this:
{"error":{"code":"InvalidRequest","message":"Error parsing request for dataset sobe_wowvirtualserver|a7b68fb5-533b-471f-a5da-3bdd6746ee16: Conversion error on column '<pi>pH</pi>': <pi>Input string was not in a correct format.</pi>"}}
I'm a beginner with this, and I'm not sure what I'm doing wrong. What steps should I take to resolve this issue? Also, does anyone know the correct format for an HTTP request body when sending dynamic sensor data?
This is the body format I'm trying to send to Power BI:
[
{
"pH": 98.6,
"TDS": 98.6,
"turbidity": 98.6,
"temperature": 98.6
}
]
Any advice on how to construct the HTTP body with values that change over time would be greatly appreciated! Thanks in advance!"