O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×



Confira estes a seguir

1 de 28 Anúncio

Mais Conteúdo rRelacionado

Diapositivos para si (20)

Semelhante a PyCon_India_2017_MicroPython_Ayan (20)


Mais recentes (20)



  1. 1. Getting Started with Embedded Python: (MicroPython and CircuitPython) By: Ayan Pahwa
  2. 2. About Me Embedded Software Engineer at Mentor Graphics - A Siemens Business IoT Enthusiast Security Researcher FPV Drone Pilot 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. 3. People who are really serious about software should make their own hardware - Alan Kay Motivation -
  4. 4. 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.
  5. 5. Python 3 IoT (Devices) Microcontrollers In a NutShell
  6. 6. Opportunities
  7. 7. ~20MHz System Clock ~32Kb RAM ~16MB ROM Single Core Register Level Access Microcontrollers
  8. 8. 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 in OS or web as emulator.
  9. 9. Python vs μPython vs CPython/PyPy vs Arduino Refer: https://github.com/micropython/micropython/wiki
  10. 10. Boards Supported
  11. 11. The PyBoard
  12. 12. The ESP8266-NodeMCU 160Kb RAM 802.11 b/g/n 4MB Flash GPIO, ADC, I2c, SPI
  13. 13. Functions & Libraries Supported
  14. 14. 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(
  15. 15. 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
  16. 16. 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
  17. 17. Interaction: WebREPL
  18. 18. Interaction: Unicorn https://micropython.org/unicorn
  19. 19. Interaction: Live https://micropython.org/live
  20. 20. Interaction: Emulator
  21. 21. Interaction: h3llO WORlD > from machine import Pin > from time import sleep > led = Pin(13, Pin.Out) > led.on() > sleep(1) > led.off() > sleep(1)
  23. 23. 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.
  24. 24. Interaction: Internals
  25. 25. 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.
  26. 26. DISCLAIMER: Other than the stunts will be performed by experts, No matter how many times you test before, chances of live demo failures are incalculable SHOW TIME
  27. 27. DEMOS