How to have multiple field data in one graph ? | ThingSpeak Apps | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

8   +   2   =  

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
How to have multiple field data in one graph ?
No permission to create posts
November 16, 2018
10:45 am
Avatar
seaurchin
New Member
Members
Forum Posts: 4
Member Since:
November 16, 2018
sp_UserOfflineSmall Offline

I have separate field for temperature and humidity so separate graph shows up, what I want is to show line graph of both temperature vs humidity in the same graph. Is it possible?

November 16, 2018
5:12 pm
Avatar
piajola

Gold
Members
Forum Posts: 113
Member Since:
October 12, 2015
sp_UserOfflineSmall Offline

Hi seaurchin,

In Apps > MATLAB Visualizations create a NEW blank visualization (empty edit window)
Copy/paste blindly the code below, run it, read the docs to make your own magic 🙂
This is enough to help you start

- - - - - - - - - - - - start copy/paste - - - - - - - - - - - -
% Read temperature, humidity data from a ThingSpeak channel
% and visualize the data in a single plot using the MATLAB
% THINGSPEAKPLOT function.

% Channel ID to read data from
readChannelID = 00000; % YOUR CHANNEL NUMBER

fieldID1 = 1; % YOUR FIELD NUMBER ie 1 to 8
fieldID2 = 2; % my case 1 Temp 2 Humid

% Data wanted. Learn more about the THINGSPEAKREAD function in docs (easy :))

[data1,time1] = thingSpeakRead(readChannelID,'Field',fieldID1,'NumDays',1);
[data2,time2] = thingSpeakRead(readChannelID,'Field',fieldID2,'NumDays',1);

% Here data1 & data2 take temperature and humidity, time1 & time2 take the day & hour you sent the data to ThingSpeak.
% 'NumDays',1 mean last day (2 for last 2 days, etc.) ... so you have the data to plot

% Learn more about the THINGSPEAKPLOT function in docs (they do not bite I assure you)
% thingSpeakPlot(time, [ humidityData,temperatureData], 'legend',{'H %', 'T *C'});

thingSpeakPlotYY( time2, data2,time1, data1,...
'YGrid1','on','YLabel1','% H.R.',...
'YLabel2','*C','XLabel','Fecha y hora',...
'Title','Tempix y Humix ultimas 24 horas');

% Here you made the plot, that is all. Pairs of ' ' comma separated to say titles, labels, etc.
% 3 dots are saying: this is to make more readable ONE line ( the function is ONE line)
%Pay a lot of attention to UPPER/lower case, spaces, punctuation marks, etc.
- - - - - - - - - - - - stop copy/paste - - - - - - - - - - - -

This is PLOT from ThingSpeak, there is a plot from Mathworks/Matlab
Any trouble, questions ...
write here again
I hope this is of some help 🙂

November 17, 2018
2:37 am
Avatar
seaurchin
New Member
Members
Forum Posts: 4
Member Since:
November 16, 2018
sp_UserOfflineSmall Offline

I got rid of the comments while pasting for sake of tidiness..

I am getting the below error when I try to save and run:

Error using thingSpeakPlotYY (line 18)
Expected input to be nonempty.

Error in Custom (no starter code) 2 (line 9)
thingSpeakPlotYY( time2, data2,time1, data1, 'YGrid1','on','YLabel1','% H.R.', 'YLabel2','*C','XLabel','Fecha y hora','Title','Tempix y Humix ultimas 24 horas');

and when I click line 18 link I get below error :

Error using mlvisualization__user_id_110221_1542440103 (line 1)
Unable to run the 'mlvisualization__user_id_110221_1542440103' function because it calls the 'opentoline' function, which is not supported for this product offering.

November 17, 2018
11:02 am
Avatar
seaurchin
New Member
Members
Forum Posts: 4
Member Since:
November 16, 2018
sp_UserOfflineSmall Offline

I got it working but I dont see the update happening in realtime.

November 17, 2018
1:28 pm
Avatar
piajola

Gold
Members
Forum Posts: 113
Member Since:
October 12, 2015
sp_UserOfflineSmall Offline

It seems that we are awake at different times (and the visit to the forum)
Yes, Visualizations are not "live" (F5 press needed)

I did not know you wanted a real-time graph ...

In my TS dashboard for a "live" Temp-Hum graph I have a simple Apps>Plugins with the classic
-HTML
-CSS
-JavaScript

where you set the refresh rate in case you will be interested ...

November 18, 2018
12:01 am
Avatar
seaurchin
New Member
Members
Forum Posts: 4
Member Since:
November 16, 2018
sp_UserOfflineSmall Offline

piajola said

It seems that we are awake at different times (and the visit to the forum)
Yes, Visualizations are not "live" (F5 press needed)

I did not know you wanted a real-time graph ...

In my TS dashboard for a "live" Temp-Hum graph I have a simple Apps>Plugins with the classic
-HTML
-CSS
-JavaScript

where you set the refresh rate in case you will be interested ...  

yea, I am in Beijing.
I realised the visualisation added to Thingspeak for embedding uses iframe so I can add refresh to it, or I can completely not use matlab visualisation and use google chart api which is quite easy to do..

November 18, 2018
11:03 pm
Avatar
piajola

Gold
Members
Forum Posts: 113
Member Since:
October 12, 2015
sp_UserOfflineSmall Offline

Glad to hear you will solve your needs ...Smile

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

briskpanda, Dejw0089, Yassine Ben Salah, anis, 43994554AKS, suda

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457