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

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
post multiple data for the same field?
No permission to create posts
November 2, 2017
8:18 pm
Avatar
ask
New Member
Members
Forum Posts: 4
Member Since:
November 2, 2017
sp_UserOfflineSmall Offline

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

November 3, 2017
11:12 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 210
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

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.

November 4, 2017
4:02 pm
Avatar
ask
New Member
Members
Forum Posts: 4
Member Since:
November 2, 2017
sp_UserOfflineSmall Offline

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?

November 6, 2017
5:41 pm
Avatar
ask
New Member
Members
Forum Posts: 4
Member Since:
November 2, 2017
sp_UserOfflineSmall Offline

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?

November 17, 2017
10:52 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 210
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

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:
19 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

celinabw2, FitoSprayscroma, LunnonGor, lancevl16, bernicenk60, veronicadq18

Administrators: Hans: 387, lee: 457