Thomas in MATLAB Answers
Last activity on 3 Apr 2025

Hallo, ich habe mir einen Sketch erstellen lassen, in dem die OTAA Daten eingetragen werden sollen. Nun meine Frage: wie komme ich an diese Daten von meiner Seite?. Im Dashboard finde ich die aber nicht.? Danke erstmal
Kevin in Discussions
Last activity on 21 Mar 2025

Hello ThingSpeak Community, I have an energy meter sending data of energy consumed in 4 rooms in hexadecimal values to Sigfox and I was trying to decode the payload and route it to ThingSpeak. All the datas are sent at the same time. But ThingSpeak only receives 1 of them and plots them. However, the rest 3 are missing. Is this because I am trying the free version ? Would the payed version be capable of receiving all the 4 messages ? Only 1 sensor data (hexadecimal byte) gets transmitted to ThingSpeak out of 4 Sensor datas (hexadecimal bytes) (All the 4 sensor datas are sent in the same time to ThingSpeak) Most of the time I have seen this, it is because instead of a single request updating all 4 fields at the same time, there are 4 separate requests updating each of the 4 fields. This will not work because on the first update, all subsequent updates to the channel are limited based on the rate limit - once every 15s for a free account, and once per second for a licensed ThingSpeak account. How do you confirm all 4 fields are updated using just a single request? thingspeak
Kevin in MATLAB Answers
Last activity on 19 Mar 2025

I have a ERS Co2 sensor. It is connected to the TTN and the TTN is receiving the data. I want to connect it to ThingSpeak. First, I used the payload uplink formatter recommended by the ELSYS company in the TTN (See the file attached: Elsys_Sensor.txt). After I went through some ThingSpeak tutorials - I used the payload uplink formatter in the file Elys_Sensor_Adapted with the program returning the required data in Fields. Still the ThingSpeak doesnt receive any data. Note: I used the Channel ID and the Write API in the TTN to add ThingSpeak as webhook.
Danh in MATLAB Answers
Last activity on 18 Mar 2025

I have a project subject in University with database in ThingSpeak, I show code below like this with board ESP32. When I run with board ESP32 or ESP8266, the code announce me a error like "ThingSpeak.h: no such file or directory", although I install Thingspeak library before that. So, I need to do what to config that code. Can anyone help me? Thanks for responding or reading my problem. T.T Error announce me inn Output: fatal error: ThingSpeak.h: No such file or directory compilation terminated. My code: #include <WiFi.h> //#include <WiFiClient.h> #include "ThingSpeak.h" #define WIFI_SSID "Tang 1 Tro 198_2.4G" #define WIFI_PASSWORD "" #define SECRET_CH_ID 2108004 #define SECRET_WRITE_APIKEY "xxxxxxxxxxxxxxxx" // replace XYZ with your channel write API Key #define A 35 // define MQ2 analog pin #define D 14 // define MQ2 digital pin #define LED 25 WiFiClient client; unsigned long myChannelNumber = SECRET_CH_ID; const char * myWriteAPIKey = SECRET_WRITE_APIKEY; int Digital_value, Analog_value; unsigned long dataMillis = 0; void setup() { Serial.begin(9600); pinMode(A, INPUT); pinMode(D, INPUT); pinMode(LED, OUTPUT); digitalWrite(LED, LOW); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("Connecting to Wi-Fi"); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(300); } Serial.println(); Serial.print("Connected with IP: "); Serial.println(WiFi.localIP()); Serial.println(); ThingSpeak.begin(client); } void loop() { Analog_value = analogRead(A); Digital_value = digitalRead(D); Serial.printf("Analog value: %d\n", Analog_value); Serial.printf("Digital value: %d\n", Digital_value); ThingSpeak.setField(1, Analog_value); ThingSpeak.setField(2, !Digital_value); if (millis() - dataMillis > 20000) { int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); if (x == 200) { Serial.println("Channel update successful."); } else { Serial.println("Problem updating channel. HTTP error code " + String(x)); } dataMillis = millis(); } if (!Digital_value) { digitalWrite(LED, HIGH); delay(1000); digitalWrite(LED, LOW); delay(1000); } }
randomnick in MATLAB Answers
Last activity on 18 Mar 2025

Hi, I am reading data from one ThingSpeak channel with three fields: Voltage, Frequency, and Wi-Fi Signal Strength, which update every minute. My setup reads these values, processes the data, and writes the results to another channel. However, I am facing several issues with inconsistent updates and missing entries. I read 30 data points every 30 minutes and write the processed results to my channel. Two of the analyses are slightly more complex than the other six fields: One analysis takes 30 input values and outputs a single result to Field 5 in the last minute. Another analysis takes the last 31 inputs and processes them into 30 outputs for Field 8 using the diff() function. The update works correctly for 29 entries across 7 fields, but in the last minute, only Field 5 gets updated while the other fields do not. Sometimes, when I try to save and run the code, I encounter errors, but other times it runs fine, eventhough the code is the same. The time control is set to update every 30 minutes, but I notice that it sometimes updates only once an hour or stops for several hours before resuming. Why does the last-minute update affect only Field 5 while the other fields are not updated? What could be causing some errors when saving and running the code? Why does the scheduled update sometimes not execute properly because of my analysis code and instead update and stopped at irregular intervals? My suspect is my code is not well formed, and sometimes the code executed too fast, thingspeak is unable to handle too much writing. FYI, I am using free license, my daily usage rate is less than 2000 messages. Any insights or suggestions would be greatly appreciated. Thank you! I am attaching some parts of my code, and the data exported from my channel. As of now I am writing this question, the entries seems to work properly for now since the last save and running the code, updating 31 entries, 30 entries for the other fields, 1 entry for field 5. My channel id is 2862014 if you need it. readChId = XXX; writeChId = XXX; % Replace with your channel number writeKey = 'XXX'; % Replace with your channel write key % Read data from ThingSpeak (last 30 data points) [frequency,time] = thingSpeakRead(readChId,'Fields',1,'NumPoints',30); voltage = thingSpeakRead(readChId,'Fields',2,'NumPoints',30); wifiStrength = thingSpeakRead(readChId,'Fields',3,'NumPoints',30); freq_drift = thingSpeakRead(readChId,'Fields',1,'NumPoints',31); % Calculate voltage fluctuation index (percentage variation from mean) % Field 5 voltage_fluctuation_index = (max(voltage) - min(voltage)) / mean(voltage) * 100; % Field 8 freq_diff = diff(freq_drift); thingSpeakWrite(writeChId,[voltage,frequency,wifiStrength,voltage_fluctuation,frequencyStability,wifiSNR,freq_diff],'Fields',[1,2,3,4,6,7,8],'TimeStamps',time,'WriteKey',writeKey); thingSpeakWrite(writeChId,'Values',[voltage_fluctuation_index],'Fields',[5],'writekey',writeKey);
Eric in MATLAB Answers
Last activity on 10 Mar 2025

I am looking delete data from the Thingspeak server so that I don't have to downlaod the same data every time. I have > 110,000 lines of data over the past two years and the files are up to 67MB. The file is taking several minutes to downlaod and handeling this much data in Excel is also slow. Is there a way I can clear the data on the server and start recording again? Thanks, Eric
Gilles Mangin-Voirin in MATLAB Answers
Last activity on 10 Mar 2025

Hello, I have been encountering several times a day for a few weeks an error when updating my data stored on Thingspeak (computerized hive parameters). The return code of my Arduinos is 211! But I can't find the meaning of this code anywhere... Does anyone know more? Here is one of my hives: https://thingspeak.mathworks.com/channels/1289244 Thanks PS: The update continues to be done but it seems to be missing points (those that return the error 211)
Rajendra in MATLAB Answers
Last activity on 7 Mar 2025

i have to paste the url generated in the output ide everytime to get the data on my thingspeak channel: e,g.: http://api.thingspeak.com/update?api_key=***REDACTED***&field1=27.25&field2=3.27&field3=0.00 my code is : #include "DHT.h" #define DHTPIN 15 // Pin where DHT sensor is connected #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); #define THINGSPEAK_API_KEY "***REDACTED***" #include <SoftwareSerial.h> #include <OneWire.h> #include <DallasTemperature.h> #include <ArduinoJson.h> SoftwareSerial myserial(10, 11); // RX, TX for GSM communication // Temperature Sensor Setup #define ONE_WIRE_BUS 5 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); // Flow Sensor Setup #define SENSOR_PIN 2 volatile byte pulseCount = 0; float flowRate = 0.0; unsigned int flowMilliLitres = 0; unsigned long totalMilliLitres = 0; unsigned long oldTime = 0; float calibrationFactor = 5.5; // Calibration factor for flow meter // Turbidity Sensor Setup int turbiditySensorValue; float voltage; // Variables for DHT sensor float temperatureC; float temperatureF; void setup() { Serial.begin(9600); myserial.begin(9600); pinMode(SENSOR_PIN, INPUT); digitalWrite(SENSOR_PIN, HIGH); pulseCount = 0; flowRate = 0.0; flowMilliLitres = 0; totalMilliLitres = 0; oldTime = 0; attachInterrupt(digitalPinToInterrupt(SENSOR_PIN), pulseCounter, FALLING); sensors.begin(); // Initialize temperature sensor dht.begin(); // Initialize DHT sensor // GSM Initialization with better error checking initGSM(); } void initGSM() { Serial.println("Initializing GSM..."); // Wait for GSM module to respond while (!sendATCommand("AT", "OK", 1000)) { Serial.println("Waiting for GSM module..."); delay(1000); } sendATCommand("AT+SAPBR=3,1,\"Contype\",\"GPRS\"", "OK", 2000); sendATCommand("AT+SAPBR=3,1,\"APN\",\"your_apn\"", "OK", 2000); // Change APN if needed sendATCommand("AT+SAPBR=1,1", "OK", 2000); sendATCommand("AT+SAPBR=2,1", "OK", 2000); } bool sendATCommand(const char* command, const char* expected_answer, unsigned int timeout) { Serial.println("Sending command: " + String(command)); myserial.println(command); String response = ""; unsigned long previous = millis(); while (millis() - previous < timeout) { while (myserial.available()) { char c = myserial.read(); response += c; } if (response.indexOf(expected_answer) >= 0) { Serial.println("Response: " + response); // Print full response return true; } } Serial.println("Timeout! No response or unexpected response: " + response); return false; } void loop() { flowMeter(); temperature(); turbidity(); sendToThingSpeak(); delay(15000); // 15 second delay between readings } void flowMeter() { if ((millis() - oldTime) > 1000) { detachInterrupt(digitalPinToInterrupt(SENSOR_PIN)); flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor; oldTime = millis(); flowMilliLitres = (flowRate / 60) * 1000; totalMilliLitres += flowMilliLitres; Serial.print("Flow rate: "); Serial.print(flowRate, 2); // Print with 2 decimal places Serial.println(" L/min"); pulseCount = 0; attachInterrupt(digitalPinToInterrupt(SENSOR_PIN), pulseCounter, FALLING); } } void pulseCounter() { pulseCount++; } void temperature() { sensors.requestTemperatures(); temperatureC = sensors.getTempCByIndex(0); temperatureF = sensors.toFahrenheit(temperatureC); Serial.print("Temperature: "); Serial.print(temperatureC); Serial.println("°C"); } void turbidity() { turbiditySensorValue = analogRead(A0); voltage = turbiditySensorValue * (5.0 / 1024.0); Serial.print("Turbidity Voltage: "); Serial.println(voltage, 2); // Print with 2 decimal places } void sendToThingSpeak() { // Check if GSM is connected if (!sendATCommand("AT+SAPBR=2,1", "OK", 2000)) { Serial.println("GSM Network Issue! Not sending data."); return; } // Close any existing HTTP connection sendATCommand("AT+HTTPTERM", "OK", 1000); delay(1000); // Initialize HTTP service if (!sendATCommand("AT+HTTPINIT", "OK", 2000)) { Serial.println("HTTP init failed"); return; } sendATCommand("AT+HTTPPARA=\"CID\",1", "OK", 1000); // Construct URL properly String url = "http://api.thingspeak.com/update?api_key="; url += THINGSPEAK_API_KEY; url += "&field1=" + String(temperatureC); url += "&field2=" + String(voltage); url += "&field3=" + String(flowRate); Serial.println("Generated URL: " + url); // Print full URL before sending // Send URL parameter properly String command = "AT+HTTPPARA=\"URL\",\"" + url + "\""; if (!sendATCommand(command.c_str(), "OK", 2000)) { Serial.println("Setting URL failed"); return; } // Start HTTP GET request if (!sendATCommand("AT+HTTPACTION=0", "+HTTPACTION: 0,200", 5000)) { Serial.println("HTTP GET command failed"); return; } delay(5000); // Wait for response // Read HTTP response if (!sendATCommand("AT+HTTPREAD", "OK", 5000)) { Serial.println("Failed to read HTTP response"); return; } Serial.println("Data sent successfully!"); // Close HTTP connection sendATCommand("AT+HTTPTERM", "OK", 1000); }
Ray Berkelmans in MATLAB Answers
Last activity on 5 Mar 2025

I'm having my data routed from Blues Notehub to ThingSpeak and it works fine, as long as there is only one data point being routed. If there are more than one, the rest do not arrive and ThingSpeak returns a response of "0". That sounds suspiciously like a rate limit issue, right? However, I am now on a paid TS plan which should allow me 1 update per second and my Notehub route is rate limited to 1 per 14.3 seconds. According to the Blues folk, evreything is working as intended on their end. See my thread here: https://discuss.blues.com/t/only-one-of-multiple-notes-is-successfully-routed/2884. Can you please help?
Giovanni in MATLAB Answers
Last activity on 3 Mar 2025

Hello, I am exploring Thingspeak features. I have successfully set up an Arduino board with sensors to send messages and display the channel on the Dashboard. It seems to me, however, that the reverse is not possible, i.e. to send messages to Arduino in order to control it. In fact the four widgets available are only supposed to receive data, not to send them. Is this because I have a free account or is it a feature of Thingspeak? As an example, Arduino IoT offers both possibilities. Thanks Giovanni
cesc bonet in MATLAB Answers
Last activity on 28 Feb 2025

good morning!, I'm learning in MatlLab and ThingSpeak, and I'm a bit lost ... I have a variable that changes state from 0 to 1. And I want to know how I can calculate the times it changes state, and the time that remains for Example in state 1. Can you help me? Thank you so much
Amanj Abdollah Zadeh in MATLAB Answers
Last activity on 19 Feb 2025

when i want to read data from thingspeak, i get the below messege : Problem reading channel. HTTP error code -304 how can i solve this?
Eman in MATLAB Answers
Last activity on 14 Feb 2025

I am using multiple sesnors and their readings are monitored in a thingspeak channel. I need to fetch and visualise these data live on a some gauges and lamp indicators to change color when a specified threshold is exceeded.
Vinod in Discussions
Last activity on 9 Feb 2025

With a deployment of ThingSpeak on August 15th, 2024, we are using a new library for visualization of ThingSpeak channel charts. This should require no changes on your part. If you notice any discrepancies/differences in your channel visualization, please post a screenshot on this thread. ANNOUNCEMENT: New charts visualization engine introduced an unwanted amount of space on the left of the cart... example a 1200 width cahart is no more 1200 but +- 150 space on the left and a 1050 chart thanks Can you please share a screenshot with the change that you want to see highlighted? in fact not a big difference, let's say that I prefer the old render.... :) thanks Thank you! Looks like you're embedding the chart on your own page and not viewing it on ThingSpeak, correct? At first glance I believe the empty space is to ensure we have enough space to add a Y-axis label. In your case you don't have a label, so that space is not used as efficiently as before. We'll look into it in some more detail. yes, it is embedded in my own page b Column charts are now incorrectly drawn. The columns should start at zero and extend up/down for positive/negative data values, but currently the columns all start at the most negative value of the y-axis. They used to look like this: But now they look lke this: Thanks for reporting the issue. We will look to fix this in an upcoming release. Timescale in chart options not saving and charts have to be updated manually where up until recently they were updating automatically every 10 minutes I'm unable to reproduce that. Can you try logging out of thingspeak, logging back in, saving your chart's timescale setting and reloading the page to confirm the setting has saved? Also, charts are updating normally every 15 seconds as long as the page is visible in the browser window. If the page is one of the background tabs on the browser, the browser may stop refreshing it automatically. Have tried logging in repeatedly but the timescale setting never saves. I had it refreshing every 10 minutes which was working perfectly for several years but has now stopped refreshing unless I do it manually. Having the browser window open makes no difference. Oddly though the visualisations are updating ok but the graphs are not. Have tried it in Microsoft Edge browser and Brave. Both exhibit the same symptoms Let me investigate the saving of the timescale setting in Monday. As to the visualization - I initially thought that was the chart visualization. Perhaps you're talking about MATLAB visualization. If so, having them auto refresh requires a paid thingspeak license. Did you have a paid thingspeak license that was not renewed? You can find more details about your license type on you account page on thingspeak. Sorry, not visualizations but the round plugin dials. They appear to update automatically but not the graphs. I have the free licence. From the analysis we did, there is a bug in that the parameter values in the dropdowns shown when you click the chart's pencil icon are not displayed correctly. They are saved on the backend, but, the UI does not show this once the page is refreshed. This is a bug and will be fixed in the upcoming release. As for the 'timescale', When you pick any value other than null, the page has to be refreshed manually. This behavior has existed for over 10 years. As to the reasoning behind this -- if you pick a non-empty timescale, it means you want to see the first point in that 'x' minute window (where 'x' is the value you pick in the dropdown). I believe the logic behind what is implemented in the code it is more likely that a user will refresh the page than wait for it to auto update when you are looking at data that refreshes very slowly. Arguably, this is incorrect, and we will look to address that separately. For now, for the auto-refresh chart, pick the null value for timescale dropdown of the chart and hit save. If you pick a non-null value, you will need to refresh the page. Waiting patiently...! When do you expect to mend this issue? The timescale setting not showing up correctly despite being saved on the backend has been fixed. Now, if you edit the value using the pencil icon and load it back up, you will see the saved setting. This is resolved as of 09/19/2024. The new visualization library still has bugs. I have a chart with y-axis minimum set to 125 and maximum 140 but the y-axis scale entries appears to be rounded to two significant figures, so 126, 128, 132 134 are all rounded to 130, while 136, 138 are rounded to 140. See Another minor issue is that values on the y-axis between 10 and -10 are represented with two decimal digits, thus 5 becomes 5.00, 0 becomes 0.00. See Clock Monitor Bucklebury - ThingSpeak IoT Thank you for reporting that, Martin. It looks like the rounding of the numbers needs better resolution. We'll look to resolve this in the next release. Now if the values of the variable are over 1000, the y-axis is now rounded to 1.0k and resolution is weak. See an example of air pressure that varies between 1017-1021 hPa, but it is impossible to see that based on the chart y-axis. Thank you for reporting it. The issue is the same as Martin reports below where the dynamic range of the axis labels is incorrect. We have a fix incoming within the next week. @Manne Tervaskanto: This should be fixed now. Please confirm. @Martin Rice: I believe this is also resolved. Please confirm. If you have set manual axis limits for the charts, you may need to switch back to automatic limits to get the benefits of the built-in autoscaling. Hi. Yes, looks great now. Thanks! y-axis values now OK, thanks. hi, if I write a number at Data min or Data max, the chart doesn't upload when new data is sended, I must press F5 for refresh for view it. But I don't write nothing at Data min and Data max the chart is upload automatically every data is sended. For users with a free ThingSpeak license, the charts are refreshed automatically every 15 seconds if the tab is in the browser foreground. Users with a paid license can set the update rate as fast as once a second. This is working as expected. This link of Field 1 Chart work fine https://thingspeak.mathworks.com/channels/2504110/charts/1?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Potencia+%28%C3%9Altimos+60+minutos%29&type=line&yaxis=Watios&yaxismin=0 This link of Field 1 Chart doesn't work fine https://thingspeak.mathworks.com/channels/2504110/charts/1?bgcolor=%23ffffff&color=%23d62020&dynamic=true&max=4000&results=60&title=Potencia+%28%C3%9Altimos+60+minutos%29&type=line&yaxis=Watios&yaxismin=0 The difference is &max=4000 . But one update automatically and other I need press F5 Hello, I need to come back to this discussion. In the example of air ambient pressure, trend still doesn't show correctly. Trend values varies from 1009 to 1017 hPa, but there is only one vertical axis value 1.01k showing the axis range. In the figures which are showing smaller values trends are ok now. Is it possible to get similar scaling to values above 1.0k? Thanks a lot. Thanks for reporting, @Manne Tervaskanto. The issue here is that we can only show 3 significant figures without the y-tick labels overwriting the y-label text. The algorithm rounds 1009 to 1.01k. 1017 will be rounded up to 1.02k. However, that would make the chart squeezed out, i.e., only a small portion of the axis between 1.01k and 1.02k would be used by the data and it would appear to be a flat line. As a user, what would you expect to see - a flat-ish line of the data with the majority of the chart blank and the two horizontal lines, or, the view as above? Thank you for reporting the issue. We're working on a fix for this. Hi, I have detected that if a field has only one data, it cannot be displayed with type column, only with type line. Regards Can you tell me more about this use case -- why would your channel have just a single value, other than perhaps you're testing something in a new channel? Hi, The value is monthly, one at January, one at February, etcetera. Regards.
Rajendrra in Discussions
Last activity on 6 Feb 2025

my code is as below: #include "DHT.h" #define DHTPIN 15 // what pin we're connected to #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); #define THINGSPEAK_API_KEY "1P4RY69D3YMP9R5W" #include <SoftwareSerial.h> #include <OneWire.h> #include <DallasTemperature.h> //----------------------------- #include <ArduinoJson.h> StaticJsonDocument<200>JsonDocument; SoftwareSerialmyserial(10, 11); //------------------------- float voltage; unsignedintfrac; //--------------------- #define ONE_WIRE_BUS 5 OneWireoneWire(ONE_WIRE_BUS); DallasTemperaturesensors(&oneWire); floatCelcius = 0; float Fahrenheit = 0; //========================================================================================================== bytesensorInterrupt = 0; // 0 = digital pin 2 bytesensorPin = 2; // The hall-effect flow sensor outputs approximately 4.5 pulses per second per // litre/minute of flow. floatcalibrationFactor = 5.5; //==========================================================we change cal factor 4.5 to 5.5 if not work chnage again(4.5) //========== 5.5 calibration factor is working efficent then 4.5 , 7.5 ,and 6.5 volatile byte pulseCount; floatflowRate; unsignedintflowMilliLitres; unsigned long totalMilliLitres, tempTotal = -1; unsigned long oldTime; //------------------------------------------------------- intpH_Value; float Voltage; //---------------------------------------------------------------------------------------------- void setup() { // put your setup code here, to run once: Serial.begin(9600); myserial.begin(9600); //-------------------------------- pinMode(sensorPin, INPUT); digitalWrite(sensorPin, HIGH); pulseCount = 0; flowRate = 0.0; flowMilliLitres = 0; totalMilliLitres = 0; // ============================================================ oldTime = 0; attachInterrupt(sensorInterrupt, pulseCounter, FALLING); sensors.begin(); //------------------------------------------------ /********************GSM Communication Starts********************/ if (myserial.available()) Serial.write(myserial.read()); myserial.println("AT"); delay(1000); myserial.println("AT+SAPBR=3,1,\"Contype\",\"GPRS\""); delay(1000); ShowSerialData(); myserial.println("AT+SAPBR=3,1,\"APN\",\"www\"");//APN delay(1000); ShowSerialData(); myserial.println("AT+SAPBR=1,1"); delay(1000); ShowSerialData(); myserial.println("AT+SAPBR=2,1"); delay(1000); ShowSerialData(); //--------------------------------- } void loop() { // put your main code here, to run repeatedly: inti; for (i = 0; i< 20; i++) { flow_meter(); } temperature(); turbidity(); delay(1000); gsm(); } voidflow_meter() { if ((millis() - oldTime) > 1000) // Only process counters once per second { // Disable the interrupt while calculating flow rate and sending the value to // the host detachInterrupt(sensorInterrupt); // Because this loop may not complete in exactly 1 second intervals we calculate // the number of milliseconds that have passed since the last execution and use // that to scale the output. We also apply the calibrationFactor to scale the output // based on the number of pulses per second per units of measure (litres/minute in // this case) coming from the sensor. flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor; // Note the time this processing pass was executed. Note that because we've // disabled interrupts the millis() function won't actually be incrementing right // at this point, but it will still return the value it was set to just before // interrupts went away. oldTime = millis(); // Divide the flow rate in litres/minute by 60 to determine how many litres have // passed through the sensor in this 1 second interval, then multiply by 1000 to // convert to millilitres. flowMilliLitres = (flowRate / 60) * 1000; // Add the millilitres passed in this second to the cumulative total totalMilliLitres += flowMilliLitres; // Print the flow rate for this second in litres / minute /* Serial.print("Flow rate: "); Serial.print(int(flowRate)); // Print the integer part of the variable Serial.print("."); // Print the decimal point */ // Determine the fractional part. The 10 multiplier gives us 1 decimal place. frac = (flowRate - int(flowRate)) * 10; Serial.print(frac, DEC) ; // Print the fractional part of the variable Serial.println("L/min"); /* // Print the number of litres flowed in this second Serial.print(" Current Liquid Flowing: "); // Output separator Serial.print(flowMilliLitres); Serial.print("mL/Sec"); // Print the cumulative total of litres flowed since starting Serial.print(" Output Liquid Quantity: "); // Output separator Serial.print(totalMilliLitres); Serial.println("mL"); */ if ( tempTotal != totalMilliLitres ) { tempTotal = totalMilliLitres; // displayVolumeOfWater(totalMilliLitres ); } // Reset the pulse counter so we can start incrementing again pulseCount = 0; // Enable the interrupt again now that we've finished sending output attachInterrupt(sensorInterrupt, pulseCounter, FALLING); } //========================================================================================================================= } voidpulseCounter() { // Increment the pulse counter pulseCount++; } //------------------------------------------------------------------------- void temperature() { sensors.requestTemperatures(); Celcius = sensors.getTempCByIndex(0); Fahrenheit = sensors.toFahrenheit(Celcius); Serial.print(" C "); Serial.print(Celcius); // Serial.print(" F "); // Serial.println(Fahrenheit); delay(1000); } //------------------------------------------------------------ void turbidity() { intsensorValue = analogRead(A0); voltage = sensorValue * (5.0 / 1024.0); // Serial.println ("Sensor Output (V):"); Serial.println (voltage); // Serial.println(); delay(1000); } //------------------------------------------------------------ voidgsm() { myserial.println("AT+HTTPINIT"); delay(1000); ShowSerialData(); myserial.println("AT+HTTPPARA=\"CID\",1"); delay(1000); ShowSerialData(); StaticJsonDocument<200>JsonDocument; JsonObject& object = JsonDocument.createObject(); object.set("TE", Celcius); object.set("TU", voltage); object.set("WF", frac); delay(1000); object.printTo(Serial); Serial.println(" "); String sendtoserver; object.prettyPrintTo(sendtoserver); delay(1000); //myserial.println("AT+HTTPPARA=\"URL\",\"https://api.thingspeak.com/update?api_key=\""); //Server address myserial.println("AT+HTTPPARA=\"URL\",\"https://api.thingspeak.com/update?api_key=\""); //Server address delay(1000); ShowSerialData(); myserial.println("AT+HTTPPARA=\"CONTENT\",\"application/json\""); delay(1000); ShowSerialData(); myserial.println("AT+HTTPDATA=" + String(sendtoserver.length()) + ",100000"); Serial.println(sendtoserver); delay(1000); ShowSerialData(); myserial.println(sendtoserver); delay(2000); ShowSerialData; myserial.println("AT+HTTPACTION=1"); delay(1000); ShowSerialData(); myserial.println("AT+HTTPREAD"); delay(1000); ShowSerialData(); myserial.println("AT+HTTPTERM"); delay(1000); ShowSerialData; } voidShowSerialData() { while (myserial.available() != 0) Serial.write(myserial.read()); delay(1000); } Thingspeak is not receiving data Id recommend starting with a simpler sketch based on the examples here: <https://github.com/mathworks/thingspeak-arduino> Remember to add sufficient 'delay' to not exceed your channel's update rate, which is typically every 15s or slower with a free ThingSpeak account. Another good first trouble shooting step is to make sure you can update your channel from a web browser. https://api.thingspeak.com/update?api_key=<api key>&field1=12
Matthias in Discussions
Last activity on 6 Feb 2025

I noticed recently that my data is no longer updating on thingspeak again. Is there a connectivity issues with thingspeak Data not updating on thingspeak There are no connectivity issues. Take a look at some public channels that have been continuously updating for a while: https://thingspeak.com/channels/9 https://thingspeak.com/channels/12397 If you have a test channel, try inserting data points from a browser and you can confirm that things are working as expected.
Stefan in MATLAB Answers
Last activity on 30 Jan 2025

I have configured a recurring TC to run once every day. This usually works, but from time to time (about once a week, but with no regular pattern) it seems to take a day off. Without any notice :-) . Seriously, every few days it just seems to skip execution. The configured email notification in case of an error does also not work. Below is a screenshot of what is displayed on 16.1. evening: “Last run 15.1.” (that should actually be today, 16.1. at 6:00 am). Are runs only registered/displayed if they are successful, or does this mean that the script was not started at all? What could be the reason for this strange behavior? Tomorrow it will probably run and show normal values again. If needed, I can specify the days when the script decided not to run. Thank you very much for your help Stefan
Johan Vervaet in MATLAB Answers
Last activity on 29 Jan 2025

Manfred Kreidl in Discussions
Last activity on 27 Jan 2025

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 Connection stability problem? I have devices connected by MQTT for months now and the connection is rock solid. It is likely that the connection is being disconnected when you try to subscribe to an invalid topic or to a topic the device is not authorized for. What is the topic you're subscribing to over the MQTT connection? I tried now the installed Windows version of MQTTX. All 4 connection types (web, tcp encrypted or not) are working fine. With the web-version https://mqttx.app/web-client# I could not establish connection. Also not with the HIVMQ client... MQTT Websocket Client I was able to use the MQTTX web client. See screenshot below: Note that you can only connect from using the same credentials from one "device" at a time. So, if you are using the same credentials from the desktop and the webclient at the same time, you will see disconnected/reconnected on both. mqtt connection stability prob
Bernard P S in Discussions
Last activity on 27 Jan 2025

Need code to collect data of waterflow sensor using ESP 8266 and to stoe it in ThingSpeak cloud Water flow sensor using ESP8266 Bernard, Curious about your question. Why not use the many examples already provided here and on the web? Is there some special reason you are asking such a broad question? You will find many generous folks here that would be willing to help you, but they would be better motivated if they knew a bit more about you and your circumstances. Regards
Michael Gacsaly in MATLAB Answers
Last activity on 24 Jan 2025

I want to create a ThingSpeak Matlab Visualization Plot with data tips (similar to the defaut ThingSpeak plot visualization). When I enable this with after tge plot with: dcm = datacursormode; dcm.enable = "on"; I get data tips that say how long ago the plot was updated ("seconds ago"). So I tried to define an update function (from an example). But that did not help. Seeing the Matlab code that generates the default ThingSpeak plot would likely answer my question...but I could not find it. dcm.UpdateFcn = @displayCoordinates; function txt = displayCoordinates(~, info) txt = {sprintf('X: %.5f', info.Position(1)), sprintf('Y: %.5f', info.Position(2))}; end
Kolbe in MATLAB Answers
Last activity on 23 Jan 2025

I have these TCs running every day. However yesterday I noted it seems the TC execution got stuck for 2 of them? Below screenshot is from today, so it is weird these do not show the correct future time, also note the 1 min difference bw. Last Ran & Run At ... I now modifed and saved both and it seems they got "restarted" and now show the future date correctly. Hopefully that did not destroy the evidence :) but you have below screenshot anyway. Hope someone can figure out what made these get "stuck"?
Aarnout Wieers in MATLAB Answers
Last activity on 13 Jan 2025

How to read the fieldname from a field in ThinkSpeak when using ThinkSpeak library for Arduino?
Mahesh Prasath in Discussions
Last activity on 11 Jan 2025

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); } I am using example program WiFiClient, write is working fine, but read is giving error 404 A couple of comments: 404 is not found, so I would suggest a serial.println on this line so you can see what is actually getting sent. Then try it in your browser wndow you help you trouble shoot it. 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"; it should look something like this: https://api.thingspeak.com/channels/2005329/field/1.json?results=4 I would suggest explicitly including the host address (api.thingspeak.com). You can also try to verify that you have the channel ID correct. We really reccomend you use the ThingSpeak library for arduino. It takes care of a lot of hard work for you. You can definitely send non integer values to thingspeak. The interfect trats everything as a string, but then the thingspeak plots will attempt to interprest numbes as integers or floats or what have you. API keys are kind of like passwords, so I have redacted them in your code above. Good luck on your project, please let us know if you get it working! Hi Chris, Thanks for your response, I got it sloved, readApikey was missing i added it as in the below and the code worked. String readRequest = "GET /channels/" + channelID + "/fields/" + fieldNumber + ".json?api_key=" + readApiKey + "&results=" + numberOfResults + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"; read 404 error
Mic So in MATLAB Answers
Last activity on 8 Jan 2025

After login I got sweet message: Expired License Your trial license has expired as of September 4, 2019. In account settings: License Type: Free Expiration Date: 04 Dec 2019 Available Remaining Messages 3 000 000 2 851 627 Channels 4 2 Upload to channels stopped working on september 4th...

About ThingSpeak

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.