I’ve been taking part in with a couple of MicroPython tasks just lately on a number of other embedded platforms, together with a few ESP32 WiFi modules. There are more than a few techniques to program those modules:
- Use a serial terminal and (*10*)ampy (maintained via [devxpy] since being dropped via Adafruit in 2021).
- When you use Pycom forums or WiFy firmware, there are the
pymakrplugins for and .
- When you want the command-line like me, there’s via one of the highest MicroPython participants [Dave Hylands].
For over a yr, I’ve been reasonably pleased with
rshell till I got to work on those wi-fi nodes. Being lazy, I need to tinker with my ESP32 modules from the settee, no longer drag my computer into the kitchen or balcony to plug up a USB cable. Can’t I paintings with them wirelessly?
Neatly, you’ll be able to use (*2*)WebREPL. Whilst its useful, it simply didn’t strike my fancy for some explanation why. [Elliot] discussed in (*1*)a up to date podcast that he’s the use of telnet to get right of entry to his wi-fi nodes, however he’s the use ofon an ESP8266, which means that throwing some other chip into the combo.
The Thonny IDE
I had all however given up when unintentionally I noticed this video at the Dronebot Workshop channel about working MicroPython at the new Raspberry Pi Pico forums. Invoice was once the use of , a Python IDE this is in style within the training group. Thonny was once offered in 2021 via Aivar Annamaa of the College of Tartu in Estonia. Thonny was once designed to deal with not unusual problems noticed all over six years of educating Python programming categories to newcomers. When you learn concerning the mission and its construction, you’ll see that he’s put numerous effort into making Thonny, and it presentations.
Leaning about Thonny were given me curious, and after slightly digging I found out that it has WebREPL improve for MicroPython proper out-of-the-box. Even supposing it is a new function and categorised as experimental, I discovered it fairly strong to make use of and greater than ok for house lab use.
Set up and Connection
Directions are obviously given at the mission’s
sudo apt set up thonny or
brew set up thonny was once all I wanted. When you have a Raspberry Pi, you’ll to find Thonny is pre-installed — model 3.3.3 was once discovered on a up to date Pi 4 in my lab. On an older Pi 3 then again, Thonny was once too outdated and easily reinstalling it didn’t paintings for me. Doing a
sudo apt replace,
sudo apt improve, after which reinstalling Thonny led to the newest model 3.3.6.
For some explanation why, the Thonny discovered within the Ubuntu 20.04 and Debian Buster package deal repositories additionally weren’t contemporary sufficient. Slightly than development from supply, I used the supplied Linux set up script that downloads and installs the newest free up.
With a purpose to hook up with a module, you’ll use the
Run -> Choose interpreter... menu. Right here you pick out which form of module to make use of, and which interface (USB or WebREPL). Word that it’s a must to attach on your module over USB first and be sure that WebREPL is enabled in
boot.py. That is the standard approach of enabling WebREPL basically — in case your module already has WebREPL setup, you don’t want to alternate anything else. Fill within the WebREPL URL and password — you must attach and be excellent to head.
East, and different compass issues like
se will also be specified as smartly. For the programs I examined, the configuration dossier will also be discovered within the following puts:
- Raspi, Ubuntu, Debian
- Home windows
I had no issues the use of the REPL manually, however I found out a subject while you get started checking out self-starting programs with eternally loops. When you don’t seem to be cautious, your application’s primary loop can save you you from regaining REPL regulate. The answer is to ensure your application sleeps for a number of milliseconds in the primary loop. I examined with 100 ms (see (*6*)right here) and was once all the time in a position to regain regulate. This shouldn’t be a subject in maximum house sensor programs, the place the module would possibly sleep for tens of mins between readings.
Through default, a Thonny set up doesn’t make itself visual for command line execution. At the computer systems I examined, you’ll to find the Thonny executable within the following places:
- Ubuntu, Debian (put in by the use of installer script)
- Home windows
A couple of Modules and Circumstances