Python to Arduino connection problem

  • I’m new to both Python and Notepad++ so my apologies in advance if this a simple fix. I’m using a simple sketch running on the Arduino that’s looping a counter and outputting a string through the serial port (COM3). In Python the script is monitoring that serial port for activity and printing the strings as they come in. If I run the script in VIDLE it works perfectly and I see the strings come across immediately. If I run it in the Notepad console I’ll get the Python initialization and then it stays blank for about 60 seconds and then I’ll see a burst of about 60 strings and then it halts. Another 60 seconds goes by then another burst. It seems like in Notepad the COM3 port is “clogged” then it just opens up for a brief second then shuts down again. Or maybe something else completed different. Anyone have an idea as to what;s happening here?


  • Hello @Michael-Williams,

    what do you mean by notepad++ console?
    How do you execute your python script?


  • Claudia,

    The NppExec plugin has a “Show Console” option where you’re provided a console screen in NotePad to view the script running. NppExec also has an Execute option where you can input the following:

    C:\Python27\python.exe “$(FILE_NAME)”

    Then you can assign a macro to run this Execute command on the active script.

  • Hello Michael,

    just for your information, nppexecs console is not really a console like the cmd.
    It tries to behave the same but it isn’t.
    Regarding your problem, I assume you have to call python with -u switch to get
    unbuffered results like

     C:\Python27\python.exe -u "$(FILE_NAME)"

    or you might override pythons sys.stdout with an unbuffered version. But I would give
    the -u switch the first try.


  • Baddabing! The -u solved the problem. Thanks Claudia!

Log in to reply