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.
Vinicio Moya in MATLAB Answers
上次活动时间: 2021-6-29

Hello everybody! I need to use a Raspberry Pi that get data from a ThingSpeak channel in a standalone configuration, but the problem is that functions ThingSpeakRead and webread are not supported. What can I do? direccion=['https://api.thingspeak.com/channels/' chId '/feeds.json?api_key=' Read '&results=' cPoints]; datos=webread(direccion); Function 'webread' not supported for code generation
Mehran Rahmani in MATLAB Answers
上次活动时间: 2020-10-25

The issue was addressed by finding the API webpage of the main website. Then, I requsted an API-Key via an online form. They provided me an API key for accessing some basic data. However, more data needed a paid membership.
Mark Morehead in MATLAB Answers
上次活动时间: 2020-3-19

I am attempting to use webread to download data from a REST web service that uses authentication. I am having problems and I think it is with the authentication. I can put the following into a web browser and get the data I want to appear in the browser: http://dummyserver/AQUARIUS/Publish/AquariusPublishRestService.svc/GetAuthToken?user=dummyname&encPwd=dummypassword I get a successful token like: 9fab1c9fee2a18bd6c2b889595d61131. Then I put the following into the web browser http://dummyserver/AQUARIUS/Publish/AquariusPublishRestService.svc/GetTimeSeriesData?dataId=QRiv.Derived-Working-DayMean@13235000%20S%20Fk%20Payette%20Riv%20at%20Lowman,%20ID&view=Public&queryFrom=2014-09-01%2000%3A00%3A00&queryTo=2014-09-02%2000%3A00%3A00&tok=9fab1c9fee2a18bd6c2b889595d61131 This gives me the data that I expect (a text file in the web browser). I turn this into Matlab code: usr = 'dummyname'; pwd = 'dummypassword'; url = 'http://dummyserver/AQUARIUS/Publish/AquariusPublishRestService.svc'; dat = '/GetTimeSeriesData?dataId=QRiv.Derived-Working-DayMean@13235000%20S%20Fk%20Payette%20Riv%20at%20Lowman,%20ID&view=Public&queryFrom=2014-09-01&queryTo=2014-09-02'; urltok = [ url, '/GetAuthToken?user=', usr, '&encPwd=', pwd ]; tok = webread( urltok ) tok = 8cef334c4b48f452634fdf3ee8208a4b % this works urldat = [ url, dat, '&tok=', tok ] data = webread([ urldat ]) % *this does not work* And I get the following response from the last webread() Error using readContentFromWebService (line 46) The server returned the message: "Bad Request" for URL, 'http://dummyserver/AQUARIUS/Publish/AquariusPublishRestService.svc/GetTimeSeriesData?dataId=QRiv.Derived-Working-DayMean%4013235000%20S%20Fk%20Payette%20Riv%20at%20Lowman%2C%20ID&view=Public&queryFrom=2014-09-01&queryTo=2014-09-02&tok=8cef334c4b48f452634fdf3ee8208a4b' (with HTTP response code 400). Error in webread (line 122) [varargout{1:nargout}] = readContentFromWebService(connection, options); Error in get_aquarius_test (line 51) data = webread([ urldat ]) From what I have read the 400 error code means that the request was malformed. However, I can't figure out what is malformed about the request. Can anyone tell me how to check what Matlab is actually sending to the server so I can try to determine how it is malformed? Or can you give me other advise on how to solve this. Other information: The Aquarius server is internal to my company and is on our own computers. I have tried different web browsers and they all seem to work fine, just Matlab has the problem. The Aquarius server stores hydrologic information and is from http://aquaticinformatics.com/.

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