Results for
Hi - I noticed that after what seems like 12 hours or less, Thingspeak restarts my graph and old values are not displayed. I read about sample limits. Also a mention of a time limit here: https://community.thingspeak.com/forum/general/chart-view-limited-to-2-hours/ Is this the case? (I can of course reduce my update time.
Thanks
Russell
Hi. simple question: im getting a 401 error when I try to delete data in a channel yet if i just change 'requests.get(...)' to 'requests.delete(...) i get a 401 error. what am i doing wrong? thanks
Hallo,
bei THINKSPEAK werden auf dem Handy max 60 Werte angezeigt.
Bei 1 Wert pro Stunde sieht man also 2,5 Tage.
Ich würde lieber 1 Wert pro Tag senden und damit 60 Tage im Überblick haben.
Gibt es dafür eine Lösung ?
Danke & MfG
Peter Benger
Hi all, The ThingSpeak API provides the possibility to embed the chart with historical values of a channel in a web page. Now I would also like to show the last value of a channel as a number on this page. I looked into some of the answers. But I could not understand. Can someone please share the JavaScript code OR the HTML code? I am new to ThingSpeak and Web Development. Please help me out!!
Thank you, Prajna Bhat
I'm accessing internet on my Arduino uno using esp-01, is there a thingspeak Library i can use on this to send data to my thingspeak channel.
Hello,
Anyone could help me to write data to a channel using micropython on ESP8266 or ESP32? I found nothing update on forums (Thingspeak, Micropython, web...)
Thanks a lot
#include WiFi.h #include "secrets.h" #include "ThingSpeak.h" #include hcsr04.h // connect to wifi char ssid[] = "long2000"; // your network SSID (name) char pass[] = "88888888"; // your network passwword int keyIndex = 0; // your network key Index number (needed only for WEP) WiFiClient client; unsigned long myChannelNumber = 1434038; const char * myWriteAPIKey = "1SXFRPC5DG3FMDM0"; const char * server = "api.thingspeak.com"; unsigned long duration; //time variable
// setup HC-SR04 #define HC-SR04
const int trig = 18; const int echo = 19; void setup() {
Serial.begin(9600); // communicate Serial to baudrate 9600 pinMode(trig,OUTPUT); pinMode(echo,INPUT); while (!Serial) // đợi cổng nối tiếp kết nối. Chỉ cần cho cổng USB gốc Leonardo WiFi.mode(WIFI_STA); ThingSpeak.begin(client); // Initialize ThingSpeak
} void loop() { float Distance; //distance variable // Connect or reconnect to WiFi if(WiFi.status() != WL_CONNECTED){ Serial.print("Attempting to connect to SSID: "); Serial.println(SECRET_SSID); while(WiFi.status() != WL_CONNECTED){ WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network
digitalWrite(trig,0);
delayMicroseconds(2);
digitalWrite(trig,1);
delayMicroseconds(5);
digitalWrite(trig,0); duration = pulseIn(echo,HIGH);
Distance = (duration/2/29.412);
Serial.print(Distance);
Serial.println("cm");
delay(2000);
// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different
// pieces of information in a channel. Here, we write to field 1.
int x = ThingSpeak.writeField(myChannelNumber, 1, Distance, myWriteAPIKey);} delay(2000); } }
I'm new and I'm doing work for college and I'm having a hard time doing this part, I can send the data to thingspeak, but I don't know how to get for example the status of field 1 and check if it is 1 or 0 , I want to do this so that later using esp32 I can turn on a real led, could someone please help me
here is my code, i want to recive an email notification when my "alerta" field increase.
% Read the soil moisture channel data from the past two weeks.
% Send an email and tell the user to add water if the value
% is in the lowest 10 %.
% Store the channel ID for the moisture sensor channel.
channelID = 1425554;
% Provide the ThingSpeak alerts API key. All alerts API keys start with TAK.
alertApiKey = 'TXXXXXXXXXXXX';
% Set the address for the HTTTP call
alertUrl="https://api.thingspeak.com/alerts/send";
% webwrite uses weboptions to add required headers. Alerts needs a ThingSpeak-Alerts-API-Key header.
options = weboptions("HeaderFields", ["ThingSpeak-Alerts-API-Key", alertApiKey]);
% Set the email subject.
alertSubject = sprintf("Alertas");
% Read the recent data.
Alerta = thingSpeakRead(channelID,'NumDays',30,'Fields',8);
% Get the most recent point in the array of moisture data.
lastValue = Alerta(end);
% Set the outgoing message
if (lastValue<=Alerta)
alertBody='alerta de anomalia de fluxo de agua';
end
% Catch errors so the MATLAB code does not disable a TimeControl if it fails
try
webwrite(alertUrl, "body", alertBody , "subject", alertSubject, options);
catch someException
fprintf("Failed to send alert: %s\n", someException.message);
endHow much storage limit or maximal storage thingspeak? and how much size (byte) per fields?
Hi. I am a begginer.
I did a sample "Calculate high and low temperatures" with matlab analysis. I want to write data in a specified field in the new channel. I do not know how to do that. I already replace the empty spaces with channel ID and Api key. Then, when i try to set the field that i want to, it returns an error.
Is it right doing like I mention here:
thingSpeakWrite(writeChannelID,'Fields',[2],maxTempF,'timestamp',timeMaxTemp,'WriteKey',writeAPIKey);
Hello folks,
I have a fits file of size (300,300,3) and I would like to access to each channel, but I can't with this code. Any idea please.
stokes = fitsread('stokes1.fits');
Iu = stokes(:,:,1); Ip = stokes(:,:,2); Theta = stokes(:,:,3);
fitswrite([Iu,Ip,Theta],'stokes.fits')
I'm a newbie in Thingspeak. I have tried manytime to upload my code using the example from library to thingspeak but nothing be happened. I'm using Esp6266. Would you mind helping me?
if true /* WriteMultipleFields
Description: Writes values to fields 1,2,3,4 and status in a single ThingSpeak update every 20 seconds.
Hardware: ESP8266 based boards
!!! IMPORTANT - Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!!
Note: - Requires ESP8266WiFi library and ESP8622 board add-on. See https://github.com/esp8266/Arduino for details. - Select the target hardware from the Tools->Board menu - This example is written for a network using WPA encryption. For WEP or WPA, change the WiFi.begin() call accordingly.
ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize, and analyze live data streams in the cloud. Visit https://www.thingspeak.com to sign up for a free account and create a channel.
Documentation for the ThingSpeak Communication Library for Arduino is in the README.md folder where the library was installed. See https://www.mathworks.com/help/thingspeak/index.html for the full ThingSpeak documentation.
For licensing information, see the accompanying license file.
Copyright 2020, The MathWorks, Inc. */
#include ESP8266WiFi.h #include "secrets.h" #include "ThingSpeak.h" // always include thingspeak header file after other header files and custom macros #include Arduino.h #include "Adafruit_SHT31.h" Adafruit_SHT31 sht31 = Adafruit_SHT31();
char ssid[] = SECRET_SSID; // your network SSID (name) char pass[] = SECRET_PASS; // your network password int keyIndex = 0; // your network key Index number (needed only for WEP) WiFiClient client;
unsigned long myChannelNumber = SECRET_CH_ID; const char * myWriteAPIKey = SECRET_WRITE_APIKEY;
String myStatus = "";
void setup() { Serial.begin(115200); // Initialize serial while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo native USB port only }
WiFi.mode(WIFI_STA); ThingSpeak.begin(client); // Initialize ThingSpeak
sht31.begin(0x44);
}
void loop() {
// Connect or reconnect to WiFi
if(WiFi.status() != WL_CONNECTED){
Serial.print("Attempting to connect to SSID: ");
Serial.println(SECRET_SSID);
while(WiFi.status() != WL_CONNECTED){
// WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network
WiFi.begin(); Serial.print(".");
delay(5000);
}
Serial.println("\nConnected.");
}
//+++++++++++++++++++++++++++SHT31 Sensor float t = sht31.readTemperature(); float h= sht31.readHumidity();
if (! isnan(t)) { // check if 'is not a number'
Serial.print("Temp *C = ");
Serial.print(t);
Serial.print("\t\t");
}
if (! isnan(h)) { // check if 'is not a number'
Serial.print("Hum. % = ");
Serial.println(h);
}
// set the fields with the values ThingSpeak.setField(1,t); ThingSpeak.setField(2,h);
// write to the ThingSpeak channel
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));
}
delay(20000); // Wait 20 seconds to update the channel again } end
Does Thingspeak Has MQTT support? If yes please navigate.
R SRIRANJANI RAMAKRISHNAN is our current top ThingSpeak related downloads contributor. Check out the Raspberry Pi and ThingSpeak model downloaded by over 50 users! And Barnard Richards has 10 new posts on our community in the last month. Please reach out to us for a free MathWorks T-Shirt. You can find contact information on my profile page. Thank you for your contributions and your posts!
Are you using ESP32 and want to help us develop functionality for it? We are looking to add support for ESP32 boards in MATLAB. If you have experience with ESP32 and care to share your workflows with us, please let me know here and we will reach out to you for a short interview.
Could you help me know what problem is in this code? I'm trying to show one plot by App Designer. Without App Designer, below code is working to make a plot. Could you let me know how I could make a plot by using the attached file? Thank you!
properties (Access = private)
TimePoints
Raw_Data % Data for only case & death
Case
Deathend
methods (Access = private)
function startupFcn(app)
load covid_data.mat data;
app.Raw_Data = cell2mat(covid_data(2:end,3:end));
Temp = covid_data(1,3:end);
app.TimePoints = datetime(Temp);
app.Case = sum(app.Raw_Data(:,1:2:end));
app.Death = sum(app.Raw_Data(:,2:2:end));
yyaxis(app.UIAxes,"left");
plot(app.UIAxes,app.TimePoints,app.Case);
yyaxis(app.UIAxes,"right");
plot(app.UIAxes,app.TimePoints,app.Death);
endI have seen this before and so i added some debug prints to my python script to make sure the posts to the channel were happening. See attached it looks like data stopped posting today at ~ 9:15am AZ time but actually the debug prints show [200] as it should, Posts happen every 1 minute. Am I posting too often or why is response always [200] but it does not render? Sometimes it will 'disappear' and then start showing up again hours later...(just did it actually) thanks
I don't understand what the -301 error means when trying to write a field to ThingSpeak. I checked my key and my write ID is OK ... The same program on another Arduino Mega and shield W5100 (but on another channel) works well ... Does anyone have any idea what the meaning of this error code is to know in which direction to look! Thank you
code :
void thingspeak(float t, float h, float units, int lum, int TempInt){
ThingSpeak.setField(1, t);
ThingSpeak.setField(2, h);
ThingSpeak.setField(3, units);
ThingSpeak.setField(4, lum);
ThingSpeak.setField(5,TempInt);
ThingSpeak.setStatus("Update OK: ");
/* écriture des champs dans ThingSpeak */ int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
if(x == 200){
Serial.println(F("Update of ThingSpeak ok."));
} else err(6,x); // error handling
} // end of function thingspeak
How to read a JSON output of another device and put data into thingspeak channel:
Maybe useful for others: just figured out, how to parse a JSON, search for a special entry and enter searched value into thingspeak. For this I used the "Get data from webpage" template. An internet search resolved the access to the UBIBOT-json output at "https://api.ubibot.com/channels?account_key=XXX". This is used as "spcify URL". Having several devices a unique search keyword is needed and added in the template for the "specify target string".
So even if the template is not 100% for JSON abjects, this is a quick and dirty method to read it out and use it for further analysis.
Full code is this:
% TODO - Specify URL of the page to read data from
url = 'https://api.ubibot.com/channels?account_key=yyy';
% TODO - Specify the target string to search in webpage
targetString = 'last_values":"{\"field3\":{\"value\":';
% TODO - Replace the [] with channel ID to write data to: writeChannelID = 666; % TODO - Enter the Write API Key between the '' below: writeAPIKey = 'yxc';
%% Scrape the webpage %% data = urlfilter(url, targetString);
%% Analyze Data %% analyzedData = data;
%% Write Data %% thingSpeakWrite(writeChannelID, analyzedData, 'WriteKey', writeAPIKey);