Eliminating duplicate values before plotting | ThingSpeak Projects | Forum

The ThingSpeak community site has been upgraded to a new site. This site is currently in read-only mode. You can ask questions or post and read discussions on the new site.

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
New Member
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.

September 23, 2019
2:50 pm

Forum Posts: 885
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.

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

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


November 24, 2020
8:23 am
New Member
Forum Posts: 1
Member Since:
November 24, 2020
sp_UserOfflineSmall Offline

If I want to keep one value of repeated values without sorting, what can I do? I want to keep point with the lowest time, so I have to delete some rows; perhaps https://domyessay.onl will help.

Forum Timezone: America/New_York

Most Users Ever Online: 166

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

kusmumichael, petersmith99, Rambant, blakeharriss09, optisol, Niyonzima Fils

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457