How to see print() output and REPL from VSCode?

  • I followed all the instructions to install VSCode on Windows, and the M5Stack plugin for VSCode, I am able to blink the LED on my M5Stick-C so far.

    How can I view the outputs of my print statements?

    How can I use the MicroPython REPL?

    The "OUTPUT" tab of VSCode is always blank, and none of these options shows me the REPL or serial print output


    The "TERMINAL" tab is always showing me Windows Powershell

    When VSCode is connected to the M5Stick, no other serial port terminal program (such as Putty, TeraTerm, RealTerm, etc) is able to access the COM port. I cannot just run some sort of command line serial port terminal through Powershell since the port is occupied

    If I disconnect VSCode, I get the error 0_1653536701744_1b8925ae-9caf-49e5-83f9-587e178273cd-image.png , so disconnecting to use an external terminal app is not an option

    I feel like I am missing something obvious... Please help me view my print output from within VSCode without disconnecting the COM port

  • @robalstona said in How to see print() output and REPL from VSCode?:

    Try this extension

    Thanks I have already installed that. Where in that extension can you see serial port print output while simultaneously being able to access the files?

  • I have the same problem Frank. I have yet to be able to do this. It's very frustrating and a real limitation of the devices IMHO. I really wish they would make this work as they hardware is perfect for small IOT devices, or if there is some way to do it they would TELL US!

    As a work around I set up an MQTT publish to send the equivalent of print statements to a MQTT mosquitto server so I can subscribe and read them on another device . Here's an example of the micropython below. Note that I run mqtt.start() in the because I am also using subscribe in main app for another purpose.

    Note that you need to supply the ip of the mqtt server. And choose your own topic of course
    It should act like a real print statement so you can mix and match object types, plus I added a "name" argument so you can specify where the code is coming from . The print statement prints "{name} -- {print contents}

    Tailor to suit .

    from mprint import *
        b= 29       
        mPrint("slope: {}, intercept: {}".format(m,b))
    except Exception as e:

    from m5mqtt import M5mqtt
    import io
    	mqtt = M5mqtt('servo','192.168.x.x', 1883,'','',300)
    def mPrint(*args,name =__name__,**kwargs):
    	outs = ptos(*args,**kwargs)
    	x="{}  -- {}".format(name,outs)
    def ptos(*args,**kwargs):
    	output = io.StringIO()
    	print(*args, file=output, **kwargs)
    	contents = output.getvalue()
    	return contents
    if __name__ == "flow.m5ucloud":
    	mPrint("test message")

  • While not quite the same, on the Core 2, Tough and Fire boards you can use Advanced > BLE UART in UIFlow (or the equivalent Micropython/ Arduino/ESP-IDF/Zephyr code) to wirelessly send logs to any Nordic BLE UART terminal, including web NUS consoles like

    Just visit that page on a BLE enabled desktop using Chrome or Firefox and pair your device once it has BLE UART running. Even works to send commands back to the M5stack if you set up receiving in your esp32 app.

  • Currently my solution is that I wrote software that tunnels data between a virtual serial port and a real one, while displaying it to me. It uses com0com to setup the fake serial port.

    Basically, m5stick is COM4, com0com is configured with fake COM6 and COM7. COM6 is connected to COM4 via my app and I can see the text in between them and inject keystroke too. VSCode talks with COM7 and all of the data from COM7 goes to COM6, to my screen, then to COM4

    I also coded it so if I hit ESC, it sends the CTRL-C signal to the terminal so it brings up REPL. (pressing CTRL-C will quit the whole terminal lol)

    This solution still sucks, exceptions are still printed to the LCD instead of to the COM port