My power meter at my house reports its power every few minutes. I capture that data and send it to ThingSpeak. The value reported is the total kilowatt-hour (kWh). I would love to see the maximum value over an hour versus randomly reported values over an hour. With the release of MATLAB R2016a, ThingSpeak users have access to a new suite of data analysis features. One of them is movmax – with movmax, I now can look at my ThingSpeak data over time and figure a moving window of maximum values. This new feature is highly customizable for your application, but I will show you how I use it.
My data over an hour looks like this: 803, 919, 724, 1349, 1500, 602, 549, 899, 1678, 1577
Using movmax, I can have a sliding window ran over my data to pull out a maximum value from the window and use it for visualization or further analysis.
The MATLAB code to process my power data is really straightforward.
readChannelID = 97871; fieldID1 = 1; readAPIKey = '7MOXB8G515OAD94Q'; %% Read Data %% [data, time] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 10, 'ReadKey', readAPIKey); %% Process Data %% data_max = movmax(data, 4) %% Visualize Data %% plot(time, data_max);
Now, using the MATLAB Visualizations app on ThingSpeak, I can visualize the data. Here’s the before and after.
You can use movmax in the MATLAB Analysis or MATLAB Visualizations apps on ThingSpeak. Sign up or sign into ThingSpeak, select Apps, and click “MATLAB Visualizations”. Create a new one with the blank template and use my MATLAB code. I will leave my channel of data up for you to try out. You can use channel number 97871 and my read API key 7MOXB8G515OAD94Q. The power data is stored in field1.
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.