Python For IoT CoE
Python For IoT CoE
Python For IoT CoE
Centre of Excellence
Dr. Akey Sungheetha, Associate Professor, Computer Science
and Engineering.
Python Programming
Language
TO TRY:
Using the --version switch will show you the version that’s installed.
Alternatively, you can use the -V switch:
Alternative
Command
Windows Command Prompt
C:\> python -V
Python 3.8.4 (3.12.4 is the one which I have installed)
TO TRY: Check which version of Install or update Python Use Python on mobile Use Python on the Web Python 3 Installation & Se
Python, if any, is installed on Windows, macOS, devices like phones or with online interpreters tup Guide – Real Python
on your machine and Linux tablets
Online compilers
TO TRY:
• PY4E - Python for Everybody IDE from
coursera may be used.
• print("Hello World")
Variables
TO TRY:
• This Python code creates a variable message
and assigns it the value “Hello, World!“. Then,
the print() function is used to print the value of
the message variable to the console.
TO TRY:
• An expression is a combination of operators and operands
that is interpreted to produce some other value.
• In any programming language, an expression is evaluated
as per the precedence of its operators.
• So that if there is more than one operator in an expression,
their precedence decides which operation will be
performed first.
• x = 15 + 1.3
• print(x)
Python Conditions and
If statements
TO TRY:
• a = 33
• b = 200
• if b > a:
• print("b is greater than a")
• TO TRY:
• def my_function():
• print("Hello from a function")
Calling a Function
To call a function, use the function
name followed by parenthesis:
TO TRY:
def my_function():
my_function()
Loops in Python
TO TRY:
• count = 0
• while (count < 3):
• count = count + 1
• print("Hello friends")
While loop and For
Loop in Python
• Output:
• 0
• 1
• 2
• 3
Certification courses
Assignment
1. Diploma in Python Programming Provided by Alison1
• Email: [email protected]
Example 1
• Raspberry Pi Model 3
• Intel Edison
• Arduino
IOT SENSORS SIMULATORS USED IN PYTHON
PROGRAMMING INCLUDE:
MQ TELEMETRY TRANSPORT (MQTT) SENSOR
SIMULATOR
• MQTT protocol for the IoT in Python enables high-speed
data exchange with low payload communication between
the devices. User-friendly requests of MQTT are made
directly in Python. Data is collected in real-time and easily
analyzed in mathematical computation libraries like
matplotlib. The diagram below shows the steps used for
the data flow:
https://www.topcoder.com/thrive/articles/python-in-iot
-internet-of-things
•
AZURE IOT SDK IN
PYTHON
• Azure IoT hub offers a variety of features for IoT SDK usage which
provides the ability to connect devices and services. The IoT SDK is
supported by the MQTT protocol which facilitates the data exchange
processes. The device requirements to be used along with Python include:
• Azure-iot-device library
• The IoT hub SDK helps with the following aspects: access, processing,
and analysis of data for machine learning applications.
• The Azure IoT hub helps collect messages and feedback data collected by
IoT devices and is displayed in the code below:
COUNTLY IOT
RASPBERRY PI SDK