001 - ESP32 MicroPython: What is MicroPython
Introduction
MicroPython is essentially a Python created for microcontrollers.
MicroPython is a light-weight and compact implementation of Python Programming Language. It is stripped and trimmed down in order to work with embedded devices which basically has limited resources.
And with the help of machine modules, we can easily communicate with the hardware input and output devices.
So how does the MicroPython works? as you may asked.
- In MicroPython, the source code is created and/or edited in the computer using an Editor like Thonny Python which is the same as in Arduino traditional programming using an Arduino IDE.
- In MicroPython, the code is stored inside the microcontrollers flash memory while in Arduino the code is stored in your computer.
- In MicroPython, the source code compilation happens inside the microcontroller or much better to call it source code interpretation. The Python interpreter converts the source code into byte code and store it in the Random Access Memory and consequently executes the program which all happens in runtime while in Arduino, the source code compilation happens in computer. The Cpp compiler converts code in to machine code. The machine code is transfered to microcontroller through serial interface and written to flash memory. Flash memory is overwritten everytime source code is uploaded.
- In MicroPython, the time it takes from code compilation until execution is very minimal and virtually executes immediately. And because MicroPython is an interpreted language, when you modified your source code it doesn’t need to compile everything it just need to modify a portion according to change in source code while in Arduino, everytime you modified your source code, you also need to recompile everything in order for the modification to take effect.
But since MicroPython is interpreted during the execution of the code, speed performance is not efficient while traditional programming has the advantage in using machine code level.
Another cool feature of MicroPython is the addition of REPL. REPL stands for Read-Evaluate-Print-Loop. REPL allows you to connect to development board and be able to test a code without any need of compiling.
REPL take advantage of the UART serial interface which is commonly included to almost all embedded devices available in the market.
Video Demonstration:
Thank you.
Posts in this series
- 026 - ESP32 MicroPython: MFRC522 RFID Module
- 025 - ESP32 MicroPython: ESP32 Bluetooth Low Energy
- 024 - ESP32 MicroPython: How to Use SD Card in MicroPython
- 023 - ESP32 MicroPython: Binary Clock
- 022 - ESP32 MicroPython: MQTT Part 2: Subscribe
- 021 - ESP32 MicroPython: MQTT Part 1: Publish
- 020 - ESP32 MicroPython: RESTful APIs | Demo READ and WRITE
- 019 - ESP32 MicroPython: OpenWeather | RESTful APIs
- 018 - ESP32 MicroPython: Thingspeak | RESTful APIs
- 017 - ESP32 MicroPython: DHT Values Auto Updates using AJAX
- 016 - ESP32 MicroPython: Web Server | ESP32 Access Point
- 015 - ESP32 MicroPython: Web Server | ESP32 Station Mode in MicroPython
- 014 - ESP32 MicroPython: SIM800L GSM Module in MicroPython
- 013 - ESP32 MicroPython: UART Serial in MicroPython
- 012 - ESP32 MicroPython: HC-SR04 Ultrasonic Sensor in MicroPython
- 011 - ESP32 MicroPython: DHT11, DHT22 in MicroPython
- 010 - ESP32 MicroPython: 0.96 OLED in MicroPython
- 009 - ESP32 MicroPython: Non-blocking Delays and Multithreading | Multitasking
- 008 - ESP32 MicroPython: Hardware Timer Interrupts
- 007 - ESP32 MicroPython: How to make some sound with MicroPython
- 006 - ESP32 MicroPython: How to control servo motor with MicroPython
- 005 - ESP32 MicroPython: Pulse Width Modulation
- 004 - ESP32 MicroPython: External Interrupts
- 003 - ESP32 MicroPython: General Purpose Input Output | GPIO Pins
- 000 - ESP32 MicroPython: How to Get Started with MicroPython
No comments yet!