# MicroPython Basics: What is MicroPython? ## Overview Danger: ![](https://cdn-learn.adafruit.com/assets/assets/000/034/694/medium800/microcontrollers_IMG_5117.jpg?1471023252) https://www.youtube.com/watch?v=I9RKliCYpsM This guide explains what is the [MicroPython programming language](http://micropython.org/), why you might want to use it for hardware projects, and where to find more information on MicroPython.  If you're familiar with [Arduino](https://www.arduino.cc/) you'll learn how MicroPython compares to it and why you might want to explore using MicroPython in place of Arduino.  Don't worry though if you're totally new to hardware and programming MicroPython is a great place to start learning! In addition this guide also explores [CircuitPython](https://github.com/adafruit/circuitpython) which is Adafruit's open source derivative of MicroPython with a focus on being simple for beginners to get started with electronics.  Read below to learn more about the differences between CircuitPython and MicroPython.  Both use the same Python programming language and have similar features--almost anything you can do in MicroPython can be done in CircuitPython (and more!). ### [MicroPython](https://www.micropython.org/) is a tiny open source [Python programming language](https://www.python.org/) interpretor that runs on small embedded development boards.  With MicroPython you can write clean and simple Python code to control hardware instead of having to use complex low-level languages like C or C++ (what Arduino uses for programming). The simplicity of the Python programming language makes MicroPython an excellent choice for beginners who are new to programming and hardware.  However MicroPython is also quite full-featured and supports most of Python's syntax so even seasoned Python veterans will find MicroPython familiar and fun to use. Beyond its ease of use MicroPython has some unique features that set it apart from other embedded systems: - **Interactive REPL, or read-evaluate-print loop.**  This allows you to connect to a board and have it execute code without any need for compiling or uploading--perfect for quickly learning and experimenting with hardware! - **Extensive software library.**  Like the normal Python programming langauge MicroPython is 'batteries included' and has libraries built in to support many tasks.  For example parsing JSON data from a web service, searching text with a regular expression, or even doing network socket programming is easy with built-in libraries for MicroPython. - **Extensibility.**  For advanced users MicroPython is extensible with low-level C/C++ functions so you can mix expressive high-level MicroPython code with faster low-level code when you need it. ### [CircuitPython](https://github.com/adafruit/circuitpython) is Adafruit's open source derivative of MicroPython.  This version of MicroPython was created to add support for easily getting started with electronics using boards like Circuit Playground Express, Trinket M0, Gemma M0, and more.  Check out the [CircuitPython documentation](http://circuitpython.readthedocs.io/en/latest/) for more details about it, including a list of [differences between CircuitPython and MicroPython](http://circuitpython.readthedocs.io/en/latest/README.html#differences-from-micropython).   In almost all cases you can do the same things with both CircuitPython and MicroPython.  CircuitPython has slightly different and simpler APIs for accessing some hardware components like digital I/O, I2C, SPI, etc. However the core Python language support is the same between CircuitPython and MicroPython. Unless a guide or project notes otherwise you can use the same code between CircuitPython and MicroPython and vice-versa.   ### Almost anything you can imagine!  Just like an Arduino board MicroPython can control hardware and connected devices.  You can control GPIO pins to blink lights, read switches, and more.  You can drive PWM outputs for servos, LEDs, etc. or read analog sensors with an analog to digital converter.  Talking to I2C or SPI devices is easy too, and you'll even find network & WiFi support on some boards.  MicroPython even has libraries for controling other hardware like NeoPixels and LED strips, tiny OLED displays, and more. In short, MicroPython can do a lot! For some examples of what MicroPython can do check out the following: - [Video overview of MicroPython Pyboard](https://www.youtube.com/watch?v=5LbgyDmRu9s) - [Video overview of MicroPython on ESP8266](https://www.youtube.com/watch?v=D-CaWFMFCV0) - [Kickstarter campaign video for MicroPython on ESP8266](https://www.kickstarter.com/projects/214379695/micropython-on-the-esp8266-beautifully-easy-iot/description) - [Video demo of dice game in MicroPython on the bbc:microbit](https://www.youtube.com/watch?v=OrWGIvM72OI) - [Play with a live MicroPython Pyboard over the internet](http://micropython.org/live/) ### There are very few limitations with MicroPython, almost anything an Arduino can do can also be done by a MicroPython board.  However one thing to realize is that MicroPython code isn't as fast and might use a little more memory compared to similar Arduino or other low-level C/C++-based code.  Usually this doesn't matter since the speed and memory differences are small and don't impact most normal uses. However be aware that code which has tight timing or performance requirements might not work in MicroPython.  For example 'bit banging' a fast serial protocol entirely in MicroPython might not be the best idea.  However there are ways to mix both MicroPython and low-level C/C++ code so you can have the best of both worlds--your main logic in clean and easy to understand MicroPython code, and performance critical parts written in faster low-level code. The MicroPython langauge implements most of the core Python 3 language, however MicroPython can't implement the entire Python 3 standard library.  Python is known for having an extensive standard library, but trying to squeeze such a big library onto tiny boards with just kilobytes of memory isn't possible.  MicroPython instead implements smallers versions of some Python standard libraries to give you a great development experience. ### There are a couple important differences between Arduino and MicroPython.  The first is that Arduino is an entire 'ecosystem' with the Arduino IDE (i.e. the desktop application you use to write and upload sketches), the Arduino programming language (based on C/C++), and Arduino hardware like the Arduino Uno R3 board. MicroPython is **only**  a programming language interpreter and does not include an editor.  Some MicroPython boards support a web-based code prompt/editor, but with most MicroPython boards you'll write code in your desired text editor and then use small tools to upload and run the code on a board. If you're coming to MicroPython or CircuitPython from a language that has a full IDE/editing environment like Arduino you might want some tips on how to configure and use a text editor and other tools for MicroPython/CircuitPython development.  See these videos below for a deep dive into setting and using MicroPython/CircuitPython on different platforms: - [CircuitPython on ChromeOS](https://www.youtube.com/watch?v=B-PfKv7DCbc) - [CircuitPython on Windows](https://www.youtube.com/watch?v=FD5lkDypVSo) - [CircuitPython on macOS](https://www.youtube.com/watch?v=2BwV9WYFo0I) The second important difference is that the MicroPython language is **interpreted** instead of being compiled into code the CPU can run directly like with the Arduino programming language.  Interpreted means when MicroPython code runs it has to do a little more work to convert from MicroPython code to instructions the CPU understands. A major advantage of interpreted code is that it can be much cleaner and simpler compared to languages that compile directly to CPU instructions.  You can even write and run interpreted code like MicroPython directly on a board without any compiling or uploading--something that's impossible with Arduino! One disadvantage of interpreted code and MicroPython vs. Arduino is that there's less performance and sometimes more memory usage when interpreting code.  A function or sketch written in Arduino will run as fast as possible on a board's CPU whereas similar code in MicroPython will be a little slower because it has to interpret every instruction and convert it to CPU code.  In practice this performance hit is rarely an issue for the kinds of projects you might create with Arduino.  If you do run into performance or memory problems MicroPython allows you to write code in C/C++ or even the board's native CPU assembly instructions for maximum perfomance. Ultimately there's no simple answer for the choice between MicroPython and Arduino.  Each has strengths and weaknesses that should be considered for your own projects.  Don't be afraid to try MicroPython--for some boards like the ESP8266 you can actually use either MicroPython or Arduino and pick the best one for your needs. ### Be sure to check the [MicroPython website](http://micropython.org/) to see the latest information on supported boards.  As of August 2016 these boards support MicroPython in various ways: - **[pyboard](https://www.adafruit.com/product/2390)** - This is the first MicroPython board and has very complete support for the language and hardware peripherals.  This board comes to you with MicroPython running on it so you can get started using it immediately without any setup.  Check out the [pyboard documentation](http://docs.micropython.org/en/latest/pyboard/) for more details on its capabilities. - **[ESP8266](https://www.adafruit.com/product/2821)** - MicroPython support for the popular ESP8266 WiFi microcontroller is excellent.  With MicroPython on ESP8266 you can access peripherals like GPIO, ADC, PWM, and I2C/SPI devices.  In addition WiFi & internet access is available and well supported.  There's even a web-based REPL that allows you to run MicroPython code on the ESP8266 through your web browser!  Check out the [ESP8266 MicroPython documentation](http://docs.micropython.org/en/v1.8/esp8266/) and the [MicroPython ESP8266 FAQ forum page](http://forum.micropython.org/viewtopic.php?f=16&t=1908) for more information.  If you're looking for an inexpensive and easy board to start with MicroPython the ESP8266 is a great option. - **[SAMD21-based Boards](../../../../micropython-for-samd21)** - Atmel SAMD21-based boards like the Feather M0 and Arduino Zero can use CircuitPython, Adafruit's open source derivative of MicroPython.  See the [Metro M0 Express guide](../../../../adafruit-metro-m0-express-designed-for-circuitpython/circuitpython) for more information on using CircuitPython with these boards. - **[WiPy](https://www.adafruit.com/product/3184)** - The WiPy is another MicroPython board with WiFi and great support. [Pycom](https://www.pycom.io/) is the company behind the WiPy board and they provide a nice integrated development environment to load and run MicroPython code on their boards.  Be sure to see the [WiPy page on Pycom's website](https://www.pycom.io/solutions/py-boards/WiPy/) for more information about the board's capabilities, in particular note the board currently doesn't support floating point calculations. - **[BBC micro:bit](https://www.microbit.co.uk/)** - The BBC micro:bit has great support for MicroPython and a very nice set of tools to write and upload code.  With MicroPython on the micro:bit you can access the board's onboard peripherals including its LEDs, accelerometer, GPIO, radio, and more.  Check out the [official micro:bit MicroPython documentation](https://microbit-micropython.readthedocs.io/en/latest/) for more details. - **[Teensy 3.x](https://www.adafruit.com/product/2756)** - The Teensy 3.x series of microcontrollers have an [early port of MicroPython available](https://forum.pjrc.com/threads/24794-MicroPython-for-Teensy-3-1). Be aware you might need to be familiar with building firmware and compiling code to use this port as there aren't pre-made images available.  This port of MicroPython is also a bit less mature compared to other boards but can still access basic peripherals like GPIO on the board.  If you're looking at using MicroPython on a Teensy you'll want to [check out the Teensy forums](https://forum.pjrc.com/threads/24794-MicroPython-for-Teensy-3-1) to learn more about what's possible in the current port. See the [MicroPython GitHub repository](https://github.com/micropython/micropython) for more information on other supported boards & platforms. ### Absolutely not!  MicroPython implements most of the Python 3 core language and as such it can be as simple or complex as you need.  As a Python beginner you'll feel right at home accessing MicroPython's REPL and experimenting with code.  Python is praised for having a clean and easy to learn syntax that's great for beginners. If you're new to Python it will help to get familiar with the basics of Python programming on your computer.  Some good free resources for learning Python are: - [Learning Python resources from the Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/intro/learning/) - [Learn Python The Hard Way](http://learnpythonthehardway.org/) If you're more experienced with Python you'll be amazed at just how much of Python's expressive power is in MicroPython.  Advanced concepts like functional and dynamic programming are all possible with MicroPython.  You can even dive into the MicroPython codebase and start extending it with new functions, libraries, and more. ### Check out the following resources to learn more about MicroPython and how to use it with specific boards: - [MicroPython homepage](http://micropython.org/) - [MicroPython pyboard documentation](http://docs.micropython.org/en/latest/pyboard/) - [MicroPython ESP8266 documentation](http://docs.micropython.org/en/latest/esp8266/) and [MicroPython ESP8266 FAQ forum page](http://forum.micropython.org/viewtopic.php?f=16&t=1908) - [MicroPython BBC micro:bit documentation](https://microbit-micropython.readthedocs.io/en/latest/) - [MicroPython WiPy documentation](https://docs.pycom.io/wipy/) - [MicroPython Developer Wiki](https://github.com/micropython/micropython/wiki) - [Differences between MicroPython and standard desktop Python](https://github.com/micropython/micropython/wiki/Differences) ### There's a growing community of MicroPython users who might be able to help you if you have questions or issues: - [MicroPython forums](http://forum.micropython.org/) - [MicroPython GitHub home](https://github.com/micropython) (be courteous and don't clutter GitHub issues with troubleshooting & tech support that's better done on forums) Remember MicroPython is primarily a volunteer effort so be respectful of people spending their spare time to help others! ### Check out more guides in the MicroPython Basics series: - [MicroPython Basics: How to Load MicroPython on a Board](../../../../micropython-basics-how-to-load-micropython-on-a-board) - [MicroPython Basics: Blink a LED](../../../../micropython-basics-blink-a-led/overview) - [MicroPython Basics: Load Files & Run Code](../../../../micropython-basics-load-files-and-run-code/overview) - [MicroPython Basics: ESP8266 WebREPL](../../../../micropython-basics-esp8266-webrepl/overview?view=all) - [MicroPython Basics: Loading Modules](../../../../micropython-basics-loading-modules) Also [check the MicroPython category on the learning system](../../../../category/micropython) for more MicroPython guides! ## Featured Products ### MicroPython pyboard [MicroPython pyboard](https://www.adafruit.com/product/2390) The **pyboard** is a compact and powerful electronics development board that runs MicroPython. It connects to your PC over USB, giving you a USB flash drive to save your Python scripts, and a serial Python prompt (a REPL) for instant programming. Requires a micro USB cable, and... In Stock [Buy Now](https://www.adafruit.com/product/2390) [Related Guides to the Product](https://learn.adafruit.com/products/2390/guides) ### Adafruit Feather HUZZAH with ESP8266 - Loose Headers [Adafruit Feather HUZZAH with ESP8266 - Loose Headers](https://www.adafruit.com/product/2821) Feather is the new development board from Adafruit, and like its namesake, it is thin, light, and lets you fly! We designed Feather to be a new standard for portable microcontroller cores. This is the  **Adafruit Feather HUZZAH ESP8266**  - our take on an... In Stock [Buy Now](https://www.adafruit.com/product/2821) [Related Guides to the Product](https://learn.adafruit.com/products/2821/guides) ### Adafruit HUZZAH ESP8266 Breakout [Adafruit HUZZAH ESP8266 Breakout](https://www.adafruit.com/product/2471) Add Internet to your next project with an adorable, bite-sized WiFi microcontroller, at a price you like! The ESP8266 processor from Espressif is an 80 MHz microcontroller with a full WiFi front-end (both as client and access point) and TCP/IP stack with DNS support as well. While this chip... In Stock [Buy Now](https://www.adafruit.com/product/2471) [Related Guides to the Product](https://learn.adafruit.com/products/2471/guides) ### ESP8266 WiFi Module [ESP8266 WiFi Module](https://www.adafruit.com/product/2282) This interesting module is a lot of fun for hobbyists and students who are interested in experimenting with the ESP8266 WiFi chipset. We bought a bunch of these modules, updated the firmware to the much-easier-to-use v0.924 and wrote some Arduino code to grab a webpage. We do not... No Longer Stocked [Buy Now](https://www.adafruit.com/product/2282) [Related Guides to the Product](https://learn.adafruit.com/products/2282/guides) ### WiPy 1.0 - IoT Development Platform [WiPy 1.0 - IoT Development Platform](https://www.adafruit.com/product/3184) The **WiPy** is an enterprise grade IOT development platform
 that runs Python in real time with the perfect blend of power, speed, friendliness, and flexibility. Within a few minutes you can wirelessly connect to it and get a Python REPL command line. In addition to... No Longer Stocked [Buy Now](https://www.adafruit.com/product/3184) [Related Guides to the Product](https://learn.adafruit.com/products/3184/guides) ### Teensy 3.2 + header [Teensy 3.2 + header](https://www.adafruit.com/product/2756) [Teensy](http://www.pjrc.com/teensy/index.html) 3.2 is a small, breadboard-friendly development board designed by Paul Stoffregen and PJRC. Teensy 3.2 brings a low-cost 32 bit ARM Cortex-M4 platform to hobbyists, students and engineers, using an adapted version of the... No Longer Stocked [Buy Now](https://www.adafruit.com/product/2756) [Related Guides to the Product](https://learn.adafruit.com/products/2756/guides) ### Python - Skill badge, iron-on patch [Python - Skill badge, iron-on patch](https://www.adafruit.com/product/750) You've learned the Python programming language! Python is an easy-to-learn and programming language that's popular for its powerful capabilities and human-readable code. The Python logo is used with permission from the [Python Foundation](http://www.python.org/psf/). No Longer Stocked [Buy Now](https://www.adafruit.com/product/750) [Related Guides to the Product](https://learn.adafruit.com/products/750/guides) ### Python for Kids - A Playful Introduction to Programming [Python for Kids - A Playful Introduction to Programming](https://www.adafruit.com/product/1161) Python for Kids - _A Playful Introduction to Programming_. Python is a powerful, expressive programming language that’s easy to learn and fun to use! But books about learning to program in Python can be kind of dull, gray, and boring, and that’s no fun for anyone. Featuring... No Longer Stocked [Buy Now](https://www.adafruit.com/product/1161) [Related Guides to the Product](https://learn.adafruit.com/products/1161/guides) ## Related Guides - [Adafruit Feather HUZZAH ESP8266](https://learn.adafruit.com/adafruit-feather-huzzah-esp8266.md) - [Huzzah Weather Display](https://learn.adafruit.com/huzzah-weather-display.md) - [Remote Control with the Huzzah + Adafruit.io](https://learn.adafruit.com/remote-control-with-the-huzzah-plus-adafruit-io.md) - [MicroPython Hardware: SPI Devices](https://learn.adafruit.com/micropython-hardware-spi-devices.md) - [Adafruit HUZZAH ESP8266 breakout](https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout.md) - [MicroPython Basics: How to Load MicroPython on a Board](https://learn.adafruit.com/micropython-basics-how-to-load-micropython-on-a-board.md) - [Building CircuitPython](https://learn.adafruit.com/building-circuitpython.md) - [3D Printed IoT On Air Sign for Twitch](https://learn.adafruit.com/3d-printed-iot-on-air-sign-for-twitch.md) - [Mini Smart Home with Huzzah, HASSio and Crickit](https://learn.adafruit.com/mini-smart-home-with-esp8266-huzzah-feather-raspberry-pi-hassio-crickit.md) - [WiFi Music Alert Box ](https://learn.adafruit.com/wifi-music-alert-box.md) - [Adding Third Party Boards to the Arduino v1.6.4+ IDE](https://learn.adafruit.com/add-boards-arduino-v164.md) - [Using Crickit and Adafruit IO together](https://learn.adafruit.com/crickit-and-adafruitio.md) - [Build an ESP8266 Mobile Robot](https://learn.adafruit.com/build-an-esp8266-mobile-robot.md) - [Mystery Box: Haunted Radio](https://learn.adafruit.com/mystery-box-haunted-radio.md) - [CircuitPython Hardware: LED Backpacks & FeatherWings](https://learn.adafruit.com/micropython-hardware-led-backpacks-and-featherwings.md) - [MQTT, Adafruit IO & You!](https://learn.adafruit.com/mqtt-adafruit-io-and-you.md)