Trouble with multiple COM ports -import processing.serial.*;

I am trying to do a data gathering system on the PC. I was planning to use 5 or more HC-06 bluetooth dongles on arduinos and start receiving data in Processing.
The system worked fine for one device I could talk back and fourth - no problem.
As soon as I added the second BT port I get
RuntimeException: Error opening serial port COM16: Port busy

If I try starting the sketch about 5 times, it will start.
But if I ad more ports it does not start. Everytime, one COM or the other is "Busy’.
I did not start the data streaming from the Arduinos before connecting. I could see how that can confuse the system.
It is said that Win10 can assign 255 COM PORTS. I barely get to use 2?

I have a powerful laptop with 16 g of ram and GPU.
I am sure there is a glitch somewhere. The Ports are not busy. There is not other data streaming. Nor another App uses them.
Here is the code:

import processing.serial.*;

Serial myPort0;  // Create object from Serial class
Serial myPort1; 
Serial myPort2; 
Serial myPort3; 
Serial myPort4; 

int val0, val1, val2, val3, val4;      // Data received from the serial port

void setup() 
  size(700, 700);

  String portName = Serial.list()[0];
   myPort0 = new Serial(this, "COM16", 9600);
   myPort1 = new Serial(this, "COM18", 9600);
  //myPort2 = new Serial(this, "COM14", 9600);
 // myPort3 = new Serial(this, "COM15", 9600);
   //myPort4 = new Serial(this, "COM15", 9600);

void draw()
  if ( myPort0.available() > 0) {  // If data is available,
    val0 =; 
     println("VALUES: "+val0+"  "+val1+"  "+val2+"  "+val3+"  "+val4);
    if ( myPort1.available() > 0) {  // If data is available,
    val1 =;         // read it and store it in val
 // /*
      if ( myPort2.available() > 0) {  // If data is available,
    val2 =;         // read it and store it in val
//  */


void mousePressed() {
  if (mouseButton == LEFT) {
  } else if (mouseButton == RIGHT) {
   // myPort2.clear();
   // myPort2.stop();

After further research I found out that Win10 is keeping the COM ports busy so when you plug and unplug devices the same COM no is assigned.
So when processing starts that “reservation” keeps it from opening the COM port. Sounds really stupid, but that is how it is. I found a tool made by a guy in Germany that frees the ports . You’d have to do it over and over before running each sketch.
I gave up. I must find other ways.
This article explains the whole stupidity.

However: Processing does not have the same problem with real USB connections (Meaning not wireless BT devices that get assigned COM PORTS).
So there is a glitch in Processing that prevents it from connecting to ports assigned by the Win for Bluetooth devices. I wonder if someone can fix that.

Here is the tool to free the ports


1 Like

And Some good news:
They sketch works perfectly on my Mac OSX 10.12

Go mac forever, it saved the project.

I would appreciate feedback on how to make it work on win 10
Till then:
Mac Forever!!!

Glad you were able to work around it by running on Mac.

Is this issue on Win10 something specific to the Processing serial library? If you wish to open an issue with the developers, I believe that the source is in the main Processing repo: