Module 6
Python in IoT Development
Python Packages for IoT
• Over the past decade, the popularity of Python as a mainstream programming
language has exploded.
• Notable advantages of Python over other languages include, but are not limited
to;
It is a very simple language to learn and easy to implement and deploy,
so you don't need to spend a lot of time learning lots of formatting
standards and compiling options.
It is portable, expandable and embeddable, so, it is not system
dependent, and hence supports a lot of single board computers on the
market these days, irrespective of architecture and operating system.
Most importantly, it has a huge community which provides a lot of
support and libraries for the language.
Python Packages for IoT
MRAA
• It is a structure GPIO library supporting
python.
• The most attractive thing about this is
that there is just one library for every
individual device.
• So you don’t have to switch every time
when you shift to an Edison or a Pi.
• As it’s a high-end library reading from
and writing to pins is pretty easy.
• It also provides communication protocols
like I2C, UART, and SPI.
Python Packages for IoT
Sockets
• It is a package that allows networking over
Transmission Control Protocol (TCP)/
Internet Protocol (IP) via python.
• Both TCP/IP and User Datagram Protocol
(UDP) are transport layer protocols, which
means that they are ideal for
communication with the devices on the
same Wi-Fi connection.
• Can be used to build its own communication
protocol setting this package as the base.
Python Packages for IoT
• Mysqldb
• A database is a no-brainer when it’s about
most IoT applications.
• If something serves the sole purpose of
sending data to the internet, a database is a
must requirement, at least a small one that
stores all this information.
• And when database word pops up MySQL is
the most common solution which comes to
most developer’s minds.
• In this portion mysqldb is a very convenient
tool that executes commands within a python
script to read and write to a database.
Python Packages for IoT
• Numpy
• When you’ll get deeper into IoT arrays will become very common to
you.
• In python, arrays are replaced with lists. But this replacement just
doesn’t fit every scenario, and that’s where Numpy comes into place,
a package used for scientific computations via python
• The most prominent feature of this library is reading sensor data in
bulk and working on them using inbuilt functions.
Python Packages for IoT
• Matplotlib
• Being an IoT developer you have to deal with heavy data traffic every
second.
• Dealing with a large amount of information has now gotten into your
veins.
• Data visualization is the most fundamental thing an IoT or any Data
Scientist has to deal with.
• It looks pretty cool converting all those numbers into cool bending shapes.
• This library is a very useful tool to convert your local data into graphs and
shapes.
Python Packages for IoT
• Pandas
• Pandas is another very useful tool dedicated to data scientists.
• Being an alternative to MySQL this is very suited to deal with
databases and data handling.
• Being a newer version and being built on Numpy this library is much
more streamlined and handles direct operations on local datasets and
ability to handle heterogeneous and unordered data.
Python Packages for IoT
• OpenCV
• It is a very vast open-source library of machine learning and image
processing.
• It is a very useful tool making most of the future of programming into daily
life; it can process images, videos.
• When used with other libraries such as NumPy which is used for numerical
operations the number of features increases in your Arsenal, whatever
operations you can do on NumPy can be combined with OpenCV.
• It is the most successful image processing library out there as it contains
high-level variants for image processing making this process a much easier
task.
Python Packages for IoT
• TensorFlow
• Tensorflow is basically all about numerical computations as it’s built
on Numpy.
• It harvests a different mathematical representation called data slow
graphs where nodes are for mathematical operations and edges as
data arrays.
• This library is a very useful tool to work with a loT of non-linear
datasets.
Python Packages for IoT
• Paho-MQTT (Message Queuing Telemetry
Transport)
• This is a protocol that was specially built for the
Internet of Things!
• It mainly focuses on high-speed and low payload
communication between resource-providing
devices.
• It gives a very user-friendly version of basic
required protocols for use in embedded systems.
• MQTT requests don’t need any external setup;
they can be done directly into python itself.
• Very handy in a prototyping stage.