question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't connect ESP32

See original GitHub issue

I’m testing out an ESP32 (yesterday I worked on a RPi Pico), and I am getting errors connecting it with Belay. It seemingly fails in Pyboard, however if I connect thorugh Pyboard directly, it works.

pyb = pyboard.Pyboard('/dev/cu.SLAB_USBtoUART', 115200)
# pyb = belay.Device('/dev/cu.SLAB_USBtoUART', 115200)

pyb.close()
# Works without errors
# pyb = pyboard.Pyboard('/dev/cu.SLAB_USBtoUART', 115200)
pyb = belay.Device('/dev/cu.SLAB_USBtoUART', 115200)

pyb.close()
# Produces an error >>>

---------------------------------------------------------------------------
PyboardError                              Traceback (most recent call last)
Cell In [24], line 2
      1 # pyb = pyboard.Pyboard('/dev/cu.SLAB_USBtoUART', 115200)
----> 2 pyb = belay.Device('/dev/cu.SLAB_USBtoUART', 115200)
      4 pyb.close()
      6 # poll = select.poll()
      7 # poll.register(pyb.serial, select.POLLIN)

File /usr/local/anaconda3/envs/buxr/lib/python3.10/site-packages/belay/device.py:464, in Device.__init__(self, startup, attempts, *args, **kwargs)
    461 self.attempts = attempts
    462 self._cmd_history = []
--> 464 self._connect_to_board(**self._board_kwargs)
    466 self.task = _TaskExecuter(self)
    467 self.thread = _ThreadExecuter(self)

File /usr/local/anaconda3/envs/buxr/lib/python3.10/site-packages/belay/device.py:523, in Device._connect_to_board(self, **kwargs)
    521 else:
    522     soft_reset = True
--> 523 self._board.enter_raw_repl(soft_reset=soft_reset)

File /usr/local/anaconda3/envs/buxr/lib/python3.10/site-packages/belay/pyboard.py:382, in Pyboard.enter_raw_repl(self, soft_reset)
    380 if not data.endswith(b"raw REPL; CTRL-B to exit\r\n>"):
    381     print(data)
--> 382     raise PyboardError("could not enter raw repl")
...
    386 # Waiting for "soft reboot" independently to "raw REPL" (done below)
    387 # allows boot.py to print, which will show up after "soft reboot"
    388 # and before "raw REPL".

PyboardError: could not enter raw repl

Before the error it seems to print:

b'MicroPython v1.19.1 on 2022-06-18; ESP32 module with ESP32\r\nType "help()" for more information.\r\n>>> '

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
roaldarbolcommented, Nov 16, 2022

I think I did try with >>> earlier, and it didn’t help (but let me give it another try in the morning, as I’m not 100% where I placed it).

1reaction
roaldarbolcommented, Nov 16, 2022

Figured it out! It is a speed problem - adding time.sleep(1) after the while loop solves the issue:

# flush input (without relying on serial.flushInput())
        n = self.serial.inWaiting()
        while n > 0:
            self.serial.read(n)
            n = self.serial.inWaiting()
        time.sleep(1)

0.5 seconds is not enough - 1 second does the trick. Apparently I wasn’t the only one who’s had the issue, see the same issue with ampy: https://github.com/scientifichackers/ampy/issues/19#issuecomment-317126363. (Took me 4 hours, but worth it I hope)😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESP32 Troubleshooting Guide | Random Nerd Tutorials
Solution: try a different shorter USB cable (with data wires), try a different computer USB port or use a USB hub with an...
Read more >
When Your ESP32 Board Won't Connect to Arduino - RNT Lab
When Your ESP32 Board Won't Connect to Arduino · Hold down the “Boot” button on the ESP32 board while uploading the sketch. OR...
Read more >
ESP32 Won't Connect to WiFi? - (Sure Fire Solutions!) - Xtrium
The first thing you can do to fix this issue your WiFi issues is to reboot your ESP32. You can do it by...
Read more >
ESP32 not connecting - Installation & Troubleshooting
Hello,. I am going crazy trying to get a blink code working on these esp32s. When I try to use the Arduino ide...
Read more >
How to fix ESP32 not connecting to the Wifi network
messages, press the RESET button of your board (or unplug and re-plug its power to reset) and and try again. If you still...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found