0% found this document useful (0 votes)
51 views

Python in IOt

Python is well-suited for IoT applications due to its simplicity, large community support, and ability to work on various platforms. It can be used for backend software development in IoT. Some solutions for using Python in IoT include running it on Raspberry Pi boards, PyBoard microcontrollers using MicroPython, and ESP8266/ESP32 microcontrollers also using MicroPython. Python code examples are provided controlling GPIO pins on a Raspberry Pi and blinking an LED using MicroPython on an ESP32.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Python in IOt

Python is well-suited for IoT applications due to its simplicity, large community support, and ability to work on various platforms. It can be used for backend software development in IoT. Some solutions for using Python in IoT include running it on Raspberry Pi boards, PyBoard microcontrollers using MicroPython, and ESP8266/ESP32 microcontrollers also using MicroPython. Python code examples are provided controlling GPIO pins on a Raspberry Pi and blinking an LED using MicroPython on an ESP32.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Avinashilingam Institute For Home Science & Higher Education For Women

School of Engineering
Department Of Electronics & Communication Engineering

PYTHON IN IOT

Presented by
Rakshana M
20080UEL07
III BE ECE
CONTENTS
• Python in IoT
• Solutions for IoT in Python
• Python on Raspberry Pi
• Python on PyBoard
• ESP8266, ESP32 with Micropython
WHY PYTHON IN IoT?
• It is simple to learn, has clean syntax, and has a large online community supporting it.
• Used backend or software development in IOT
• Works on various platforms like Linux , MicroPython for Microcontrollers
• Accessible in the cloud.
• Python recognizes the IoT project from scratch or interact with actuators, sensors, and
accessories.
• It has a large number of libraries for all types of platforms and the speed it offers at which we
can develop the code.
• It is a great ally for developing device prototypes.

3
Solutions for
• Python on Raspberrypi
• Python on PyBoard IoT in Python
• ESP8266, ESP32 with
Micropython

4
Python on Raspberry Pi:
• The I/O ports on the expansion bar of the Raspberry Pi can be controlled.
• The board supports wireless communication (Bluetooth and WiFi) and Ethernet.
• Monitor can also be connected to the HDMI output, a specialized 3.2" 320x240 TFT LCD, or a
low energy consumption E-Ink 2.13" 250x122 display for Raspberry Pi.
• There are controllers available in a large variety .
• Controllers are ranging from the fast Raspberry Pi 4 Model B 8 GB to the smallest Raspberry Pi
Zero, all supporting the Python programming language.

5
Example:
Let us consider the following snippet of Python code where we have used the GPIO Zero library in order to
control the I/O ports.

# importing the required modules


from gpiozero import Button
from time import sleep
# creating an object of Button
the_button = Button(2)
# using the if-else statement
while True:
if the_button.is_pressed:
print("Button Pressed")
else:
print("Button Released")
sleep(1)

6
Python on PyBoard
• Another great solution for Python in IoT devices is the PyBoard with an STM32F405RG microcontroller.
• It is compact as well as a powerful electronics development board.
• It works on MicroPython.
Working:
• The PyBoard connects to the PC through USB,
• USB flash drive is provided to store the Python scripts and a serial Python prompt (a REPL) for instant
programming.
• It works with Windows, MacOS, and Linux.
• PyBoard executes MicroPython, which is a lightweight implementation of the standard CPython interpreter.

7
ESP8266, ESP32 with Micropython:
MicroPython:
• It is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the
Python standard library and is optimized to run on microcontrollers and in constrained environments.
• The MicroPython pyboard is a compact electronic circuit board that runs MicroPython on the bare metal, giving a
low-level Python operating system that can be used to control all kinds of electronic projects.
MicroPython features:
• An interactive prompt
• Arbitrary precision integers
• Closures
• List comprehension
• Generators
• Exception handling
• Controls I2C, UART, ADC, DAC, and SPI.
• 256k of code space and 16k of ram.
• Dimensions: 33mm x 43mm
• Weight 6 grams.
8
Installing Micropython:

• Download the MicroPython firmware from website.


• Install the software using esptool.
• Installing esptool:
• Install the python on system.
• Use the pip installer in the command line to install the esptool module.
Note: Format the board before installing.

9
Developing & Working

• The IDEs can be used for developing with MircoPython.


• The complete procedure of development is carried out on a working computer, and is compiled
• It is saved in the memory of an ESP8266 or ESP32 microcontroller.

Advantages

• Cost effective
• Works effectively on Pyboard
• Easy to write

10
Example:

# importing the required modules


from machine import Pin
import time
# creating an object of Pin
ledPin = Pin(2, Pin.OUT)
# using some functions
while True:
ledPin.on()
time.sleep(1)
ledPin.off()
time.sleep(1)

11
Than
k
You Refence links:
https://www.javatpoint.com/internet-of-things-with-pytho
n

You might also like