I've written a Java program to read my Arduino's outputs through Serial port (using RXTX Library). There's a small issue I'm facing.

Arduino continuously writes to serial. But every time, after running the Java program I have to reset the Arduino to make the program see the serial port values. Otherwise it won't read any value.

Hope it's clear. I need to know whether there's a way to fix this. How can I make my program to read serial port values when it is started without doing anything to external devices.


EDIT This is the method which'll initialize the serial port.

SerialPort serialPort;
private static final String PORT = "COM32";
private InputStream input;
private static final int TIME_OUT = 2000;
private static final int DATA_RATE = 9600;

public void initialize() {
        CommPortIdentifier portId = null;
        Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
        while (portEnum.hasMoreElements()) {
            CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
            if (currPortId.getName().equals(PORT)) {
                portId = currPortId;
        if (portId == null) {
            System.out.println("Could not find COM port.");
        try {
            serialPort = (SerialPort) portId.open(this.getClass().getName(),

            input = serialPort.getInputStream();
        } catch (Exception e) {
  • \$\begingroup\$ I don't know the specific arduino serial port implementation, but... have you checked flow control settings? \$\endgroup\$ – Axeman Aug 22 '12 at 8:07
  • \$\begingroup\$ The Arduino serial settings are: No flow control, 8 data bits, no parity, and 1 stop bit. Check to make sure your java settings match. \$\endgroup\$ – helloworld922 Aug 22 '12 at 8:19
  • \$\begingroup\$ If arduino has no flow control at all, then IMHO the flow control can't be the thing that stops data flow... \$\endgroup\$ – Axeman Aug 22 '12 at 8:27
  • \$\begingroup\$ @Axeman how can I check the settings. I'll edit the post and include the port initialization method..Thanks! \$\endgroup\$ – Anubis Aug 22 '12 at 8:29
  • \$\begingroup\$ Could it be related to this question on stackoverflow: stackoverflow.com/questions/10382578/… \$\endgroup\$ – Axeman Aug 22 '12 at 8:29

The serial flow control signals (DTR and/or RTS) must be set accordingly to the Arduino specification and to the specification of USB-SERIAL adapter you're using.

Looking briefly at the schematic of your board, I can see that the RTS signal is disconnected, but DTR signal from FTDI chip is coupled with the ATMEGA's RESET pin (I imagine that this is done to allow Arduino uploader to reset the micro and upload new firmware to it).

This means that you have to set DTR signal (in your Java code) to avoid unwanted resets.

  • \$\begingroup\$ Appreciate your help.. \$\endgroup\$ – Anubis Aug 23 '12 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.