ESP32 LoBo .py File

Step 1: Why? The Purpose.

Run the python program from a .py file.

Case 1: .py file is inside ESP32/Folder.

Case 2: Autorun the .py file whenever ESP32 start/reset.

Step 2: How? The Process.

  1. Create the file inside esp32 folder, write the program and run it.

  2. Automatically Run the program on start/reset.

Step 3: What? The Result.

Verify "What we Get" by "Why we are Doing".

1: Create the file into esp32 folder, write the program and run it.

a) Run rshell with notepad

b) Change Directory to /pyboard/flash.

b) Make Dirctory inside /pyboard/flash named progFiles.

d) change directory to progFiles.

e) edit firstBlinkTest.py

(Case 1: file already present. System will simply open the existing file with notepad)

(Case 2: file is not present. System will create the file and open the blank file for edit)

f) write the program in notepad as shown above, save and close.

g) start repl, import machine and reset ESP32.

h) Run the program by the following command.

Here, in the above program, we append the path of python-interpreter search. So that when we import firstBlinkTest, the python-interpreter is now able to search inside the 'progFiles' folder for such program and if found: run it.

5: Automatically Run the program on start/reset.

a) Ctrl + X to exit the repl.

b) Change directory to /pyboard/flash.

c) edit main.py in notepad.

(Case 1: file already present. System will simply open the existing file with notepad)

(Case 2: file is not present. System will create the file and open the blank file for edit)

d) Write the above program in notepad, save and close.


f) Start repl, import machine and reset ESP32.

Knowledge Base:

Inside ESP32 dev board i.e pyboard, 2 very important files:

  1. 'boot.py' - this file is necessary to boot the ESP32. The file is empty. Don't delete or mesh with the file.

  2. 'main.py' - after finish booting, the MicroPython interpreter automatically execute the main.py file if present.