Getting started with Micropython for Microcontrollers

Keywords: ESP8266, MicroPython, COM port for ESP8266 not detected, uPyCraft, GPIO control, IDE for micro python, ESP32 

Have you ever wondered why do we need Python for micro controllers ??? Yes you got it right it is widely used language for Machine learning and Artificial Intelligence. With increasing market in Data Science, Machine Learning and Big Data, I being an Embedded Engineer gave a thought and made some use cases which requires a combination of hardware and software mainly python.

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 all of Python’s syntax (Python version 3.4) and implements a small subset of the Python standard library which makes it familiar and fun to use.

Lets have fun in programming ESP8266 WiFi module which is a TINY board to start with. I would cover the following topics.

  1. Prerequisites
  2. Environment setup
  3. GPIO control 
  4. Servo motor control
  5. Connecting to WiFi in stationary mode
  6. Connecting ESP8266 to a server Thingspeak/AWS for IoT 

and lot more.

  • Environment setup
    • Download uPyCraft IDE from https://github.com/DFRobot/uPyCraft/blob/master/uPyCraft_V1.0.exe
    • Run uPyCraftIDE by clicking the exe file which would look like this
    •  uPyCraft IDE has 4 sections
      1. Files & Folders 
        • Device folder contains the files stored in the ESP board. This folder also contains boot.py by default and you have to make another file with main.py to write your program.
        • SD folder contains the files stored in the SD card. There are various boards which support SD card like pyBoard.
        • uPy_lib contains in-built MicroPython IDE libraries.
        • Workspace contains the files which you will save on your PC.​Files & Folders 
      2. Editor: This section is for writing and editing the python code. Multiple python files can be opened in Editor.
      3. Shell/Terminal: This section is for writing and executing the shell commands on the ESP board. This section also shows the status of the program, errors, print messages, etc.
      4. Tools: This section contains options for creating a new file, saving the file, uploading the file, connecting/disconnecting the board, etc.
    • Flashing Micro Python on ESP board 
      1. Download latest bin file for ESP8266 from this link
      2. Open uPyCraft IDE and connect the ESP board.
      3. Go to Tools-> Serial and choose the COM port for your board.

        Note : If you are unable to find the COM port for your ESP8266 board then either USB cable is faulty or you need to install the drivers for ESP32/ESP8266 from this link.

    • Now,  Tools->board , in my case it is esp8266

  1.  

 

 

 

 

 

 

 

 

 

    • Click on Users and choose .bin file that is downloaded earlier. Click ok
    • After a few seconds firmware will be flashed on ESP32. Now we are done with the firmware uploading part

KUDOS you are ready to start writing the code !

  • GPIO control
    • Click on RST button on your hardware
    • Now we will start writing the program for Blinking LED using ESP8266 MicroPython using uPyCraft IDE.
    • Click on the connect icon in the Tools section to make the connection between IDE and ESP board.
    • Congratulations you have executed the code successfully.
    • Good Job!

THANK YOU and many more programs to do!

Please like and share Techawarey.  Find and Like Techawarey on Facebook.😊

Related posts

One Thought to “Getting started with Micropython for Microcontrollers”

Leave a comment....