How to read data in more than 2 fields in thingspeak?

Hi Team
I have this following URL and want to read data to it, i want to read 2 fields within the URL itself. How can i read 2 or 3 fields to it using below URL? Documentation does not have this including, only 1 fields per each request. Please assist, thanks.

6 Comments

Hi, you can read either a single field or all fields. There is no way to read 2 specific fields. You would have to read all fields, and just ignore any fields you do not need. Your channel seems to use Field1, Field2 and Field8, so reading all fields will actually read Fields 1, 2 and 8 which may be what you need?
Read the last entry for your fields 1, 2, and 8 :
Read the three last entries for these three fields:
https://api.thingspeak.com/channels/899906/feeds.json?result=3
Read only field 2:
Read the last field 2 entry
Note: Use "csv" instead of "json" in the above examples if you need csv output format.
I am not sure if this helps
HI
"Your channel seems to use Field1, Field2 and Field8, so reading all fields will actually read Fields 1, 2 and 8 which may be what you need? " That is correct mate, but i cant seem to get correct date range.eg. want my date range to start from 25 November to 28 November 2019. The URL seem to give me last order of date range as being 28-11-2019. But if i amend and use this URL, can able able achieve something what i am looking for,
Hi,
If we need all data from beginning of 25 November until end of 28 November, I would use:
The point here is that if you use "2019-11-28T00:00+02:00" as your End-date/time, you will only get data until end of 27 November. To include all of 28 November, use "2019-11-28T23:59+02:00" or even "2019-11-29T00:00+02:00". So:
Start=2019-11-25T00:00+02:00 is the beginning of 25 November
End=2019-11-28T00:00+02:00 is actually the end of 27 November
End=2019-11-28T23:59+02:00 is the end of 28 November (well, 1 minute before the end)
End=2019-11-29T00:00+02:00 is perhaps a better way of specifying end of 28 November.
This seems to work for me, but maybe I misunderstood your question :-)
Again, use csv instead of json in the URL.
Hi Mate
Well you make sense, with CSV file format i can able to see the trends of date ranges up until 28 November and next day my channel was not used, so the data was not used. I wonder why there are some restrictions to way we can see or read data of more than 2 fields within its URL.
The suggested URL does not restrict the number of fields you can read (up to 8), in fact it reads all of the fields that you have data in. If you wanted to discard all of the empty fields, or just select a few of the fields, you could read the data in a MATLAB analysis and process the data there. You could reven write the output to another channel.
I suggest using thingSpeakRead with 'outputformat','timetable'. then you can select the columns from the table that youa re interested in. If you use a MATLAB visualizations script, you can also plot the selected data.
Chris, that elaboration maybe relevant to other issue i may likely to have. My issue was to read 2 fields from one specific URL using Rest Client only, but it appears i can read up to 8, as well one per field selected. To me this is a problem, especially if we are to read data from our channel using REST client. At this point,i dont need Visualization to do the output because its out of scope to my business rules on thingspeak.

Sign in to comment.

 Accepted Answer

Your RESTClient can read all 8 fields using the documented API and the lines of code in your application subsequent to the RESTClient code can choose the fields you want.
Alternatively, you can use the API to read each individual field using a separate RESTClient call.

More Answers (0)

Communities

More Answers in the  ThingSpeak Community

Categories

Products

Tags

Asked:

on 2 Dec 2019

Answered:

on 6 Dec 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!