Want to learn more? Take the full course at [ Ссылка ] at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
Hello,
and welcome to this course on Analyzing IoT Data in Python. My name is Matthias Voppichler, and I'll be helping you learn the skills necessary to gather and analyze IoT data.
In this course, you will learn how to collect and analyze IoT Data. We'll first look at a public REST endpoint, which will provide environmental data, and we will connect to datastreams using MQTT, a simple message protocol.
Then, we will visualize IoT Data using Matplotlib, combine multiple datasets, detect patterns and draw conclusions from the Datasets.
Finally, we will implement a simple Machine Learning algorithm on top of a datastream to alert when certain event categories happen.
You may ask yourself, What is IoT?
IoT, or Internet of Things, defines a network of connected devices interacting with their environment. IoT devices extend beyond standard devices such as PC's, Laptops or Smartphones and often replace "dumb" counterparts which have been used for decades, like analog Temperature sensors.
IoT Devices measure and collect data about their environment and some also interact by performing certain predefined actions, for example turning the heat up or down.
IoT Devices are everywhere, collecting data, also about us.
Some examples include smart locks, Connected thermostats and Temperature sensors. In industrial settings, this also includes connected machines, robots, and package tracking devices, and many more.
Common formats for IoT data include json, plain text, binary data, and XML. Industrial machines often implement proprietary protocols.
When talking about IoT data, the topic quickly delves into Big Data since IoT Devices constantly produce data, which quickly sums up to large sizes. We will not cover Big Data in this Course.
In order to collect data from IoT devices, multiple approaches can and will be used.
Often, IoT data is produced in the form of Datastreams. More about this later in the course. Many times, we have a Raspberry Pi or similar devices set up to gather data.
We will also encounter API endpoints. These endpoints are often exposed directly by an IoT device, or by a provider managing the device, for example, if it's in a public space.
Let's start simple by connecting to an API endpoint.
We start by importing Requests, a module to handle http communications.
We then use requests.get to get the data from a rest api. The parameter "count=3" specifies that we would like the last 3 entries from a device.
Many API's require multiple parameters like a start or endtime - but consuming API's can fill a course on its own.
The result "r" is a requests object.
Requests provides a method json() to convert the json-encoded response content to a Python object, so we print the result accordingly.
After printing the data, we can see that the data consists of 2 columns - timestamp and value.
We can convert this to a Dataframe by passing it to pandas DataFrame constructor.
We can simplify this process by using Pandas read_json() method, which handles both downloading and parsing the data for us.
We pass the url to pd.read_json(), and pandas will make the request and parse the result into a dataframe for us.
Since the column is called "timestamp", pandas will conveniently parse the column to a datetime datatype. This automatism works for several typical time column names, which are listed in the pandas documentation.
And now, let's Practice. Enjoy.
#PythonTutorial #Python #DataCamp #IoT #data
Ещё видео!