0

I'm using MicroPython extension, and have successfully flashed the MicroPython firmware (Operating System) to the ESP8266 target device using the NodeMCU flasher tool through a serial COM port.

After creating a new project by selecting the project folder I'm told auto detection of COM ports isn't available for Windows version of Visual Studio Code. I'm prompted to manually enter the COM port I've connected the target MicroPython device to, and VSC then says:

Port not exist, please connect device and try again!

I've tried all 4 USB ports, reinstalled the driver software, rebooted the computer, power cycled the target device and made sure the target device is in program flash mode (to allow application to be written to it) each time I attempt to connect VSC to it!

Tirna
  • 383
  • 1
  • 12

2 Answers2

0

I encountered the same problem as you in not being able to specify a port when using the Micropython IDE extension on windows.

I've found a simple way of running micropython scripts without leaving visual studio. First you'll need to install python, and then install ampy, using pip install ampy.

Then add this task.json build task. You'll need to adjust your baud rate and port as needed.

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "ampy",
            "type": "shell",
            "command": "ampy -b 115200 -p COM5 -d 1 run ${file} --no-output",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Just type Ctrl+Shift+B to run the current python file on your device.

Phillip Ngan
  • 15,482
  • 8
  • 63
  • 79
  • 1
    I get the following error: "ampy : The term 'ampy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again." I've installed ampy using pip and pip3, my interpreter path is set to python 3.6 – Tirna Jul 16 '18 at 20:43
  • @Tirna, check that you can run ampy from the command line terminal. If you can, I don't know why it does not run with the given build task, because all the task does is run the ampy command on the shell. – Phillip Ngan Jul 16 '18 at 22:39
  • When I press ctrl -> shift -> p and select 'MicroPython: Run', it says ampy isn't installed. When I tell it to install, it says it can't and I should 'check my internet connection'. When I type 'pip list' in terminal window, Windows says ampy is installed. – Tirna Jul 17 '18 at 15:56
0

I'd suggest using the pycom pymakr extension. pymakr connects via both serial USB as well as over TCP if your board/firmware can run telnet

Jos Verlinde
  • 1,468
  • 12
  • 25