Performance trends and alerts with ThingSpeak IoT
-
Upload
anoush-najarian -
Category
Data & Analytics
-
view
326 -
download
7
Transcript of Performance trends and alerts with ThingSpeak IoT
![Page 1: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/1.jpg)
1© 2016 The MathWorks, Inc.
Trending Now! Performance Trends and Alerts with ThingSpeak IoT
By Anoush Najarian • MATLAB Performance Team • MathWorks Boston CMG • Social Media Chair at #CMGimPACt • CMG Board of Directors @anoushnajarian
![Page 2: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/2.jpg)
2
Agenda
The Internet of Things (IoT) ThingSpeak A few of our favorite IoT applications Performance Trends and Alerts on ThingSpeak
![Page 3: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/3.jpg)
3
The Internet of Things is…
The internet of things (IoT) is the internetworking of physical devices, vehicles (also referred to as "connected devices" and "smart devices"), buildings and other items—embedded with electronics, software, sensors, actuators, and network connectivity that enable these objects to collect and exchange data.
https://en.wikipedia.org/wiki/Internet_of_things
![Page 4: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/4.jpg)
4
Things…
Typical “thing”– A sensor with connectivity– An actuator with connectivity
They are constrained– Processing– Memory– Protocols– Clock– Power
They run code over and over – sometimes they sleep wake up and run code, and go back to sleep
There are lots of them
![Page 5: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/5.jpg)
5
What is the Internet of Things?
Edge Nodes Exploratory Analysis
Analytic IoT PlatformDeploy analyticsto aggregator
Deploy algorithms to nodes/devices
![Page 6: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/6.jpg)
6
Agenda
The Internet of Things (IoT) ThingSpeak A few of our favorite IoT applications Performance Trends and Alerts on ThingSpeak
![Page 7: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/7.jpg)
7
What is ThingSpeak?
Analytic IoT platform– Collect data from sensors, “things”– Visualize data instantly– Has more than 60,000 users
Analyze data– MATLAB integration allows users to run
scheduled code on data coming into ThingSpeak
Act on data– E.g. send a tweet when the temperature in
your backyard reaches 32 degrees
![Page 8: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/8.jpg)
8
Who is ThingSpeak for?
Makers
Academics
Engineers and scientists
https://thingspeak.com/
![Page 9: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/9.jpg)
9
ThingSpeak: Collecting Data using Channels
For any new data, first login and create a channel in ThingSpeak
Channels have read and write API keys and can be public or private
A channel is made up of 8 fields and can store 8 streams of data (Temp, Humidity, etc.)
Channels can be updated at a maximum rate of once every 15 seconds
ThingSpeak Weather Channel
![Page 10: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/10.jpg)
10
Agenda
The Internet of Things (IoT) ThingSpeak A few of our favorite IoT applications Performance Trends and Alerts on ThingSpeak
![Page 11: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/11.jpg)
11
Objectives Measure, explore, discover weather patterns Provide niche weather serviceSolution Arduino station with weather sensors Cloud-based aggregation and analysis Full example available at
makerzone.mathworks.com
Example 1: Monitoring Weather
![Page 12: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/12.jpg)
12
Fun with Arduino!
Arduino Serial Monitor records the data from the temperature sensor, the pressure sensor, and the humitidity sensor, as transmitted to ThingSpeak!
Placing ice on the Arduino temperature sensor to cool it off!
![Page 13: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/13.jpg)
13
Fun with Raspberry Pi
Building a circuit with a temperature sensor in this week's
Posting the temperature readings from the sensor to ThingSpeak using Twitter.
![Page 14: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/14.jpg)
14
Objectives Measure, explore, discover traffic patterns Provide live local traffic information serviceSolution RaspberryPi + webcam Automated deployment of vision
algorithms on embedded sensor Full example available at
makerzone.mathworks.com
Example 2: Monitoring Traffic
![Page 15: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/15.jpg)
15
Smart Agriculture
Vineyards Green Houses Golf Courses Weather Stations – drought studies, radiation analysis Compost – Fungus prevention
![Page 16: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/16.jpg)
16
Agenda
The Internet of Things (IoT) ThingSpeak A few of our favorite IoT applications Performance Trends and Alerts on ThingSpeak
![Page 17: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/17.jpg)
17
Case Study: Performance Optimization of MATLAB Code
A customer ran into slow performance issues with her code in MATLAB. She saw such slow performance in that she decided to recode her algorithm in another language. We wanted to show her some simple techniques in MATLAB that could bring her code down to a more reasonable running time.
![Page 18: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/18.jpg)
18
What is the problem the user was trying to solve?
The code generates locations on a 2D grid with dimensions nx1 by nx2
The code iterates through all possible combinations of these initial and final positions
![Page 19: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/19.jpg)
19
The core of the code
![Page 20: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/20.jpg)
20
Measure performance of the original code
![Page 21: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/21.jpg)
21
Set up ThingSpeak channel
![Page 22: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/22.jpg)
22
Post performance data to our ThingSpeak channel
![Page 23: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/23.jpg)
23
Focusing in on the Performance ImprovementsFebruary 1 – baseline at 23.8s If we hover over the data points in the trend plots, or zoom in, we will spot the key
optimizations that helped performance of Sarah's code. Initial Code measured at around 23.8s:
![Page 24: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/24.jpg)
24
Performance Optimizations We Used
Preallocation Vectorization Elimination of repeated calculations
![Page 25: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/25.jpg)
25
Optimization #1: Preallocation
Listen to Code Analyzer!
![Page 26: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/26.jpg)
26
Focusing in on the Performance ImprovementsOptimization #1: February 20 – 22.3s
On February 20, we switched to Code with Preallocation, speeding up to around 22.3s, or by 6%:
![Page 27: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/27.jpg)
27
Optimization #2Vectorize the inner two loops
![Page 28: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/28.jpg)
28
Focusing in on the Performance ImprovementsOptimization #2: May 20 - down to 0.2s! On May 2, we implemented the optimization to Vectorize the Inner Two loops; this sped up
the code 100+-fold, to 0.2s.
![Page 29: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/29.jpg)
29
Optimization #3Vectorize the inner three loops
![Page 30: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/30.jpg)
30
Focusing in on the Performance ImprovementsOptimization #3: June 9 – dipped down to 0.06s! Finally, on June 9, we implemented Vectorize the Inner Three Loops, and the code sped
up to 0.06s, or by 67%.
![Page 31: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/31.jpg)
31
Final Optimization, #4: Eliminate redundant work
![Page 32: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/32.jpg)
32
In all, our trends capture pretty awesome 400+-fold performance improvement in the past few months!
The result: 400x as fast overall!
![Page 33: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/33.jpg)
33
What’s Next?
Use Analysis and Visualization tools on ThingSpeak for more advanced data analysis like displaying error bars, normalizing performance across a suite of tests
Set up email alerts in response to changes in performance Use machine learning for anomaly detection and to generate smart alerts
![Page 34: Performance trends and alerts with ThingSpeak IoT](https://reader034.fdocuments.net/reader034/viewer/2022042707/587854d71a28ab68198b707b/html5/thumbnails/34.jpg)
34
Thank you!
Many thanks to the ThingSpeak team for help with these slides and for creating and growing ThingSpeak!
A big thank you to Andy Campbell for helping me publish a MATLAB Central blog post on this
@[email protected]/in/anoushnajarian