Eliminating duplicate values before plotting | ThingSpeak Projects | 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
Eliminating duplicate values before plotting
No permission to create posts
August 22, 2019
1:05 pm
Avatar
maximelanoelle
New Member
Members
Forum Posts: 4
Member Since:
July 12, 2018
sp_UserOfflineSmall Offline

Hello all,
I am collecting sensor data that I am plotting to Thingspeak.
A particular sensor gives me 0 or 1 depending on the status of an electrical relay.
I am recording the time when the relay turns ON (value 1). Then I want confirmation that the relay turned OFF (value 0). This is expected to happen twice a day, every day.
Although I am keen to record / display the data to ensure the relay goes ON and OFF when it needs to, I am trying to minimise the data plotted as I have more than one sensor, and the website where I display the plots struggles due to the number of points.
I am aware of the min / max function that allows to eliminate "bad" data, but I need to see both 0 and 1 in my case, so this isn't an option unfortunately. I also cannot use the average function since I wouldn't know if I could have missed a "relay=ON" event.
Is there an easy way to only plot points that are different from one time iteration (t) to the next (t+1)? This would minimise significantly the number of points I want to display.
I am already using all the fields possible in my channel, so I don't think I can do a calculation in Matlab to then write onto a new field.
If removing duplicates is not an option, do you have any other suggestions?
Many thanks in advance.
Max

September 23, 2019
2:50 pm
Avatar
cstapels
Moderator
Members


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

Even if your fields are full, you can read data into a MATLAB visualization and plot it. Then you can add the visualization to the channel.

This is pseudo code, but hopefully will give you the idea.

importantData=[]
myData=thingSpeakRead (channel, options...);
for i=1:length(myData)-1 % loop through data
if (myData(i)~=myData(i+1))
importantData(end+1)=myData(i)
end
end
plot(importantData)

FYI, MATLAB Answers is now the preferred location for online help regarding ThingSpeak topics.

https://www.mathworks.com/matlabcentral/answers/?product_base_code%5B%5D=ThingSpeak&sort=asked+desc

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
20 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:

titan83, Svetoslav, abubakar, shindepavan551@gmail.com, fet61-fakohse, Mario Marquez

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457