Page 1 of 3

Using webrepl instead of USB connection with Thonny IDE

Posted: Thu Oct 22, 2020 3:01 pm
by laukejas
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.

Re: Using webrepl instead of USB connection with Thonny IDE

Posted: Thu Oct 22, 2020 5:36 pm
by Divergentti
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.

Re: Using webrepl instead of USB connection with Thonny IDE

Posted: Thu Oct 22, 2020 6:23 pm
by aivarannamaa
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.

Re: Using webrepl instead of USB connection with Thonny IDE

Posted: Sat Oct 24, 2020 8:45 am
by Divergentti
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.

Re: Using webrepl instead of USB connection with Thonny IDE

Posted: Sat Oct 24, 2020 11:41 am
by aivarannamaa
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.

Re: Using webrepl instead of USB connection with Thonny IDE

Posted: Sat Oct 24, 2020 5:57 pm
by Minyiky
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

Re: Using webrepl instead of USB connection with Thonny IDE

Posted: Mon Oct 26, 2020 8:26 pm
by aivarannamaa
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.

Re: Using webrepl instead of USB connection with Thonny IDE

Posted: Mon Nov 02, 2020 9:12 pm
by aivarannamaa
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!

Re: Using webrepl instead of USB connection with Thonny IDE

Posted: Fri Nov 13, 2020 6:16 pm
by laukejas
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?

Re: Using webrepl instead of USB connection with Thonny IDE

Posted: Fri Nov 13, 2020 10:18 pm
by aivarannamaa
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