Werid Serial LCD Issue

I am having a very weird issue with my I2C serial LCD.

If I run the "hello world" sketch it works great but my actual project is to read data from the serial port and display it on the LCD.

If I run the sketch on my Uno and keep the Arduino IDE running and the serial monitor open then it works great.

If I close the serial monitor, every time it should display my data, it seems to simply re-initialize and doesn't display anything at all.

I have no idea what is causing the problem, so weird that it works fine with the serial monitor open.

Here is the code, ant ideas?



#define SOP '<'
#define EOP '>'

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

bool started = false;
bool ended = false;

char inData[80];
byte index;

void setup()

void loop()
  // Read all serial data available, as fast as possible
  while(Serial.available() > 0)
    char inChar = Serial.read();
    if(inChar == SOP)
       index = 0;
       inData[index] = '\0';
       started = true;
       ended = false;
    else if(inChar == EOP)
       ended = true;
      if(index < 79)
        inData[index] = inChar;
        inData[index] = '\0';

  // We are here either because all pending serial
  // data has been read OR because an end of
  // packet marker arrived. Which is it?
  if(started && ended)
    // The end of packet marker arrived. Process the packet
    // Serial.println(inData);
    lcd.print(inData); // display the title
    // Reset for the next packet
    started = false;
    ended = false;
    index = 0;
    inData[index] = '\0';

If I run the sketch on my Uno and keep the Arduino IDE running and the serial monitor open then it works great.

Opening / Closing the serial monitor resets the board.
You can also try that with other sketches.

YOu might try to circumvent this by using e.g. putty.exe as terminal iso build in serial monitor.

YOu might try to circumvent this by using e.g. putty.exe as terminal iso build in serial monitor.

That probably won't help. If the Arduino board uses DTR instead of RTS, then the application
accessing the serial port won't matter as the operating system drops DTR when the serial port is opened.
The application does get control prior to this happening so it can't prevent it.
I believe all the official Arduino boards use DTR.
I said "probably" because some operating systems allow modifying this DTR behavior.

When RTS is used, this is not a problem since
RTS is not messed with when the serial port is opened.

Boards that use RTS instead, will not experience
Auto-reset when the serial port is opened and you can open and close the serial
as often as you want with no side effects.

There are some ways to disable auto-reset on the boards that use DTR.
Read the section about "Automatic (Software) Reset":

However, I don't agree with the part in the write up above about this only applying to
Mac OS or Linux, Windows also modifies DTR when the serial port is opened,
depending on which version of windows and how the serial port is configured.
So it is an issue on Windows as well.

--- bill

Wow, thanks Bill the looks like the problem.

Reading through the comments, I found a perl script that might do the trick to save me from having to cut the trace on my board.

I actually couldn't find the info on which trace to cut on the Uno but am so glad I know what the problem is, at least can I do some more investigation.





use strict;
use Device::SerialPort;

my $port = Device::SerialPort->new("/dev/ttyUSB0");


Bummer, i thought i had nailed it, based on your info I found this page that says putting a 10uf capacitor between reset and ground would solve the issue with the Uno.


I rushed out to radioshack and got the capacitor, but now the board doesn't seem to get any serial data.

It didn't say which way to connect the capacitor, I'm presuming the - went to ground and the + to reset.

Any other thoughts?



Are you using a unix machine?
Look up the stty command.
stty -hup
or stty -hupcl

on the port should disable doing modem control signals on opens/closes of the port.

There is another option that will work if you are writing your own application that opens the serial port.
The trick is to create two apps to open the port in non exclusive mode.
The first app is a dummy process that simply opens the port and then goes to sleep.
The real app also must open the port in non exclusive mode.
Since the first app always keeps the port open, the driver modem control will not perform any DTR twiddling.

This technique should work on all the OSes.

There are other 3rd party "arduino" boards out there that provide jumpers to disable auto reset.
Seeeduino is one that has this: Seeeduino v3.0 | Seeed Studio Wiki

---- bill

Thanks, I using OSX to send data to the port using a 3rd party app called arduino-serial.