uPyCraft looses connection to ESP32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: uPyCraft looses connection to ESP32

Post by Roberthh » Sat Apr 13, 2019 9:20 pm

upycraft, rshell and ampy and maybe others assume that the device is in the REPL state. They do not work if the device is running a code. They try to break running code by issuing Ctrl-D. But if after reboot again code is started, that mechanism fails.

cla
Posts: 1
Joined: Sat Apr 20, 2019 7:12 pm

Re: uPyCraft looses connection to ESP32

Post by cla » Sat Apr 20, 2019 7:24 pm

It does appear that the while True: loop ties up the serial port and won't allow uPyCraft to reconnect to ESP32 boards. For the time being, a work around involves using a break statement in the while True: loop. For example:

Code: Select all

from machine import Pin, ADC, PWM
from time import sleep
button = Pin(23, Pin.IN, Pin.PULL_DOWN)
frequency=5000
led=PWM(Pin(5), frequency)
pot = ADC(Pin(34))
pot.atten(ADC.ATTN_11DB)

while True:
  pot_value=pot.read()
  percent_value=(pot_value/4095)
  print(percent_value)
  led.duty(int(1023*percent_value))
  sleep(0.1)

  if button.value()==True:
    break
The above is code for simple dimmer. In the above code, pin 23 can be triggered with an external push button. Once triggered the break will allow reconnection of uPyCraft to the ESP32 board.

What seems to work best is, from uPyCraft: select Tools -->Serial-->Select COM Port. After selecting COM Port (you'll have about 3 seconds) press the external pin interrupt to break out of the while True: loop and allow uPyCraft to reconnect.

matthiasheng
Posts: 13
Joined: Sat Oct 06, 2018 1:57 pm

Re: uPyCraft looses connection to ESP32

Post by matthiasheng » Sun Apr 21, 2019 4:07 pm

Hi All,

I have this annoying problem as well, it happen on some ESP8266 and all the ESP32 boards that i have.
My solution is to solder a push button between reset/enable pin and 3.3V Pin, just before you connect to the serial port, press and hold the push button, after you see ">>>" from the upycraft, you can release the push button, you need to press this push button every time you connect to upycraft, it works 100% on all my esp8266 and esp32 boards.

sirius
Posts: 1
Joined: Wed May 22, 2019 12:08 pm

Re: uPyCraft looses connection to ESP32

Post by sirius » Wed May 22, 2019 12:15 pm

I have the same issue, and it's driving me nuts too.

However, Thonny IDE is working, while uPyCraft is not. So, I just flash the firmware with uPyCraft and do everything else with Thonny IDE. It's not perfect either, but you don't have flasto h firmware every time if you unplug ESP32 -board from your computer.

Post Reply