iot data explorer for thingspeak and matlab video -凯发k8网页登录
this video will demonstrate how to explore thingspeak data using a custom-built matlab app, and then go into more detail on how the app was built using app designer.
thingspeak is an iot analytics platform service that allows you to aggregate, visualize, and analyze live data streams in the cloud. you can send data to thingspeak from your devices, create instant visualization of live data, and send alerts.
thingspeak channel views provide a snapshot of your streaming data. this traffic monitor channel is observing live traffic data for east- and west-bound traffic on the main road outside mathworks headquarters.
you can use matlab to create custom visualizations for your data, such as this week-over-week comparison, or the 48-hour summary. however, exploratory data analysis can be somewhat tedious without graphical controls to quickly modify your data visualizations.
the iot data explorer for thingspeak provides an easy-to-use, graphical interface to explore data read in from thingspeak.
the app and its code are publicly available on file exchange and on the thingspeak github site, and we will use it to look at the effect of the recent quarantine on pollution and traffic levels around mathworks headquarters.
after it is installed, this matlab app can be opened from the matlab app gallery. we’ll look at some features specific to this app, and afterwards, demonstrate how you can make a similar app on your own.
this channel shows measurements from an air quality monitor made by purpleair that is installed in one of the parking garages at mathworks headquarters. as more people have started working from home, fewer people are driving to work and using the garage, so we should expect to see an improvement in air quality.
first, as a sort of control, let’s compare air quality from two dates during quarantine. we’ll look at april 28 and compare it with one week before. fill in the channel id and set the date here, then specify [duration] the width of time, which goes forward from midnight of the indicated date. to compare it with one week prior, we set this field [compare length] to one week.
even though both dates occurred during quarantine, we see a significant difference in air quality – blue for the indicated date, orange for the week before. perhaps temperature changes throughout the day affect the sensor readings. field 6 of our channel contains this data, so we can check it, literally. a cursory glance of the two visualizations suggests that there could be an effect, but it’s not immediately clear.
even though both dates occurred during quarantine, we see a significant difference in air quality – blue for the indicated date, orange for the week before. perhaps temperature changes throughout the day affect the sensor readings. field 6 of our channel contains this data, so we can check it, literally. a cursory glance of the two visualizations suggests that there could be an effect, but it’s not immediately clear.
now let’s compare data from the current date to pre-quarantine times. we’ll compare this data with data from 7 weeks prior, when there was no quarantine. as we might expect, the air quality is worse, as indicated by the higher numbers. however, the temperature was also much higher.
let’s see if the trend continues over several days. since we can get up to 8000 data points with each read, we can visualize nearly 3 consecutive days’ worth of data. we see similar air quality levels at these times, despite quarantine vs not quarantine, and note that both date ranges do not contain weekends. since we also see temperature become similar around those times, this seems to indicate that temperature might affect air quality more than the number of cars utilizing the garage.
[“note that if the raw data across your time range is very cluttered, this app lets you quickly apply the matlab retime function to see things like hourly averages instead.” – to replace all red text.]
hopefully you’ve seen how interactive graphical tools make it much easier to perform exploratory data analysis. let’s talk about how you can make your own iot data explorer in matlab.
as mentioned before, the app you’re seeing in this video is available from file exchange and the thingspeak github site, and you are highly encouraged to download it and leverage it as a starting point. matlab app designer enables you to create your own apps from scratch, or edit an existing one.
simply type “appdesigner” in the matlab command line.
for context, the thingspeak explorer app is a 2-panel app with reflow. let’s find the app and open it in app designer. while you can certainly make an app that automatically updates visualizations every time one of these inputs are changed, this app keeps things simple by allowing you to set up parameters at your own pace, then use the update button when you’re ready.
here on the left, you can see some of the controls used to provide input, a date picker, dropdowns, and switches to select the time. [while adding another checkbox:] simply drag-and-drop controls onto the interface, and click on them to edit and rename.
right-click on any element to create a callback. these callbacks activate whenever the element is triggered in some relevant manner. one great use for callbacks is input validation: communicating to the user on things like, if a field requires an integer, or if a date needs to set in the past relative to another.
this iot explorer app keeps things simple by doing all input validation on the callback for this update button, which is also where the main action happens. let’s take a look at the callback function.
there are three main parts of this function. first, we get all the inputs from the ui, and perform input validation. next, we use that input to gather data from thingspeak – first from the selected date, then from the date in the past. and finally, we plot the data visualizations.
let’s look at the key functionality: reading data from thingspeak. you can navigate to the function definition by right-clicking on the function name and clicking “open” while it looks like there’s a lot of code here, most of it is just to make the app a little more robust, because reading data from thingspeak is entirely contained in this one line of code.
thingspeakread needs to know a few pieces of information, particularly the channel id. then, you can specify additional data using name-value pairs, such as daterange with a start and end date, selected fields as indicated by which checkboxes were checked, an api key if the channel was private, and the output format for the results. matlab timetables are a great output format as they make it easy to plot and retime data.
this next section helps our app run more smoothly by ensuring we actually received data from thingspeakread, and it notifies the user if something went wrong.
the final section performs retiming, if that option was selected. that concludes the process of getting data for the present and past dates, and the update callback function will proceed to the next step.
hope you’ve been able to see how easy it is to get data from thingspeak, and use matlab app designer to build and modify custom apps so that you and your colleagues can analyze and visualize data in an interactive manner. use the links below to find the entry on github, where you can download the app, try it out for yourself, and also leave comments and feedback.
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 mathworks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- (español)
- (english)
- (english)
欧洲
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
亚太
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)