Roger in MATLAB Answers
上次活动时间: 2025-7-15

Hello, I am new to ThinkSpeak so thought I would try your example code for ESP8266 -- ThinkSpeak Channel. Have spent much time making sure all is installed and seems to compile, load and run on ESP8266 Node MCU. Channel is set up and have ID and Author ID I can see the channel but nothing noted. I am getting the above return on serial monitor. Any help very gratefully recieved, please.
Johan Vervaet in MATLAB Answers
上次活动时间: 2025-7-7

I simply want to regenerate my password which I am forgotten of one of my MQTT devices.
Innosens in MATLAB Answers
上次活动时间: 2025-7-3

Hi, my channel upated time showed current time and date, but data did not appear in channe and last entry was 5 hours ago
M Ramzan in MATLAB Answers
上次活动时间: 2025-6-18

I'm using an ESP32 to collect data from an MPU6050 sensor. The ESP32 buffers 170 samples at a time and uploads them to ThingSpeak using the bulk update API. However, the data entries received on ThingSpeak are inconsistent. Here's the pattern of total entries I see on the channel after each upload: After 1st upload: 170 entries (correct) After 2nd upload: 338 entries (should be 340) After 3rd upload: 499 entries (should be 510) After 4th upload: 657 entries (should be 680) After 5th upload: 818 entries (should be 850) As you can see, the expected total should increase by 170 each time, but it's losing a few samples in each batch, and the number of missing entries increases over time. The losses are not consistent — it seems like 1 or 2 samples get dropped randomly in each interval. Some things I’ve considered: The ESP32 is collecting and sending the full buffer (verified via serial debug). Could it be a payload size limit, HTTP timeout, or formatting issue? Maybe ThingSpeak is silently dropping malformed lines from the bulk update? Has anyone else run into this with buffered uploads to ThingSpeak? Any tips for debugging the exact cause of dropped samples? Thanks for any help!
sravani kandi in MATLAB Answers
上次活动时间: 2025-6-18

how to post matlab output to a website by not using thingspeak?
Klaus in MATLAB Answers
上次活动时间: 2025-5-29

Hi, I tried to delete a channel data using POSTMAN as described here https://www.mathworks.com/help/thingspeak/clearchannel.html in Examples section: Use POSTMAN to Clear Channel The channel ID is correct, the write API key is correct, and the answer of postman after sending request is: { "status": "401", "error": { "error_code": "error_auth_required", "message": "Authorization Required", "details": "Please provide proper authentication details." } } I already tried to authorize me in Authorization tab using Basic Auth (username and password), but the result is the same. I already tried to use api_key in the request command directly: https://api.thingspeak.com/channels/1234567/feeds.json?api_key=XXXXXXXXXXXXXXXX The result is the same. 🙁 Does this channel deletion method work at all on ThingSpeak?
Mi He2 in MATLAB Answers
上次活动时间: 2025-5-18

Over the past few days, I’ve observed that MATLAB visualizations on ThingSpeak are not rendering correctly when accessed via the public URL. When I run the MATLAB Visualization script manually within ThingSpeak, the resulting image has the correct resolution and aspect ratios. However, accessing the same visualization through the public URL generates a much smaller image with distorted proportions. The script itself hasn’t been modified for a long time, and this issue has only started occurring recently. Could this be related to a recent change in the rendering engine or visualization settings on ThingSpeak? I would appreciate any guidance or insight into what might be causing this discrepancy. Thank you!
Martin Exner in MATLAB Answers
上次活动时间: 2025-5-14

Hi. I have issues getting live data in ThingSpeak working with Elecfreaks IoT-kit. Is this a known issue? I have had it working before, so its not my code thats the problem :) Regards Martin
Ray Berkelmans in MATLAB Answers
上次活动时间: 2025-5-12

I am trying to calculate the daily median across a range of channels and write the result to a new field for each channel. The code seems to run sometimes, but runs into rate limitation other times. I'm not sure why since I am only writing once and to different channels? Error using Median calcs (line 39) Requests are too frequent. For further information, see Limitations in the documentation. My code is: % Sensor/channel configuration sensors = [ struct('name', 'McKinley','channelID', 28xxxx, 'writeKey', 'G3WPJ586M55Gxxxx') struct('name', 'DPI', 'channelID', 80xxxx, 'writeKey', 'S0E0LB45GQLMxxxx') struct('name', 'Bryony','channelID', 29xxxx, 'writeKey', '2BPCI0IOAINPxxxx') ]; % Define date range (last 24 hours to midnight) endTime = dateshift(datetime('now'), 'start', 'day'); startTime = endTime - hours(24); % Preallocate a results array results = []; % Step 1: Read and calculate all medians for i = 1:length(sensors) s = sensors(i); % Read Field 1 for the past 24 hours [weight, ~] = thingSpeakRead(s.channelID, 'DateRange', [startTime, endTime], 'Fields', 1); % Compute median, ignoring NaNs medianWeight = round(median(weight, 'omitnan'),2); % Store in results results(i).name = s.name; results(i).channelID = s.channelID; results(i).writeKey = s.writeKey; results(i).value = medianWeight; end % Step 2: Display results for i = 1:length(results) r = results(i); fprintf('%s (Channel %d) → 24hr Median: %.2f\n', r.name, r.channelID, r.value); end % Step 3: Write results thingSpeakWrite(results(1).channelID, 'Fields', 6, 'Values', {results(1).value}, 'WriteKey', results(1).writeKey); thingSpeakWrite(results(2).channelID, 'Fields', 6, 'Values', {results(2).value}, 'WriteKey', results(2).writeKey); thingSpeakWrite(results(3).channelID, 'Fields', 6, 'Values', {results(3).value}, 'WriteKey', results(3).writeKey);
Ajay Kumar in MATLAB Answers
上次活动时间: 2025-5-11

Basically, I am getting temperature values and trying to send an email alert whenever the temperature exceeds a specific point. But however the code runs but yet I am facing an error that says Error using matlab.internal.webservices.HTTPConnector/copyContentToByteArray (line 373) The server returned the status 429 with message "Too Many Requests" in response to the request to URL https://api.thingspeak.com/alerts/send. Error in readContentFromWebService (line 46) byteArray = copyContentToByteArray(connection); Error in webwrite (line 139) [varargout{1:nargout}] = readContentFromWebService(connection, options); Error in Customer Temperature Email Trigger (line 10) webwrite(alertUrl , "body", alertBody, "subject", alertSubject, options); I am also attaching the code. channelID = 1614947; alertApiKey = 'PRIVATE_ALERT_API_KEY'; alertUrl="https://api.thingspeak.com/alerts/send"; options = weboptions("HeaderFields", ["ThingSpeak-Alerts-API-Key", alertApiKey ]); temperature = thingSpeakRead(channelID,'NumDays',30,'Fields',1); recentvalue = temperature(end) alertSubject = sprintf("Temperature Alert"); alertBody = sprintf(" The temperature of the customer entering the store is high : ",recentvalue); if recentvalue > 32 webwrite(alertUrl , "body", alertBody, "subject", alertSubject, options); end Basically the other articles tell me that I have to enter a delay or a pause because the free version of thingspeak has limitations. Any idea on what I could do to make sure the code runs with minimal amount of delay?
Chris in MATLAB Answers
上次活动时间: 2025-5-9

I am currently running a ThingSpeak Maltlab analysis that reads the latest channel status and acts on it. I am using this code, which works fine: url='https://api.thingspeak.com/channels/mychan/feeds/last.json?api_key=mykey&status=true'; lastData=webread(url); status = [lastData.status]; I am trying to figure out how to change this to read the last 3 channel statuses and put them into an array like status(i) where i goes from 1-3? This url returns the 3 statuses I want: url = https:'//api.thingspeak.com/channels/mychan/status.json?api_key=mykey&results=3' But I can't figure out how to get them into an array to work with. Does anyone know how to do this? Thanks.
Bernd in MATLAB Answers
上次活动时间: 2025-4-22

I know how to write data with MATLAB Analysis to channel, in my case I read the absolute value from my electricity counter (which updates every 1min) and calculate the consumption of the last 20min. datetimeStop = datetime('now'); datetimeStart = datetime('now')- minutes(20); data = thingSpeakRead(readChannelID, Fields=[1], DateRange=[datetimeStart,datetimeStop], ReadKey=readAPIKey); analyzedData = data(length(data)) - data(1); thingSpeakWrite(writeChannelID, analyzedData, WriteKey=writeAPIKey); I would like to write to a second channel the average consumption for each hour of the day, e.g. 01:00, 02:00, ... My problem: With thingSpeakWrite I add values to a channel, but if I calculate the running average for each hour at every new day - with (n*avg_old + new_value)/(n+1) - I want to update/replace the average. How is that possible? BR Bernd
K0I05 in MATLAB Answers
上次活动时间: 2025-4-16

Hello, I have done this in other environments but I haven't touched MATLAB in years and seeking a bit of direction. I am pushing environmental data to ThingSpeak at a 1 minute interval and one parameter that I am looking to plot is precipitation type. This parameter is coded and utilizes a look-up table as follows: (0) No Rain, (1) Rain, (2) Snow, (3) Rain-Snow, (4) Hail, (7) Rain-Snow-Hail. I used a stacked bart chart in the past. I would query the database, filtered the data by code and created a time series dataset for each code, replaced the original code in the created time series dataset with value of 1 and insert a value of 0 for timeticks that didn't have a coded type value, and plotted each times series dataset. A screenshot of my previous implementation in MACHBASE is attached. Any guidance would be grealy appreciated. Thanks .
kevin wright in MATLAB Answers
上次活动时间: 2025-4-14

Hi, I've been trying to use the new Arduino 4 (wifi version) to communicate with ThingSpeak. The r4 has wifi capabilities, how hard can it be? The answer seems to be 'plenty hard' as none of the libraries seem to want to play well. If anybody has actually managed this, please can you share?
tao in MATLAB Answers
上次活动时间: 2025-4-10

Tingspeak: I use the first chennel to receive data, and every time the received data is greater than 0, matlab analysis is triggered by react, and the results are written into the second channel. The first channel receives data every 20 seconds. Finally, it was found that the second channel missed a lot of data. May I ask what causes it?
R. De Gruijter in MATLAB Answers
上次活动时间: 2025-4-10

See my post here for more info: <www.thethingsnetwork.org/forum/t/49946 https://www.thethingsnetwork.org/forum/t/payload-formatter-v3-how-to-return-rssi-and-snr-to-a-thingspeak-channel/49946> .In the payload formatter I cannot access information like SNR (signal to noise ratio) of a lorawan message. But this information is definitely available in the Things Stack. So how do I get this data into a ThingSpeak channel for recording?
Thomas in MATLAB Answers
上次活动时间: 2025-4-3

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
上次活动时间: 2025-3-21

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
上次活动时间: 2025-3-19

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
上次活动时间: 2025-3-18

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
上次活动时间: 2025-3-18

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
上次活动时间: 2025-3-10

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
上次活动时间: 2025-3-10

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
上次活动时间: 2025-3-7

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
上次活动时间: 2025-3-5

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?

关于 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.