Jürgen Zick in MATLAB Answers
上次活动时间: 2024-6-4

Hello, since some time a script is not working anymore, it is timing out. I could track down the problem to thingSpeakRead. I am reading some data to be visualized by this: [loc_comp, timeStamps] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'ReadKey', readAPIKey, DateRange=[(datetime - days(1)), datetime]); It was working this way approx. until April and then I ignored it first. Now I'd like to use that visualization again but can't it get it to work. If I replace the channel read by some fixed test data everything else is running as before. Just the channel read is not working ... channel id, field number and read key have not changed... Any ideas? The Timeout=xx parameter did not help as well ... Thanks, Jürgen Edit: i also tried e.g. [loc_comp, timeStamps] = thingSpeakRead(123456, Fields=[6], ReadKey='MySecretKey', NumPoints=15, Timeout=60); with the same timeout error appearing ..
Dimitris Lymperis in MATLAB Answers
上次活动时间: 2024-1-5

I am using the following commands in a script to retrieve the records from the last 5 minutes of two diffirent temperature sensors. Temp_1 = thingSpeakRead(readChannelID_1,'Fields',Temperature_1_FieldID,'NumMinutes',5,'ReadKey',readAPIKey_1,'OutputFormat','timetable') Temp_2 = thingSpeakRead(readChannelID_2,'Fields',Temperature_2_FieldID,'NumMinutes',5,'ReadKey',readAPIKey_2,'OutputFormat','timetable') Some times i get a good one timetable with double values (rarely) for temperature and some other time i get a cell array with the following format. Timestamps Temperature_2 ____________________ _____________ 17-Dec-2020 23:16:00 {'nan' } 17-Dec-2020 23:16:16 {'16.10000'} 17-Dec-2020 23:16:31 {'16.10000'} 17-Dec-2020 23:18:52 {'16.10000'} 17-Dec-2020 23:19:09 {'nan' } 17-Dec-2020 23:19:25 {'16.10000'} 17-Dec-2020 23:19:41 {'16.10000'} 17-Dec-2020 23:20:28 {'16.10000'} 17-Dec-2020 23:20:44 {'16.10000'} why does it happen and how can i get only the double values?
rene in Discussions
上次活动时间: 2022-12-1

Hello, I need help with this code to show the longitude and latitude from the neo6m module. When the map is displayed, it looks very close. How can I fix it? It is for a university project I hope you can help me thanks https://thingspeak.com/apps/matlab_visualizations/488254 code: lat = thingSpeakRead(1962341,'Fields',3,'ReadKey','ZHIVMUHTJXI4xxxx','NumPoints',10,'Timeout',50); lon = thingSpeakRead(1962341,'Fields',4,'ReadKey','ZHIVMUHTJXI4xxxx','NumPoints',10,'Timeout',50); geoscatter(lat,lon,'h'); geobasemap('satellite'); edit zoom map latitude longitude I would suggest using a single read. myData=thingSpeakRead(...'fields','[3,4]'); myMap= geoscatter(myData(:,1),myData(:,2)); You can change the zoom level on the map, but it should default to show the scatter of your points. you can use geolimits to change the limits geolimits(2*[min(myData(:,1) max(myData(:,1))],[min(myData(:,2) max(myData(:,2))]); % not tested syntax thanks for the answer i solve this with this code ax=gca; ax.ZoomLevel=17; longitude latitude thingspeakread geobasemap zoom
MathWorks Internet of Things Team in MATLAB Answers
上次活动时间: 2022-11-26

I want to write information for controlling a device in my ThingSpeak channel, can I store the control parameters in ThingSpeak and read all of the paremeters at once back to the device? I'd like to be able to read multiple fields without having to make multiple calls to the ThingSpeak readfield command on my Arduino or esp32 or ESP8266. Is this possible?
Luke Martin in MATLAB Answers
上次活动时间: 2022-7-13

Hi folks, I'm looking for a way to set the '2733' in my command below equal to the amount of datapoints available. [data, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 2733, 'ReadKey', readAPIKey); For context, I'm trying to setup visualisations that still work when the dataset in the channel is changed. For my current dataset, I have 2733 lines so the above works, but I'd like to get it to the point where it can work without amendment when I change the dataset. Thanks!
Vinicio Moya in MATLAB Answers
上次活动时间: 2020-7-9

Hello! I have a channel in ThingSpeak. Field number 4: Temperature, with some data. But, when I try to read that data in Simulink, I only receive 0... What could be happening? Simulink model: Configuration in simulink ThingSpeak data: REsponse:
Andrew Clark in MATLAB Answers
上次活动时间: 2020-2-12

I am receiving runtime errors when running this Matlab example [ MathWorks Internet of Things Team (2020). Air Quality Measurements and Visualizations (https://www.mathworks.com/matlabcentral/fileexchange/71908-air-quality-measurements-and-visualizations), MATLAB Central File Exchange. Retrieved February 7, 2020.] using my Thingspeak Public channel data. It sometimes runs successfully, but mostly ends with these error codes. There is obviously some sort of problem with the data being read. I have checked the data in the Channel and in the specific field and it looks ok. I have tried reducing the number of minutes ("NumMinutes") to a lower number but get same result. Perhaps there is a date or time issue, since I am asking for 1440 minutes, which is 24 hours. Can anyone shed any light on what could be causing these issues? Thanks much. This is the code: % This script acquires data from a public ThingSpeak channel located at % the MathWorks Headquarters in Natick, MA, and uses it to calculate % an Air Quality Index (AQI). % Copyright 2019 The MathWorks, Inc. % Prior to running this MATLAB code template, assign the channel ID to read % data from to the 'readChannelID' variable. Also, assign the field ID % within the channel that you want to read data from to plot. % TODO - Replace the [] with channel ID to read data from: %%readChannelID = 357142; readChannelID = 891066; yourChannel = 839634; yourChannelWriteKey = 'xxxxxxxxxxxxxxxxxxx'; % TODO - Replace the [] with the Field ID to read data from: fieldID1 = 2; % Channel Read API Key % If your channel is private, then enter the read API % Key between the '' below: readAPIKey = ''; %% Read Data %% [rawData, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'Numminutes', 1440, 'ReadKey', readAPIKey); localTime = time - hours(7); % adjust for local time in Sunnyvale CA %% Run custom function that analyzes collected data, computes AQI and plots collected data returnAQI = analyzeplotAQI(localTime,rawData); %% Send computed AQI to ThingSpeak Channel (Field 1) thingSpeakWrite(yourChannel,returnAQI,'WriteKey',yourChannelWriteKey,'Fields',8); % CUSTOM FUNCTIONS BELOW % Main function that smoothes collected data and calls other custom functions function returnAQI = analyzeplotAQI(localTime,rawData) %% Smooth data smoothData = movmedian(rawData,10); % Find max and plot data smoothDataMax = max(smoothData); plotfun(localTime,rawData,smoothData,smoothDataMax) % Combine smoothed data with time as # of elements are the same smoothParticulateDataTable = table(localTime,smoothData,'VariableNames',{'Time','Particulate_Conc'}); % Calculate AQI pmObs = round(mean(smoothParticulateDataTable{:,2}),1); % Calculate 24 hour running average returnAQI = calculateAQI(pmObs); end %% Plot Data function plotfun(localTime,rawData,smoothData,smoothDataMax) plot(localTime, rawData); hold on plot(localTime,smoothData,'-*') % Plot max of smooth data line(localTime,smoothDataMax * ones(length(localTime),1),'LineStyle','--') title('2.5 micron particulate concentration \mug/m^{3}') xlabel('Time'); ylabel('Concentration \mug/m^{3}'); legend('Collected data','Smoothed data','Max of Smooth Data','Location','best') axis tight hold off end %% Calculate AQI function returnAQI = calculateAQI(pmObs) % Learn about how AQI is calcuated % https://www.epa.gov/outdoor-air-quality-data aqiLow = [0;51;101;151;201;301]; aqiHigh = [50;100;150;200;300;500]; concLow = [0;15.5;40.5;65.5;150.5;250.5]; concHigh = [15.4;40.4;65.4;150.4;250.4;500.4]; % Create Look Up Table lutAQI = table(aqiLow,aqiHigh,concLow,concHigh,... 'VariableNames',{'AQI_low','AQI_high','PM_low','PM_high'}); % Find the necessary equation parameters rowIdx = find(pmObs >= lutAQI.PM_low & pmObs <= lutAQI.PM_high); PM_min = lutAQI.PM_low(rowIdx); PM_max = lutAQI.PM_high(rowIdx); AQI_min = lutAQI.AQI_low(rowIdx); AQI_max = lutAQI.AQI_high(rowIdx); returnAQI = round((((pmObs - PM_min) * (AQI_max - AQI_min))/(PM_max - PM_min)) + AQI_min); end And these are the Output error messages I am getting: Warning: Ignoring extra legend entries. > In legend>process_inputs (line 594) In legend>make_legend (line 335) In legend (line 279) In AQI Calculator>plotfun (line 50) In AQI Calculator>analyzeplotAQI (line 33) In AQI Calculator (line 23) Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Error in AQI Calculator>calculateAQI (line 71) returnAQI = round((((pmObs - PM_min) * (AQI_max - AQI_min))/(PM_max - PM_min)) + AQI_min); Error in AQI Calculator>analyzeplotAQI (line 38) returnAQI = calculateAQI(pmObs); Error in AQI Calculator (line 23) returnAQI = analyzeplotAQI(localTime,rawData);
Mario Chiappelli in MATLAB Answers
上次活动时间: 2019-7-18

I am getting this error warning when attempting to compile an app that needs the ThingSpeak Toolbox Support add on in order to properly function: "P files can not be analyzed to find their required fields. Please add P file requirements manually." For context, I have a sensor updating ThingSpeak and my app generates a report based off of the data in ThingSpeak. The app works perfect when in the normal MatLab window but when I exported it into an executable file, the report is never generated. I did some research and concluded I needed to add the ThingSpeak Toolbox Support add on to fix this but I have no idea hwo to "add P file requirements manually." The only command I need to give the app access to is ThingSpeakRead. I am making this in App Designer. Thanks in advance
mbarak afef in MATLAB Answers
上次活动时间: 2019-5-30

writeChId = 123; % Replace with your channel number writeKey = 'XXX'; % Replace with your channel write key [temp,time] = thingSpeakRead(readChId,'Fields',4,'NumPoints',20); humidity = thingSpeakRead(readChId,'Fields',3,'NumPoints',20); tempC = (5/9)*(temp-32); b = 17.62; c = 243.5; gamma = log(humidity/100) + b*tempC./(c+tempC); dewPoint = c*gamma./(b-gamma) dewPointF = (dewPoint*1.8) + 32; thingSpeakWrite(writeChId,[temp,humidity,dewPointF],'Fields',[1,2,3],... 'TimeStamps',time,'Writekey',writeKey);

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