1:05 pm

July 12, 2018

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
2:50 pm


Moderators
March 7, 2017

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
8:23 am

November 24, 2020

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.
Most Users Ever Online: 166
Currently Online:
38 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:
huldacormier, bogart, estebanmateo93, mikewrite, onlinebusiness, winzy99Moderators: cstapels: 460
Administrators: Hans: 405, lee: 457