Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
50 views

MicroPython Programming With ESP32 and ESP8266 Troubleshooting V1 1

This document provides troubleshooting tips for common errors that occur when using MicroPython with the uPyCraft or Thonny IDEs. It describes 7 common errors, such as being unable to open the serial port or upload new code, and provides solutions like restarting the ESP board, checking the serial port selection, or reflashing the MicroPython firmware.

Uploaded by

S4nn3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

MicroPython Programming With ESP32 and ESP8266 Troubleshooting V1 1

This document provides troubleshooting tips for common errors that occur when using MicroPython with the uPyCraft or Thonny IDEs. It describes 7 common errors, such as being unable to open the serial port or upload new code, and provides solutions like restarting the ESP board, checking the serial port selection, or reflashing the MicroPython firmware.

Uploaded by

S4nn3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

MicroPython with uPyCraft IDE

Troubleshooting

We’ve discovered some common problems and error messages that occur with

uPyCraft IDE. Usually restarting your ESP with the on-board EN/RST button fixes

your problem or pressing the uPyCraft IDE “Stop” button and repeating your

desired action. In case it doesn’t work for you, read these next common errors and

discover how to solve them.

Error #1: You get the following message:

>>>
Select Serial Port could not open port 'COM4':
FileNotFoundError(2, 'The system cannot find the file
specified.', None, 2)

Or an equivalent message:

>>>
could not open port 'COM4': PermissionError(13, 'A device
attached to the system is not functioning.', None, 31)
Unplug, and plug back your ESP board. Then, double-check that you’ve selected

the right serial port in the ToolsSerial menu. Then, click the

“Connect/disconnect” button to establish a serial communication. You should

now be able to upload a new script or re-run new code.

This error might also mean that you have your serial port being used in another

program (like a serial terminal or in the Arduino IDE). Double-check that you’ve

closed all the programs that might be establishing a serial communication with

your ESP board. Then, unplug and plug back your ESP board. Finally, restart the

uPyCraft IDE – try to select the serial port in the ToolsSerial menu.

Error #2: Trouble uploading a new script.

>>>
already in download mode, please wait.

Press the “Stop” button in uPyCraft IDE (1 or 2 times) to make sure any code that

was running stops. After that, press the “Download and run” button to upload the

new script to your ESP board.

Error #3: After uploading a new script, if you see the following message:

>>>
Ready to download this file,please wait!
...
download ok
os.listdir('.')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'os' isn't defined

Or this message:

>>>
Ready to download this file,please wait!
...
download ok
os.listdir('.')
OSError: [Errno 98]

Other Courses – Forum - Facebook Group 2


It means the new file was uploaded to your board successfully. You can notice that

it printed the “download ok” message. Press the ESP on-board “EN/RST” button to

restart your board and re-run the new uploaded script from the beginning.

Error #4: Problem restarting your board, running a script or opening the serial port:

>>>
Brownout detector was triggered

The “Brownout detector was triggered” error message means that there’s some

sort of hardware problem. It’s often related to one of the following issues:

 Poor quality USB cable;

 USB cable is too long;

 Board with some defect (bad solder joints);

 Bad computer USB port;

 Or not enough power provided by the computer USB port.

Solution: try a different shorter USB cable (with data wires), try a different

computer USB port or use a USB hub with an external power supply.

IMPORTANT: if you keep having constant problems or weird error messages, we


recommend re-flashing your ESP board with the latest version of MicroPython
firmware.

Error #5: When I try to open a serial communication with the ESP32/ESP8266 in

uPyCraft IDE, sometimes it prompts the “Burn Firmware” window asking to re-flash the

MicroPython firmware.

Basically, we think this is what’s happening: when you’re running a script in your

board, sometimes it’s busy running that script and performing the tasks. So, you

need to try opening the COM port multiple times or restart the ESP to catch it

available to establish the serial communication with uPyCraft IDE.

If you’re running a script that uses Wi-Fi, deep sleep, or it's doing multiple tasks, I

recommend trying 3 or 4 times to establish the communication. If you can’t, I

recommend re-flash the ESP with MicroPython firmware.

Other Courses – Forum - Facebook Group 3


Error #6: You get the following message: “Please install SourceCodePro font”.

Some computers don’t have the SourceCodePro font installed. You can ignore that

message and it will still work just fine.

If you want to install the SourceCodePro font, please follow these instructions:

1. Download the following .zip folder and unzip it to find the font file

inside: https://randomnerdtutorials.com/SourceCodeProFont

2. Then, you need double-click that file to open it and press the “Install” button:

After that, re-open uPyCraft IDE and it will not prompt that warning message again.

Error #7: You get one of the following indentation error messages:

IndentationError: unexpected indent

Or

IndentationError: unindent doesn't match any outer indent level

Other Courses – Forum - Facebook Group 4


Or

SyntaxError: invalid syntax

If you upload a new script to your ESP board and it prompts one of the preceding

error messages, it means that there’s a space or multiple spaces missing in your

script. Python doesn’t use ; or {} to know where each line ends. Python uses

indentation (everything is done using spaces). Double-check that all the spaces are

properly inserted in your script. To avoid indentation errors, we recommend

copying/pasting the code directly from the GitHub link provided in each example.

Other Courses – Forum - Facebook Group 5


MicroPython with Thonny IDE
Troubleshooting

We’ve discovered some common problems and error messages that occur with

Thonny IDE. Usually restarting your ESP with the on-board EN/RST button fixes

your problem. Or pressing the Thonny IDE “Stop/Restart backend” button and

repeating your desired action. In case it doesn’t work for you, read these next

common errors and discover how to solve them.

Error #1: You get one of the following messages:

========================= RESTART =========================


Unable to connect to COM4
Error: could not open port 'COM4': FileNotFoundError(2, 'The
system cannot find the file specified.', None, 2)

Check the configuration, select Run → Stop/Restart or press


Ctrl+F2 to try again. (On some occasions it helps to wait before
trying again.)

Or:

Other Courses – Forum - Facebook Group 6


========================= RESTART =========================
Could not connect to REPL.
Make sure your device has suitable firmware and is not in
bootloader mode!
Disconnecting.

Or:

========================= RESTART =========================


Lost connection to the device (EOF).

Unplug, and plug back your ESP board. Then, double-check that you’ve selected

the right serial port in the Tools  Options  Interpreter  Port. Then, click the

“Stop/Restart backend” button to establish a serial communication. You should

now be able to upload a new script or re-run new code.

These errors might also mean that you have your serial port being used in another

program (like a serial terminal or in the Arduino IDE). Double-check that you’ve

closed all the programs that might be establishing a serial communication with

your ESP board. Then, unplug and plug back your ESP board. Finally, restart

Thonny IDE.

Error #2: Thonny IDE fails to respond or gives an Internal Error:

When this happens, you can usually close that window and it will continue to work.

If it keeps crashing, we recommend restarting the Thonny IDE software.

Other Courses – Forum - Facebook Group 7


Error #3: Thonny IDE hangs when pressing “Stop/Restart backend” button:

When you press the “Stop/Restart backend” button, you need to wait a few

seconds. The ESP needs time to restart and establish the serial communication

with Thonny IDE. If you press the “Stop” button multiple times or if you press the

button very quickly, the ESP will not have enough time to restart properly and it’s

very likely to crash Thonny IDE.

Error #4: Problem restarting your ESP board, running a new script or opening the serial

port:

Brownout detector was triggered

Or if the ESP keeps restarting and printing the ESP boot information:

ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)


configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp
_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4732
load:0x40078000,len:7496
load:0x40080400,len:5512

The “Brownout detector was triggered” error message or constant

reboots means that there’s some sort of hardware problem. It’s often related to

one of the following issues:

 Poor quality USB cable;

 USB cable is too long;

 Board with some defect (bad solder joints);

 Bad computer USB port;

 Or not enough power provided by the computer USB port.

Solution: try a different shorter USB cable (with data wires), try a different

computer USB port or use a USB hub with an external power supply.

Other Courses – Forum - Facebook Group 8


Important: if you keep having constant problems or weird error messages, we

recommend re-flashing your ESP board with the latest version of MicroPython

firmware.

Error #5: When I try to establish a serial communication with the ESP32/ESP8266 in

Thonny IDE, I can’t get it to connect.

We think this is what’s happening: when you’re running a script in your board,

sometimes it’s busy running that script and performing the tasks.

So, you need to try start the connection by pressing “Stop/Restart backend”

button multiple times or restart the ESP to catch available to establish the serial

communication.

Warning: don’t press the “Stop/Restart backend” button multiple times very

quickly. After pressing that button, you need to be patient and wait a few seconds

for the command to run.

If you’re running a script that uses Wi-Fi, deep sleep, or it’s doing multiple tasks, I

recommend trying 3 or 4 times to establish the communication. If you can’t, I

recommend re-flash the ESP with MicroPython firmware.

Error #6: Debug tools are grayed out:

Thonny IDE debug tools aren’t available for MicroPython. The debug tools are only

available for the Python Interpreter, so being grayed out is the expected behavior.

Other Courses – Forum - Facebook Group 9


Error #7: You get one of the following indentation error messages:

IndentationError: unexpected indent

Or

IndentationError: unindent doesn't match any outer indent level

Or

SyntaxError: invalid syntax


If you upload a new script to your ESP board and it prompts one of the preceding

error messages, it means that there’s a space or multiple spaces missing in your

script. Python doesn’t use ; or {} to know where each line ends. Python uses

indentation (everything is done using spaces). Double-check that all the spaces are

properly inserted in your script. To avoid indentation errors, we recommend

copying/pasting the code directly from the GitHub link provided in each example.

Other Courses – Forum - Facebook Group 10

You might also like