post multiple data for the same field? | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
post multiple data for the same field?
Avatar
ask
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
1
November 2, 2017 - 8:18 pm
sp_Permalink sp_Print

Hello All, Just have a quick question. Is it possible to post multiple data for the same field?

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOfflineSmall Offline
2
November 3, 2017 - 11:12 am
sp_Permalink sp_Print

Are you trying to write two different data types to the same field successively or simultaneously?  You can change the data types for each individual post, even for the same field.  You may have to be careful with the plotting or other processing you do with MATLAB code.

It is possible to put multiple data elements in a single field at the same timestamp with a single write, but its not recommended. You would have to parse the data later to separate them.

You would use something like https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=2.2andSecondData2.4&

 

There is room for up to 255 characters in a field.  Using two successive writes will give two separate entries, since the time stamp will change. But you can use the "created_at" parameter to  update your channel feed.  If you use the same date for created_at with two posts, you will get two separate entries at the same time.

https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=2.2&created_at=2017-11-3%2013:59:59

 

Can you describe what you are trying to do?  Perhaps there is a different way to achieve your goal.

Avatar
ask
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
3
November 4, 2017 - 4:02 pm
sp_Permalink sp_Print

I basically want to do 2 different things if Possible.

1. To get more details for a parameter without sending frequent updates. For example sampling a variable every 5 seconds and updating thingspeak field with 12 values every minute. It seems like that can be done per your suggestion above like below? Is the syntax correct?

https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=2.2andSecondData2.4andThirdData4.5...andTwelvthData6.3&

2. To draw more than one trace in the same field for comparison purposes. For example plotting temperature and humidity in the same graph. And for this the second update that uses 'created at' can be employed requiring as many updates as the plots needed per time instance. Correct?

Avatar
ask
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
4
November 6, 2017 - 5:41 pm
sp_Permalink sp_Print

cstapels said
Are you trying to write two different data types to the same field successively or simultaneously?  You can change the data types for each individual post, even for the same field.  You may have to be careful with the plotting or other processing you do with MATLAB code.

It is possible to put multiple data elements in a single field at the same timestamp with a single write, but its not recommended. You would have to parse the data later to separate them.

You would use something like https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=2.2andSecondData2.4&

 

There is room for up to 255 characters in a field.  Using two successive writes will give two separate entries, since the time stamp will change. But you can use the "created_at" parameter to  update your channel feed.  If you use the same date for created_at with two posts, you will get two separate entries at the same time.

https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=2.2&created_at=2017-11-3%2013:59:59

 

Can you describe what you are trying to do?  Perhaps there is a different way to achieve your goal.  

So I tried https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=2.2andSecondData2.4& and I am finding that only the first value is plotted on the chart. How can I retrieve the other values? Or are they lost permanently?

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOfflineSmall Offline
5
November 17, 2017 - 10:52 am
sp_Permalink sp_Print

The plots for each field will not be able to show multiple lines for the data concatenated as you described above.  If you put the data in multiple fields, or even across multiple channels, you can use a MATLAB visualization to read two series of data and plot it on the same chart, for example with thingSpeakPlotYY or plot(x1,y1,x2,y2);

You could also use a MATLAB visualization with the data in your fields the way you wrote it, if you do a bit of work on the data. 

Read the data to a variable combinedData=thingSpeakRead(...'OutputFormat','Timetable')  ;

Then operate on combined data to get the values back.  Use splitstr(variable,'and') to split the strings.  

for i=1:height(data)
outer=strsplit(combinedData.FieldLabel1{1},'and');
numbers(i,1)=str2num(outer{1});
numbers(i,2)=str2num(outer{2});
end

Now you can plot(1:height(data),numbers), and you should get two lines.

Its definitely more work than using two fields or two channels, but it is possible.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
16 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

winnieeq69

AutoCheernpen

Bostermet

engladNed

iivenul

olewaeayafaku

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee