Serial Communication AND Serial Monitor (Port busy)

Hi,

I am using Processing to send data that I am receiving via Arduino using the serial port. The problem is that now I am not able to use the serial monitor of the Arduino IDE anymore! I am getting an error message that says “Port busy”.

To me that makes sense, because the serial monitor tries to access the same port that’s already established between Processing and the Arduino board. But I need to see the values that are being sent! Is there any way to accomplish this? I already find it weird that the Arduino IDE doesn’t work without an Arduino board attached.

Could I have several Serial objects open - e.g. one between Arduino IDE and Processing, the other between Arduino IDE and Arduino?

Here’s my code. It works.

// PROCESSING
import processing.serial.*;

void setup(){
  size( 800, 400 );
 
  //Open the serial port for communication with the Arduino
  String portName = Serial.list()[3];
  myPort = new Serial(this, portName, 9600);
}

void draw(){
  myPort.write("stuff");
}
// ARDUINO
char val; // Data received from the serial port

void setup() {
  Serial.begin(9600);
}

void loop() {
  if (Serial.available()){
    val = Serial.read(); // read it and store it in val
  }
    Serial.println(val);
  delay(10); // Wait 10 milliseconds for next reading
}

I am using an Arduino UNO and MacOS.

Screen Shot 2017-02-27 at 09.37.21.png

The problem is that now I am not able to use the serial monitor of the Arduino IDE anymore!

Do you want to use Processing to send data to the Arduino? Or, do you want to use the Serial Monitor app? Both is the wrong answer. So is yes.

But I need to see the values that are being sent!

Processing can read the serial port and show the data in its output window.

Could I have several Serial objects open - e.g. one between Arduino IDE and Processing, the other between Arduino IDE and Arduino?

No. The IDE isn't even involved in your problem, so this makes no sense. The Serial Monitor and the IDE are two different applications.

Hi and thanks for the reply.

I need to use Processing and Arduino together. Processing fetches cursor positions and sends them to Arduino. For debugging, I need some sort of monitor for when the data is already in the Arduino.

There has to be a way to display values.

For debugging, I need some sort of monitor for when the data is already in the Arduino.

When you call your mates to arrange a get-together for beer, do you need for your wife to listen to their responses? Why can't you listen to their responses?

Processing is making the calls to send data (invites). Processing should, and can, listen to the responses.

:smiley:

So in other words, I have to use Processing's console…?

blar1234:
I need to use Processing and Arduino together. Processing fetches cursor positions and sends them to Arduino. For debugging, I need some sort of monitor for when the data is already in the Arduino.

There has to be a way to display values.

This is a common requirement.

You need to add some code to your Processing program to display the data coming from the Arduino. That way everything is part of the Processing program and there is no need for the Serial Monitor.

...R

I have to use Processing's console…?

Or you could use SoftSerial to communicate with Processing and the Serial monitor to display values from the Arduino. Or you could use an Arduino board with more than one serial interface built in.

So in other words, I have to use Processing's console…?

You may be slow, but you do get there in the end. Must have been the beer talk. 8)