SlideShare a Scribd company logo
Getting Started with Embedded Python
(MicroPython and CircuitPython)
@iAyanPahwa/iayanpahwa
About Me
Embedded Software
Engineer at Mentor
Graphics - A Siemens
Business
Part time blogger
Full time maker
Mentor Graphics is world
leader in Electronics Design
Automation(Tools Business).
I work for Automotive
Embedded Software Division,
which deals in providing
custom solutions, OS and
BSP for IVI and ADAS
systems.
Contact: https://iayanpahwa.github.io
People who are really
serious about software
should make their own
hardware
- Alan Kay
Motivation
-
@iAyanPahwa/iayanpahwa
Motivation
@iAyanPahwa/iayanpahwa
What is MicroPython
The MicroPython project is an open source
implementation of Python 3 that includes a small
subset of the Python standard libraries, and is
optimised to run on microcontrollers with constrained
environments like limited ROM, RAM and processing
power. It came about after a successful Kick-starter
campaign by Damien George.
@iAyanPahwa/iayanpahwa
Python 3
IoT
(Devices)
Microcontrollers
In a NutShell
@iAyanPahwa/iayanpahwa
Opportunities
@iAyanPahwa/iayanpahwa
@iAyanPahwa/iayanpahwa
~20MHz System Clock
~32Kb RAM
~16MB ROM
Single Core
Register Level Access
Microcontrollers
@iAyanPahwa/iayanpahwa
MicroPython
- A small stripped down version on Python3 which runs as firmware on microcontrollers,
exposes all the low level modules, acting as an operating system.
- It is packed full of advanced features such as an interactive prompt, arbitrary precision
integers, closures, list comprehension, generators, exception handling and more.
- Yet it is compact enough to fit and run within just 256k of code space and 16k of RAM.
- MicroPython aims to be as compatible with normal Python as possible to allow you to
transfer code with ease from the desktop to a microcontroller or embedded target.
- Python APIs for low level hardware modules- GPIOs, UART, PWM, ADC, i2c, SPI.
- Runs directly on bare-metal or under OS env or as emulator.
@iAyanPahwa/iayanpahwa
Python vs μPython vs Arduino
Refer: https://github.com/micropython/micropython/wiki
@iAyanPahwa/iayanpahwa
Boards Supported
@iAyanPahwa/iayanpahwa
The PyBoard
The ESP8266
160Kb RAM
802.11 b/g/n
4MB Flash
GPIO, ADC, I2c, SPI
@iAyanPahwa/iayanpahwa
Functions & Libraries Supported
@iAyanPahwa/iayanpahwa
Interaction
Serial REPL (115200 BAUD RATE)
WEB REPL, works over LAN
File System mounts on host
Tools to transfer source code(ex: AMPY)
Emulation on linux host
Unicorn web based emulator
@iAyanPahwa/iayanpahwa
Interaction: Serial
Loading uP on ESP8266 board
Install esptool - pip install esptool
Download uP firmware.bin from GitHub release pages for
your board.
Erase flash - esptool.py --port /path/to/ESP8266
erase_flash
Flash uP firmware - esptool.py --port /path/to/ESP8266 --
baud 460800 write_flash --flash_size=detect 0 firmware.bin
Connect Serial console - screen /dev/tty… 115200
@iAyanPahwa/iayanpahwa
Interaction: WebREPL
Setting up WebREPL
> import webrepl_setup
> Enter ‘E’ to enable it
> Enter and confirm password(defaults
micropythoN)
> Enter ‘y’ to reboot and save changes
@iAyanPahwa/iayanpahwa
Interaction: WebREPL
@iAyanPahwa/iayanpahwa
Interaction: Unicorn
https://micropython.org/unicorn
@iAyanPahwa/iayanpahwa
Interaction: Live
https://micropython.org/live
@iAyanPahwa/iayanpahwa
Interaction: Emulator
@iAyanPahwa/iayanpahwa
(DEMO)
HELLO WORLD OF ELECTRONICS
@iAyanPahwa/iayanpahwa
Interaction: Hello WORlD
// Classic way of Blinking LED
#include “Board_Defination_File.h”
int main(void)
{
while(1){
DDRB |= (1 << 7);
PORTB |= (1 << 7);
_delay_ms(1000);
PORTB &= ~(1 << 7);
_delay_ms(1000);
}
}
// Make Pin Output
// Send logic 1 to the pin
//Send logic 0 to the pin
@iAyanPahwa/iayanpahwa
Interaction: h3llO WORlD
> from machine import Pin
> from time import sleep
# Make Pin behave as output
> led = Pin(2, Pin.OUT)
> while True:
# Send digital logic 1 to the pin
> led.on()
> sleep(1)
# Send digital logic 0 to the pin
> led.off()
> sleep(1)
MicroPython Way
@iAyanPahwa/iayanpahwa
Interaction: Advance
File System on Flash to store:
WiFi credentials (SSID, PASSOWRD)
boot.py - POST operations
main.py - main executable
You can mount the fs over network, or
transfer files over webREPL or tools like
AMPY.
@iAyanPahwa/iayanpahwa
CircuitPython
https://github.com/adafruit/circuitpython
Adafruit fork of MicroPython maintained for
educational purpose around boards sell by
Adafruit industries.
Centred Around ATMEL SAMD21 and ESP8266 SoCs.
Various new modules added like capacitive touch
APIs, Sound outputs, USB HID etc.
Bluetooth Low energy support with newly
supported NRF SoC port.
DISCLAIMER: The stunts will be performed by experts
under expert supervision and no matter how many times
you test before, chances of live demo failures are
incalculable :P
SHOW TIME
@iAyanPahwa/iayanpahwa
DEMOS
@iAyanPahwa/iayanpahwa
Temperature and Humidity Measurement
> import dht, machine
> from time import sleep
# Make Pin behave as output
> d = dht.DHT11(machine.Pin(4))
> while True:
# Measure temp and humidity
> d.measure()
# Print Values
> d.temperature()
> d.humidity()
> sleep(2)
@iAyanPahwa/iayanpahwa
NeoPixel
* 1 wire to control multiple LEDs, color and
brightness.
* 8-bit format for Red, Green, Blue
* RRGGBB
* 0-ff or 0-255
NeoPixel
> import machine, neopixel
# Initialize GPIO and number of pixels
> np = neopixel.NeoPixel(machine.Pin(4), 8)
# Set a Pixel color in RGB format
> np[0] = (255, 0, 0)
>np.write()
@iAyanPahwa/iayanpahwa
Thank You
@iAyanPahwa
/iayanpahwa

More Related Content

What's hot (20)

Internet of things ppt
Internet of things ppt
Dania Purnama Sari
 
Bitcoin Keys, Addresses & Wallets
Bitcoin Keys, Addresses & Wallets
Christopher Allen
 
MQTT
MQTT
ESUG
 
The many faces of IoT (Internet of Things) in Healthcare
The many faces of IoT (Internet of Things) in Healthcare
Stocker Partnership
 
Understanding blockchain
Understanding blockchain
Priyab Satoshi
 
IoT
IoT
Ananth Kumar
 
JSNAPyとPyEZで作る次世代ネットワークオペレーションの可能性
JSNAPyとPyEZで作る次世代ネットワークオペレーションの可能性
Taiji Tsuchiya
 
IoT Wireless Technologies
IoT Wireless Technologies
NEXT INDUSTRIES SRL
 
Voice recognition
Voice recognition
East West University-Dhaka Bangladesh
 
Wearable computing
Wearable computing
kdore
 
IOT Unit-1 (Introduction to IOT) by Durgacharan
IOT Unit-1 (Introduction to IOT) by Durgacharan
Durgacharan Kondabathula
 
ESP8266 and IOT
ESP8266 and IOT
dega1999
 
BLOCKCHAIN
BLOCKCHAIN
Nitish sharma
 
Blockchain basics
Blockchain basics
Romit Bose
 
Home automation system
Home automation system
RaadSabah
 
ネットワーク機器のAPIあれこれ入門 (NetOpsCoding#2)
ネットワーク機器のAPIあれこれ入門 (NetOpsCoding#2)
Kentaro Ebisawa
 
Designing for IoT and Cyber-Physical System
Designing for IoT and Cyber-Physical System
Maurizio Caporali
 
Internet of Things(IoT) - Introduction and Research Areas for Thesis
Internet of Things(IoT) - Introduction and Research Areas for Thesis
WriteMyThesis
 
IoT Standards & Ecosystem
IoT Standards & Ecosystem
Harish Vadada
 
Iot how it works
Iot how it works
S SIVARAMAKRISHNAN
 
Bitcoin Keys, Addresses & Wallets
Bitcoin Keys, Addresses & Wallets
Christopher Allen
 
MQTT
MQTT
ESUG
 
The many faces of IoT (Internet of Things) in Healthcare
The many faces of IoT (Internet of Things) in Healthcare
Stocker Partnership
 
Understanding blockchain
Understanding blockchain
Priyab Satoshi
 
JSNAPyとPyEZで作る次世代ネットワークオペレーションの可能性
JSNAPyとPyEZで作る次世代ネットワークオペレーションの可能性
Taiji Tsuchiya
 
Wearable computing
Wearable computing
kdore
 
IOT Unit-1 (Introduction to IOT) by Durgacharan
IOT Unit-1 (Introduction to IOT) by Durgacharan
Durgacharan Kondabathula
 
ESP8266 and IOT
ESP8266 and IOT
dega1999
 
Blockchain basics
Blockchain basics
Romit Bose
 
Home automation system
Home automation system
RaadSabah
 
ネットワーク機器のAPIあれこれ入門 (NetOpsCoding#2)
ネットワーク機器のAPIあれこれ入門 (NetOpsCoding#2)
Kentaro Ebisawa
 
Designing for IoT and Cyber-Physical System
Designing for IoT and Cyber-Physical System
Maurizio Caporali
 
Internet of Things(IoT) - Introduction and Research Areas for Thesis
Internet of Things(IoT) - Introduction and Research Areas for Thesis
WriteMyThesis
 
IoT Standards & Ecosystem
IoT Standards & Ecosystem
Harish Vadada
 

Viewers also liked (20)

PyCon_India_2017_MicroPython_Ayan
PyCon_India_2017_MicroPython_Ayan
Ayan Pahwa
 
Raspberry home server
Raspberry home server
Massimiliano Perrone
 
HPC DAY 2017 | Prometheus - energy efficient supercomputing
HPC DAY 2017 | Prometheus - energy efficient supercomputing
HPC DAY
 
LinuxKit and OpenOverlay
LinuxKit and OpenOverlay
Moby Project
 
Java on the GPU: Where are we now?
Java on the GPU: Where are we now?
Dmitry Alexandrov
 
HPC DAY 2017 | HPE Storage and Data Management for Big Data
HPC DAY 2017 | HPE Storage and Data Management for Big Data
HPC DAY
 
HPC DAY 2017 | NVIDIA Volta Architecture. Performance. Efficiency. Availability
HPC DAY 2017 | NVIDIA Volta Architecture. Performance. Efficiency. Availability
HPC DAY
 
HPC DAY 2017 | HPE Strategy And Portfolio for AI, BigData and HPC
HPC DAY 2017 | HPE Strategy And Portfolio for AI, BigData and HPC
HPC DAY
 
Database Security Threats - MariaDB Security Best Practices
Database Security Threats - MariaDB Security Best Practices
MariaDB plc
 
HPC DAY 2017 | Accelerating tomorrow's HPC and AI workflows with Intel Archit...
HPC DAY 2017 | Accelerating tomorrow's HPC and AI workflows with Intel Archit...
HPC DAY
 
Model Simulation, Graphical Animation, and Omniscient Debugging with EcoreToo...
Model Simulation, Graphical Animation, and Omniscient Debugging with EcoreToo...
Benoit Combemale
 
Libnetwork updates
Libnetwork updates
Moby Project
 
HPC DAY 2017 | Altair's PBS Pro: Your Gateway to HPC Computing
HPC DAY 2017 | Altair's PBS Pro: Your Gateway to HPC Computing
HPC DAY
 
Latency tracing in distributed Java applications
Latency tracing in distributed Java applications
Constantine Slisenka
 
GPU databases - How to use them and what the future holds
GPU databases - How to use them and what the future holds
Arnon Shimoni
 
Design patterns in Java - Monitis 2017
Design patterns in Java - Monitis 2017
Arsen Gasparyan
 
An Introduction to OMNeT++ 5.1
An Introduction to OMNeT++ 5.1
Alpen-Adria-Universität
 
Drive into calico architecture
Drive into calico architecture
Anirban Sen Chowdhary
 
Vertx
Vertx
NexThoughts Technologies
 
세션1. block chain as a platform
세션1. block chain as a platform
Jay JH Park
 
PyCon_India_2017_MicroPython_Ayan
PyCon_India_2017_MicroPython_Ayan
Ayan Pahwa
 
HPC DAY 2017 | Prometheus - energy efficient supercomputing
HPC DAY 2017 | Prometheus - energy efficient supercomputing
HPC DAY
 
LinuxKit and OpenOverlay
LinuxKit and OpenOverlay
Moby Project
 
Java on the GPU: Where are we now?
Java on the GPU: Where are we now?
Dmitry Alexandrov
 
HPC DAY 2017 | HPE Storage and Data Management for Big Data
HPC DAY 2017 | HPE Storage and Data Management for Big Data
HPC DAY
 
HPC DAY 2017 | NVIDIA Volta Architecture. Performance. Efficiency. Availability
HPC DAY 2017 | NVIDIA Volta Architecture. Performance. Efficiency. Availability
HPC DAY
 
HPC DAY 2017 | HPE Strategy And Portfolio for AI, BigData and HPC
HPC DAY 2017 | HPE Strategy And Portfolio for AI, BigData and HPC
HPC DAY
 
Database Security Threats - MariaDB Security Best Practices
Database Security Threats - MariaDB Security Best Practices
MariaDB plc
 
HPC DAY 2017 | Accelerating tomorrow's HPC and AI workflows with Intel Archit...
HPC DAY 2017 | Accelerating tomorrow's HPC and AI workflows with Intel Archit...
HPC DAY
 
Model Simulation, Graphical Animation, and Omniscient Debugging with EcoreToo...
Model Simulation, Graphical Animation, and Omniscient Debugging with EcoreToo...
Benoit Combemale
 
Libnetwork updates
Libnetwork updates
Moby Project
 
HPC DAY 2017 | Altair's PBS Pro: Your Gateway to HPC Computing
HPC DAY 2017 | Altair's PBS Pro: Your Gateway to HPC Computing
HPC DAY
 
Latency tracing in distributed Java applications
Latency tracing in distributed Java applications
Constantine Slisenka
 
GPU databases - How to use them and what the future holds
GPU databases - How to use them and what the future holds
Arnon Shimoni
 
Design patterns in Java - Monitis 2017
Design patterns in Java - Monitis 2017
Arsen Gasparyan
 
세션1. block chain as a platform
세션1. block chain as a platform
Jay JH Park
 
Ad

Similar to Getting Started with Embedded Python: MicroPython and CircuitPython (20)

Starting from scratch to build MicroPython.pptx
Starting from scratch to build MicroPython.pptx
Ramprakashs12
 
Iot Bootcamp - abridged - part 1
Iot Bootcamp - abridged - part 1
Marcus Tarquinio
 
Micropython for the iot
Micropython for the iot
Jacques Supcik
 
Micropython on MicroControllers
Micropython on MicroControllers
Akshai M
 
MicroPython&electronics prezentācija
MicroPython&electronics prezentācija
CRImier
 
Get Starte with MicroPython ESP32
Get Starte with MicroPython ESP32
fanghe22
 
Get Started with MicroPython ESP32
Get Started with MicroPython ESP32
fanghe22
 
Python in the real world : from everyday applications to advanced robotics
Python in the real world : from everyday applications to advanced robotics
Jivitesh Dhaliwal
 
Getting Started with MicroPython and LoPy
Getting Started with MicroPython and LoPy
Christian Fässler
 
IoT: Internet of Things with Python
IoT: Internet of Things with Python
Lelio Campanile
 
Programando o ESP8266 com Python
Programando o ESP8266 com Python
Relsi Maron
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptx
TuynLCh
 
Tangible Tools For Teaching With Python
Tangible Tools For Teaching With Python
Tony DiCola
 
MicroPython Introduction PUSG July 2017
MicroPython Introduction PUSG July 2017
Ovidiu HOSSU
 
Intro to the raspberry pi board
Intro to the raspberry pi board
Thierry Gayet
 
DIY Home Smart Lighting System with Micropython - PyCon MY 2018
DIY Home Smart Lighting System with Micropython - PyCon MY 2018
Tegar Imansyah
 
Iot bootcamp abridged - part 2
Iot bootcamp abridged - part 2
Marcus Tarquinio
 
Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIO
Kris Findlay
 
Internet of Energy: "Can python prevent California wildfires?"
Internet of Energy: "Can python prevent California wildfires?"
Chijioke “CJ” Ejimuda
 
Damien George - Micro Python - CIUUK14
Damien George - Micro Python - CIUUK14
Daniel Lewis
 
Starting from scratch to build MicroPython.pptx
Starting from scratch to build MicroPython.pptx
Ramprakashs12
 
Iot Bootcamp - abridged - part 1
Iot Bootcamp - abridged - part 1
Marcus Tarquinio
 
Micropython for the iot
Micropython for the iot
Jacques Supcik
 
Micropython on MicroControllers
Micropython on MicroControllers
Akshai M
 
MicroPython&electronics prezentācija
MicroPython&electronics prezentācija
CRImier
 
Get Starte with MicroPython ESP32
Get Starte with MicroPython ESP32
fanghe22
 
Get Started with MicroPython ESP32
Get Started with MicroPython ESP32
fanghe22
 
Python in the real world : from everyday applications to advanced robotics
Python in the real world : from everyday applications to advanced robotics
Jivitesh Dhaliwal
 
Getting Started with MicroPython and LoPy
Getting Started with MicroPython and LoPy
Christian Fässler
 
IoT: Internet of Things with Python
IoT: Internet of Things with Python
Lelio Campanile
 
Programando o ESP8266 com Python
Programando o ESP8266 com Python
Relsi Maron
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptx
TuynLCh
 
Tangible Tools For Teaching With Python
Tangible Tools For Teaching With Python
Tony DiCola
 
MicroPython Introduction PUSG July 2017
MicroPython Introduction PUSG July 2017
Ovidiu HOSSU
 
Intro to the raspberry pi board
Intro to the raspberry pi board
Thierry Gayet
 
DIY Home Smart Lighting System with Micropython - PyCon MY 2018
DIY Home Smart Lighting System with Micropython - PyCon MY 2018
Tegar Imansyah
 
Iot bootcamp abridged - part 2
Iot bootcamp abridged - part 2
Marcus Tarquinio
 
Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIO
Kris Findlay
 
Internet of Energy: "Can python prevent California wildfires?"
Internet of Energy: "Can python prevent California wildfires?"
Chijioke “CJ” Ejimuda
 
Damien George - Micro Python - CIUUK14
Damien George - Micro Python - CIUUK14
Daniel Lewis
 
Ad

More from Ayan Pahwa (6)

Kicad 101
Kicad 101
Ayan Pahwa
 
IoT with circuitpython | CloudBadge
IoT with circuitpython | CloudBadge
Ayan Pahwa
 
MQTT on Raspberry Pi - Basics
MQTT on Raspberry Pi - Basics
Ayan Pahwa
 
Basics of Embedded Systems / Hardware - Architectures
Basics of Embedded Systems / Hardware - Architectures
Ayan Pahwa
 
Using Linux in commercial products + Yocto Project touchdown
Using Linux in commercial products + Yocto Project touchdown
Ayan Pahwa
 
Reverse engineering IoT Devices
Reverse engineering IoT Devices
Ayan Pahwa
 
IoT with circuitpython | CloudBadge
IoT with circuitpython | CloudBadge
Ayan Pahwa
 
MQTT on Raspberry Pi - Basics
MQTT on Raspberry Pi - Basics
Ayan Pahwa
 
Basics of Embedded Systems / Hardware - Architectures
Basics of Embedded Systems / Hardware - Architectures
Ayan Pahwa
 
Using Linux in commercial products + Yocto Project touchdown
Using Linux in commercial products + Yocto Project touchdown
Ayan Pahwa
 
Reverse engineering IoT Devices
Reverse engineering IoT Devices
Ayan Pahwa
 

Recently uploaded (20)

PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 

Getting Started with Embedded Python: MicroPython and CircuitPython

  • 1. Getting Started with Embedded Python (MicroPython and CircuitPython) @iAyanPahwa/iayanpahwa
  • 2. About Me Embedded Software Engineer at Mentor Graphics - A Siemens Business Part time blogger Full time maker Mentor Graphics is world leader in Electronics Design Automation(Tools Business). I work for Automotive Embedded Software Division, which deals in providing custom solutions, OS and BSP for IVI and ADAS systems. Contact: https://iayanpahwa.github.io
  • 3. People who are really serious about software should make their own hardware - Alan Kay Motivation - @iAyanPahwa/iayanpahwa
  • 5. What is MicroPython The MicroPython project is an open source implementation of Python 3 that includes a small subset of the Python standard libraries, and is optimised to run on microcontrollers with constrained environments like limited ROM, RAM and processing power. It came about after a successful Kick-starter campaign by Damien George. @iAyanPahwa/iayanpahwa
  • 6. Python 3 IoT (Devices) Microcontrollers In a NutShell @iAyanPahwa/iayanpahwa
  • 9. ~20MHz System Clock ~32Kb RAM ~16MB ROM Single Core Register Level Access Microcontrollers @iAyanPahwa/iayanpahwa
  • 10. MicroPython - A small stripped down version on Python3 which runs as firmware on microcontrollers, exposes all the low level modules, acting as an operating system. - It is packed full of advanced features such as an interactive prompt, arbitrary precision integers, closures, list comprehension, generators, exception handling and more. - Yet it is compact enough to fit and run within just 256k of code space and 16k of RAM. - MicroPython aims to be as compatible with normal Python as possible to allow you to transfer code with ease from the desktop to a microcontroller or embedded target. - Python APIs for low level hardware modules- GPIOs, UART, PWM, ADC, i2c, SPI. - Runs directly on bare-metal or under OS env or as emulator. @iAyanPahwa/iayanpahwa
  • 11. Python vs μPython vs Arduino Refer: https://github.com/micropython/micropython/wiki @iAyanPahwa/iayanpahwa
  • 14. The ESP8266 160Kb RAM 802.11 b/g/n 4MB Flash GPIO, ADC, I2c, SPI @iAyanPahwa/iayanpahwa
  • 15. Functions & Libraries Supported @iAyanPahwa/iayanpahwa
  • 16. Interaction Serial REPL (115200 BAUD RATE) WEB REPL, works over LAN File System mounts on host Tools to transfer source code(ex: AMPY) Emulation on linux host Unicorn web based emulator @iAyanPahwa/iayanpahwa
  • 17. Interaction: Serial Loading uP on ESP8266 board Install esptool - pip install esptool Download uP firmware.bin from GitHub release pages for your board. Erase flash - esptool.py --port /path/to/ESP8266 erase_flash Flash uP firmware - esptool.py --port /path/to/ESP8266 -- baud 460800 write_flash --flash_size=detect 0 firmware.bin Connect Serial console - screen /dev/tty… 115200 @iAyanPahwa/iayanpahwa
  • 18. Interaction: WebREPL Setting up WebREPL > import webrepl_setup > Enter ‘E’ to enable it > Enter and confirm password(defaults micropythoN) > Enter ‘y’ to reboot and save changes @iAyanPahwa/iayanpahwa
  • 23. (DEMO) HELLO WORLD OF ELECTRONICS @iAyanPahwa/iayanpahwa
  • 24. Interaction: Hello WORlD // Classic way of Blinking LED #include “Board_Defination_File.h” int main(void) { while(1){ DDRB |= (1 << 7); PORTB |= (1 << 7); _delay_ms(1000); PORTB &= ~(1 << 7); _delay_ms(1000); } } // Make Pin Output // Send logic 1 to the pin //Send logic 0 to the pin @iAyanPahwa/iayanpahwa
  • 25. Interaction: h3llO WORlD > from machine import Pin > from time import sleep # Make Pin behave as output > led = Pin(2, Pin.OUT) > while True: # Send digital logic 1 to the pin > led.on() > sleep(1) # Send digital logic 0 to the pin > led.off() > sleep(1) MicroPython Way @iAyanPahwa/iayanpahwa
  • 26. Interaction: Advance File System on Flash to store: WiFi credentials (SSID, PASSOWRD) boot.py - POST operations main.py - main executable You can mount the fs over network, or transfer files over webREPL or tools like AMPY. @iAyanPahwa/iayanpahwa
  • 27. CircuitPython https://github.com/adafruit/circuitpython Adafruit fork of MicroPython maintained for educational purpose around boards sell by Adafruit industries. Centred Around ATMEL SAMD21 and ESP8266 SoCs. Various new modules added like capacitive touch APIs, Sound outputs, USB HID etc. Bluetooth Low energy support with newly supported NRF SoC port.
  • 28. DISCLAIMER: The stunts will be performed by experts under expert supervision and no matter how many times you test before, chances of live demo failures are incalculable :P SHOW TIME @iAyanPahwa/iayanpahwa
  • 30. Temperature and Humidity Measurement > import dht, machine > from time import sleep # Make Pin behave as output > d = dht.DHT11(machine.Pin(4)) > while True: # Measure temp and humidity > d.measure() # Print Values > d.temperature() > d.humidity() > sleep(2) @iAyanPahwa/iayanpahwa
  • 31. NeoPixel * 1 wire to control multiple LEDs, color and brightness. * 8-bit format for Red, Green, Blue * RRGGBB * 0-ff or 0-255
  • 32. NeoPixel > import machine, neopixel # Initialize GPIO and number of pixels > np = neopixel.NeoPixel(machine.Pin(4), 8) # Set a Pixel color in RGB format > np[0] = (255, 0, 0) >np.write() @iAyanPahwa/iayanpahwa