Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MicroPython on an ESP8266 @ PyTexas 2017

MicroPython on an ESP8266 @ PyTexas 2017

An ESP8266 is a $5 microcontroller with built-in wi-fi capability that can be used to automate things around your home and business. This includes reading sensors, turning on/off switches, controlling motors. This is made even more exciting by being able to use Python to control this!

Christopher Cooper

November 19, 2017
Tweet

More Decks by Christopher Cooper

Other Decks in Technology

Transcript

  1. C. Cooper MicroPython on an ESP8266 MicroPython on an ESP8266

    November 19th, 2017 Presented by Christopher Cooper speakerdeck.com/ccooper21 [email protected]
  2. C. Cooper MicroPython on an ESP8266 HELLO! I am Chris

    Cooper › I design, implement, and deploy enterprise software › I was the Solution Architect and Program Manager for Ford’s DealerConnection platform › I play with microcontrollers and MicroPython for fun 2
  3. C. Cooper MicroPython on an ESP8266 In 2013, Damien George

    asked… Q: Can a microcontroller be programmed using a high-level language? PyBoard v1.1 w/ pin headers (ARM Cortex M4F MCU @ 168Mhz) 5
  4. C. Cooper MicroPython on an ESP8266 MicroPython KickStarter goals and

    deliveries completed on April 12th, 2015 PyBoard v1.1 w/ pin headers (ARM Cortex M4F MCU @ 168Mhz) 6
  5. C. Cooper MicroPython on an ESP8266 What is a MCU?

    › “System-on-a-Chip” › Programmable I/O › Highly power efficient › Low cost › Typically, no operating system Atmel ATtiny85 MCU @ 20Mhz 7
  6. C. Cooper MicroPython on an ESP8266 What is an ESP8266?

    › Up to 160Mhz › 160KB RAM › 4MB ROM (ext. flash) › Built-in wi-fi › ~ $4.50 per unit (NodeMCU) ESP-01 module (Espressif ESP8266EX MCU @ 160Mhz) 10
  7. C. Cooper MicroPython on an ESP8266 Let’s use an Arduino

    Uno... › Not enough RAM (2KB) › Not enough ROM (32KB) › Much slower › No wi-fi › MicroPython Arduino Uno R3 (Atmel ATmega168P MCU @ 16Mhz) 11
  8. C. Cooper MicroPython on an ESP8266 Let’s use a Raspberry

    Pi... › Is a miniaturized computer › Not power efficient › Much more expensive › Not hard real-time suitable Raspberry Pi 3 Model B (4x ARM Cortex A53 cores @ 1.2Ghz) 12
  9. C. Cooper MicroPython on an ESP8266 MicroPython vs. CPython Similarities

    › Language syntax and semantics › REPL (Web enabled on ESP8266) › “pip” for PyPI packages (“upip” in uPy) › Open source › Written in C 15
  10. C. Cooper MicroPython on an ESP8266 MicroPython vs. CPython Differences

    › Subset of standard modules and functionality › Addition of hardware oriented modules › Language enhancements › Memory management › License - MIT vs. PSFL v2 16
  11. C. Cooper MicroPython on an ESP8266 26 See these slides

    again speakerdeck.com/ccooper21 See the code github.com/ccooper21/pytexas_2017 Instructions “C:<R>,<G>,<B>” where each is 0 - 127
  12. C. Cooper MicroPython on an ESP8266 Contact Me E-mail: [email protected]

    GitHub: @ccooper21 27 Creative Commons Attribution: Presentation template by SlidesCarnival See these slides again speakerdeck.com/ccooper21 See the code github.com/ccooper21/pytexas_2017
  13. C. Cooper MicroPython on an ESP8266 MCU Comparison 29 Product

    Core Freq RAM ROM $/10K DMIPS Atmel ATtiny85 Atmel AVR (8-bit) 20Mhz 0.5KB 8KB $0.78 Atmel ATmega328P Atmel AVR (8-bit) 20Mhz 2KB 32KB $1.54 ~7 Nordic nRF52 ARM Cortex M4F (32-bit) 64Mhz 64KB 512KB < $2.60 ~80 Espressif ESP8266EX Tensilica Xtensa LX106 (32-bit) 160Mhz 160KB 4MB (ext.) < $2.45 ~105 Intel Pentium (1994) Intel x86 (32-bit) 100Mhz N/A N/A ~169 NXP MK66 ARM Cortex M4 (32-bit) 180Mhz 256KB 1MB $10.95 ~225 Espressif ESP32 Tensilica Xtensa LX6 (32-bit; dual core) 240Mhz 520KB 4MB (ext.) < $4.39 ~600
  14. C. Cooper MicroPython on an ESP8266 ESP8266 packaging 30 -

    ESP8266EX IC - ~$1.50 (from China) - Specs: - 160 Mhz (max.) - 80 Mhz (def.) - 160KB RAM - ESP-12F (ESP-xx) module - ~$3.00 (from China) - Adds: - Flash IC (4MB) - Oscillator - Wi-Fi antenna - FCC certification - NodeMCU board - ~$4.50 (from China) - ~$9.00 (from Amazon) - Adds: - Regulated power - USB/serial interface - GPIO pin breakout
  15. C. Cooper MicroPython on an ESP8266 NodeMCU › Initially, LUA

    language implementation for ESP8266 › Same team created open source hardware design for popular ESP8266 development board HiLetGo NodeMCU development board 31
  16. C. Cooper MicroPython on an ESP8266 CircuitPython › Fork of

    MicroPython controlled by Adafruit › Goal to make MicroPython more accessible to beginners and hobbyists Adafruit Circuit Playground Express board 32
  17. C. Cooper MicroPython on an ESP8266 Additional References › MicroPython

    Official Site › http://micropython.org/ › MicroPython Getting Started Tutorial (ESP8266 variant) › https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/intro.html › MicroPython Documentation (ESP8266 variant) › http://docs.micropython.org/en/latest/esp8266/ › MicroPython Discussion Forum › https://forum.micropython.org/ › MicroPython GitHub repositories › “micropython”: https://github.com/micropython/micropython/ › “micropython-lib”: https://github.com/micropython/micropython-lib/ › “webrepl”: https://github.com/micropython/webrepl/ 33