Page 1 of 1

Can't connect to D1 Mini Board

Posted: Tue Dec 07, 2021 12:52 pm
by GuyLevin
I'm using D1 Mini with micropython
It happens a lot that I upload some code that has a main loop in it, and afterwards I lose connection to the board
I can see the console output, but can't see the files, can't burn a new firmware, can't stop the code from running, anything...

Tried looking for an answer online, but couldn't find anything relevant
What can I do?

Re: Can't connect to D1 Mini Board

Posted: Tue Dec 07, 2021 1:20 pm
by Roberthh
Micropython is not a common OS. While main.py is executing, there is no REPL.
You should always be able to stop a running main.py with Ctrl-C, unless main.py re-configures the UART or detaches UART from stdin. But in any case firmware upload is possible. But a new firmware will not clean out a main.py running wild. For that, you have to make a full erase of the flash, using the erase_flash option of esptool.py.

Re: Can't connect to D1 Mini Board

Posted: Tue Dec 07, 2021 1:34 pm
by GuyLevin
Thanks for your reply
I was not able to erase using esptool and ctrl+c seems to stop the program for a second, and then it returns

Re: Can't connect to D1 Mini Board

Posted: Tue Dec 07, 2021 2:25 pm
by Roberthh
Erase_flash is the sledge hammer approach. There is hardly a reason why is should fail. What is the error message when you try it?

esptool.py -p <port_name> -b 460800 --chip esp8266 erase_flash

Re: Can't connect to D1 Mini Board

Posted: Tue Dec 07, 2021 2:56 pm
by GuyLevin
See screenshot

Re: Can't connect to D1 Mini Board

Posted: Tue Dec 07, 2021 3:44 pm
by Roberthh
OK. So there is a problem switching to bootloader mode. What happens it you try to switch to bootloader manually?
For that, connect GPIO0 (D3) to GND and push reset.
P.S.: You did not specify a baud rate.

Re: Can't connect to D1 Mini Board

Posted: Tue Dec 07, 2021 3:59 pm
by GuyLevin
Looks the same
Shorted the pins and added baud rate

Re: Can't connect to D1 Mini Board

Posted: Tue Dec 07, 2021 4:06 pm
by Roberthh
You have to connect GPIO0 to GND and then push the reset button. So you are using a genuine Wemos D1 Mini?

Re: Can't connect to D1 Mini Board

Posted: Tue Dec 07, 2021 4:33 pm
by GuyLevin
I did connect them and pressed the reset button
Yes, I'm using a genuine one

Re: Can't connect to D1 Mini Board

Posted: Tue Dec 07, 2021 11:16 pm
by GuyLevin
Moved from pi to windows, I was able to delete and write the firmware again
The only thing is that now I have to press the reset button while connecting the USB so the computer will recognize the controller