Using webrepl instead of USB connection with Thonny IDE

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
laukejas
Posts: 29
Joined: Thu May 02, 2019 5:17 pm

Using webrepl instead of USB connection with Thonny IDE

Post by laukejas » Thu Oct 22, 2020 3:01 pm

Hi,

After trying out nearly a dozen IDE's, I've finally settled for Thonny. Seems really great for small to medium projects with MicroPython and my ESP8266. Only thing is, having USB cable plugged in during development is extremely inconvenient, especially with moving projects (robots and such).

How can I set up Thonny IDE to allow me to run or upload scripts and manage files via webrepl, without USB connection? I see that previous versions of Thonny used to have webrepl as experimental feature, but now it is gone for some reason. So how do I use it? Or do I need to use something other than webrepl? The final goal is to have a one-click setup from within IDE to get my code to and from my ESP8266 over WiFi.

I see that Thonny is pretty popular around here, so I'd love to hear how you guys solved this.

Divergentti
Posts: 31
Joined: Fri Sep 04, 2020 9:27 am
Location: Hanko, Finland
Contact:

Re: Using webrepl instead of USB connection with Thonny IDE

Post by Divergentti » Thu Oct 22, 2020 5:36 pm

laukejas wrote:
Thu Oct 22, 2020 3:01 pm
Hi,

After trying out nearly a dozen IDE's, I've finally settled for Thonny. Seems really great for small to medium projects with MicroPython and my ESP8266. Only thing is, having USB cable plugged in during development is extremely inconvenient, especially with moving projects (robots and such).

How can I set up Thonny IDE to allow me to run or upload scripts and manage files via webrepl, without USB connection? I see that previous versions of Thonny used to have webrepl as experimental feature, but now it is gone for some reason. So how do I use it? Or do I need to use something other than webrepl? The final goal is to have a one-click setup from within IDE to get my code to and from my ESP8266 over WiFi.

I see that Thonny is pretty popular around here, so I'd love to hear how you guys solved this.
I am interested about this topic too.

I am using PyCharm with Micropython plugin and PuTTY for serial (USB) and WebREPL. PyCharm can send code to the ESP32 and 8266, but since last updates it's serial REPL is broken and that is why I have to use PuTTY for serial connection REPL.

The WebREPL I have used for remote updates file by file (like import os, os.remove('main.py')) mainly because I have not yet implemented OTA-updates.

Perhaps WebREPL client side code can be integrated with IDEs, but I do not know how.

User avatar
aivarannamaa
Posts: 85
Joined: Fri Sep 22, 2017 3:19 pm
Location: Estonia
Contact:

Re: Using webrepl instead of USB connection with Thonny IDE

Post by aivarannamaa » Thu Oct 22, 2020 6:23 pm

Thonny has WebREPL support, but currently it's either unreliable or slow (depending on the configuration) because of https://github.com/micropython/micropython/issues/2497.

I have some ideas about workaround and I can let you know when it's ready.
Aivar Annamaa
https://thonny.org

Divergentti
Posts: 31
Joined: Fri Sep 04, 2020 9:27 am
Location: Hanko, Finland
Contact:

Re: Using webrepl instead of USB connection with Thonny IDE

Post by Divergentti » Sat Oct 24, 2020 8:45 am

I presume websocket_helper.py, webrepl_pli.py and FileSaver.js https://github.com/micropython/webrepl can be added to Thonny and other IDEs as is? Perhaps these same standard libraries can be used for some sort of central management as well.

User avatar
aivarannamaa
Posts: 85
Joined: Fri Sep 22, 2017 3:19 pm
Location: Estonia
Contact:

Re: Using webrepl instead of USB connection with Thonny IDE

Post by aivarannamaa » Sat Oct 24, 2020 11:41 am

Divergentti wrote:
Sat Oct 24, 2020 8:45 am
I presume websocket_helper.py, webrepl_pli.py and FileSaver.js https://github.com/micropython/webrepl can be added to Thonny and other IDEs as is? Perhaps these same standard libraries can be used for some sort of central management as well.
Thonny has a custom solution, and currently it would be hard to use outside of Thonny, but you could check out https://github.com/Hermann-SW/webrepl by @HermannSW for central management.
Aivar Annamaa
https://thonny.org

Minyiky
Posts: 2
Joined: Sat Oct 24, 2020 5:53 pm

Re: Using webrepl instead of USB connection with Thonny IDE

Post by Minyiky » Sat Oct 24, 2020 5:57 pm

aivarannamaa wrote:
Thu Oct 22, 2020 6:23 pm
Thonny has WebREPL support, but currently it's either unreliable or slow (depending on the configuration) because of https://github.com/micropython/micropython/issues/2497.

I have some ideas about workaround and I can let you know when it's ready.
Just to confirm is this something that is in development but not available to users or a feature that should be accessible but may not work well. I ask as I have seen tutorials on using webrepl with thonny but can't access it in either the windows or linux versions.

Just to add another use case to the one mentioned above, the main reason for my interest is that I am using Chrome OS which currently doesn't support CH340 connections in its Crosinti Linux environment

User avatar
aivarannamaa
Posts: 85
Joined: Fri Sep 22, 2017 3:19 pm
Location: Estonia
Contact:

Re: Using webrepl instead of USB connection with Thonny IDE

Post by aivarannamaa » Mon Oct 26, 2020 8:26 pm

Minyiky wrote:
Sat Oct 24, 2020 5:57 pm
Just to confirm is this something that is in development but not available to users or a feature that should be accessible but may not work well. I ask as I have seen tutorials on using webrepl with thonny but can't access it in either the windows or linux versions.
WebREPL support has been experimentally enabled in some Thonny version and disabled in others. The best state of it is in Thonny's code repository and I hope to publish it as the next beta of version 3.3 in couple of days.
Aivar Annamaa
https://thonny.org

User avatar
aivarannamaa
Posts: 85
Joined: Fri Sep 22, 2017 3:19 pm
Location: Estonia
Contact:

Re: Using webrepl instead of USB connection with Thonny IDE

Post by aivarannamaa » Mon Nov 02, 2020 9:12 pm

I just released the next beta of Thonny 3.3, which should work much better with WebREPL: https://github.com/thonny/thonny/releases/tag/v3.3.0b7

Looking forward to your feedback!
Aivar Annamaa
https://thonny.org

laukejas
Posts: 29
Joined: Thu May 02, 2019 5:17 pm

Re: Using webrepl instead of USB connection with Thonny IDE

Post by laukejas » Fri Nov 13, 2020 6:16 pm

aivarannamaa wrote:
Mon Nov 02, 2020 9:12 pm
I just released the next beta of Thonny 3.3, which should work much better with WebREPL: https://github.com/thonny/thonny/releases/tag/v3.3.0b7

Looking forward to your feedback!
It's great. Far fewer exceptions that in the previous build I tried. Amazing software. I do have a question. Is it possible to dynamically capture keystrokes on Thonny and send them to ESP8266 via REPL? I have built a simple robot, and I would like to have an option to manually control it with arrow keys on my keyboard over WiFi, rather than entering commands and having to press Enter each time. Does REPL support this?

User avatar
aivarannamaa
Posts: 85
Joined: Fri Sep 22, 2017 3:19 pm
Location: Estonia
Contact:

Re: Using webrepl instead of USB connection with Thonny IDE

Post by aivarannamaa » Fri Nov 13, 2020 10:18 pm

Nope, Thonny's Shell does not support capturing keystrokes. Actually, I don't see how you could capture keystrokes in MicroPython even if you were using a proper terminal emulator.

> Far fewer exceptions that in the previous build I tried

Do you mean misbehaviors of Thonny? Please report them at https://github.com/thonny/thonny/issues/new
Aivar Annamaa
https://thonny.org

Post Reply