What the best IDE for ESP32 micro python developing ?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
VladVons
Posts: 60
Joined: Sun Feb 12, 2017 6:49 pm
Location: Ukraine

What the best IDE for ESP32 micro python developing ?

Post by VladVons » Sun Jan 24, 2021 8:08 pm

Tell me please what IDE you use for ESP32 micro python developing ?
Thony, uPyCraft, PyCharm or VSCode + some plugin or something else.

Is it possible to debug python source code at all ?

VladVons
Posts: 60
Joined: Sun Feb 12, 2017 6:49 pm
Location: Ukraine

Re: What the best IDE for ESP32 micro python developing ?

Post by VladVons » Mon Jan 25, 2021 10:11 am

Everybody use linux + nano editor + command line for uploading as I do ? :)
so, I share own method

add to the ~/bashrc EOF string
source ~/esp_upload.sh
Hint: dont forget logout/logit to take effect

esp_upload.sh

Code: Select all

#!/bin/bash

#VladVons, 2021.01.25
#add to ~/bashrc EOF source ~/esp_upload.sh and logout/logit to take effect
#to exit from picocom Ctrl+A+X

#### enter terminal
#esp

##### send files to device and ener terminal
#esp dev_dht22.py dev_sht31.py

##### send files to device
#espf dev_dht22.py dev_sht31.py

##### send files from current directory to device
#espd


##### receive files from device from current directory
#espg


cSpeed=115200
cPort=/dev/ttyUSB0


_esp_install()
{
  sudo pip3 install esptool
  sudo pip3 install adafruit-ampy
  sudo pip3 install picocom

  # add current user preveleges
  sudo usermod -a -G dialout $USER
  sudo usermod -a -G tty $USER
}

_esp_terminal()
{
  picocom $cPort -b${cSpeed}
}

_esp_file_transfare()
{
  aMode=$1; aFile=$2; 

  Path="$(pwd)/$aFile"
  Find="src"
  Suffix=${Path#*$Find}

  if [ "$aMode" == "put" ]; then
    Cmd="ampy --port $cPort --baud $cSpeed put $aFile $Suffix"
  elif [ "$aMode" == "get" ]; then
    Cmd="ampy --port $cPort --baud $cSpeed get $Suffix"
  else 
    Cmd="echo unknown mode $aMode"
  fi

  echo $Cmd
  eval "$Cmd"
}


# receive files from device
espg()
{
  for File in $*; do
    _esp_file_transfare get $File
  done
}

##### send files to device from current directory
espd()
{
  for File in $(ls -1); do
    _esp_file_transfare put $File
  done
}

##### send files to device
espf()
{
  for File in $*; do
    _esp_file_transfare put $File
  done
}

##### send files to device and enter terminal
esp()
{
  aFile=$1;

  if [ -z "$aFile" ]; then
    _esp_terminal
  else
    killall picocom
    espf $*
    _esp_terminal
  fi
}
For example i modified sys_info.py in project directory ~/mpy-vRelay/src/Inc
then upload file to board with command

enter terminal
>esp

copy files to device and enter terminal
>esp dev_dht22.py dev_sht31.py

copy files to device
>espf dev_dht22.py dev_sht31.py

copy files to device from current directory
>espd


to exit from picocom
Ctrl+A+X
Last edited by VladVons on Mon Feb 01, 2021 2:11 pm, edited 8 times in total.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: What the best IDE for ESP32 micro python developing ?

Post by jimmo » Tue Jan 26, 2021 12:50 am

VladVons wrote:
Sun Jan 24, 2021 8:08 pm
Tell me please what IDE you use for ESP32 micro python developing ?
I use Sublime Text, but the actual editor doesn't matter too much. I just want something fast and lightweight with basic navigation features and emacs shortcuts.

Then for testing the code on the board I use pyboard.py and miniterm. The key thing about pyboard.py, especially during development, is that you don't have to copy the code to the device first, you can just "run this file". http://docs.micropython.org/en/latest/r ... rd.py.html

There's a new tool that should be available soon called "mpr" (see https://github.com/micropython/micropython/pull/6375) which allows you to mount the PC's filesystem onto the MicroPython device, which means you can skip the file copy step even for multi-file projects.
VladVons wrote:
Sun Jan 24, 2021 8:08 pm
Is it possible to debug python source code at all ?
Unfortunately no. You can debug the C code (using JTAG on ESP32 or SWD/JTAG on ARM), which is often useful enough to track down what's going on.

However, I generally try to avoid actually developing testing the code on the device. Either I use CPython or the unix port of MicroPython with the a mock implementation of the hardware bits.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: What the best IDE for ESP32 micro python developing ?

Post by pythoncoder » Tue Jan 26, 2021 6:30 am

Interesting. I think whether to debug on the hardware depends on what you're developing. I use the same approach for developing algorithms which don't use the hardware, using the Unix build of MicroPython.

But most of the things I do are hardware dependent, such as writing device drivers, sometimes for weird bits of kit like 433MHz radios. I use Kate for the editor, but as @jimmo says this is purely down to personal choice. I use this fork of Dave Hylands rshell for copying files to the device and running the REPL (the fork adds text macros which are seriously useful for complex projects). I debug the old fashioned way with print statements.

In my view debugging on the hardware doesn't slow things down much once you establish a good workflow, but mileage varies. But mpr does sound interesting and could speed development while running the code on the hardware.

I've tried one or two IDE's but I was unconvinced they offered much, although they are great for beginners. There is no MicroPython debugger, sadly, otherwise my view of IDE's might be very different.
Peter Hinch
Index to my micropython libraries.

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

Re: What the best IDE for ESP32 micro python developing ?

Post by aivarannamaa » Tue Jan 26, 2021 6:56 am

pythoncoder wrote:
Tue Jan 26, 2021 6:30 am
There is no MicroPython debugger, sadly, otherwise my view of IDE's might be very different.
The problem is that currently it's not possible to query locals at debug time. I just added a feature request for this: https://github.com/micropython/micropython/issues/6799. Feel free to vote for it!
Aivar Annamaa
https://thonny.org

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: What the best IDE for ESP32 micro python developing ?

Post by pythoncoder » Tue Jan 26, 2021 1:51 pm

aivarannamaa wrote:
Tue Jan 26, 2021 6:56 am
...
The problem is that currently it's not possible to query locals at debug time. I just added a feature request for this: https://github.com/micropython/micropython/issues/6799. Feel free to vote for it!
Is this the only roadblock? Does an underlying mechanism exist to support single stepping and code breakpoints?

I could become a Thonny user if we can debug!
Peter Hinch
Index to my micropython libraries.

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

Re: What the best IDE for ESP32 micro python developing ?

Post by aivarannamaa » Tue Jan 26, 2021 2:09 pm

pythoncoder wrote:
Tue Jan 26, 2021 1:51 pm
Is this the only roadblock? Does an underlying mechanism exist to support single stepping and code breakpoints?
Since 1.12 it is possible to compile MicroPython with sys.settrace, which can be used for registering a callback function to be called by the VM when a frame is entered/exited, exception raised or a new line reached. The callback function gets information about current stack (but not locals). It seems to work quite like sys.settrace in CPython. I've experimented with it only in the Unix port, though, but I expect it to work in bare metal ports as well.
Aivar Annamaa
https://thonny.org

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: What the best IDE for ESP32 micro python developing ?

Post by pythoncoder » Tue Jan 26, 2021 3:10 pm

Excellent. A debugger would be a real game-changer.
Peter Hinch
Index to my micropython libraries.

lorenz
Posts: 8
Joined: Sat Dec 12, 2020 8:11 pm

Re: What the best IDE for ESP32 micro python developing ?

Post by lorenz » Sat Feb 06, 2021 11:56 pm

Hi,
I use VSCode to develop micropython applications.
On top of that I use the micropy-cli which installs the stubs for micropython (https://github.com/BradenM/micropy-cli)
The stubs are useful as the Pylance language server won't complain if e.g. you `import esp32` and all the functions and constants are defined in the stubs. So if I want to know e.g. the wakeup reasons I can just type esp. and then tab and it will show all the globals int he esp32 module.
For me the biggest advantage of VSCode is the markdown plugin which I use to document things on the side (not in the python files but in separate markdown files).

Most of the time I run the application using the pyboard command without copying it over.
To copy the application, libraries and config files I have a set of make command, e.g. `make deploy-dependencies` or `make deploy-configs` which just call the pyboard command again.

For debugging I use print statements.

skinsman
Posts: 2
Joined: Mon May 24, 2021 10:30 pm
Location: Perth, Australia

Re: What the best IDE for ESP32 micro python developing ?

Post by skinsman » Tue May 25, 2021 10:44 am

jimmo wrote:
Tue Jan 26, 2021 12:50 am
VladVons wrote:
Sun Jan 24, 2021 8:08 pm
Tell me please what IDE you use for ESP32 micro python developing ?
I generally try to avoid actually developing testing the code on the device. Either I use CPython or the unix port of MicroPython with the a mock implementation of the hardware bits.
What mock implementation of the hardware bits do you use? I'm fairly new to MicroPython and trying to figure out this side of it. Do you use https://github.com/Josverl/micropython-stubs, your own set of stubs or something else?
Thanks.

Post Reply