Program for LCD printing from Serial input only works if separate program is listening on Serial

Hey all, I'm writing a program for my arduino that will print whatever is sent to the /dev/ttyACM0 (the serial port) device to an LCD. However, the program only works if I have a separate process listening to the /dev/ttyACM* device. i.e.

Process 1 is running tail -f /dev/ttyACM0
Process 2 is running echo "text" > /dev/ttyACM0

I want to get my program to the point where the only thing that is required is process 2. If I run process 2 without process 1 running, the LCD screen gets cleared and nothing prints, although the RX light on the arduino does light up so it is definitely getting data.

Here is my code:

#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

#define SERIAL_BUFFER_SIZE 32

char serial_buffer[SERIAL_BUFFER_SIZE];

void setup() {
	// set up the LCD's number of columns and rows:
	lcd.begin(16, 2);
	lcd.clear();
	Serial.begin(115200);
}	

void loop() {
	if (Serial.available() > 0) {
		// reset buffer
		memset(serial_buffer, 0, SERIAL_BUFFER_SIZE * sizeof(char));
		// line feed (\n) sent at end of tx
		Serial.readBytesUntil('\n', serial_buffer, SERIAL_BUFFER_SIZE);
		//Serial.println(serial_buffer);
		lcd.clear();
		lcd.setCursor(0, 0);
		lcd.print(serial_buffer);
	}
}

The Arduino will reset each time you open the serial connection. Without having the receive side of the connection held open you probably just get a reset each time you send.

You can try disabling the reset by jumpering the Reset pin to +5V to see if that will work for you. If that works, change the jumper to a 10uf capacitor with the + side to Reset and the - side to Gnd. That will absorb the auto-reset pulse without preventing a manual reset. You will want to disconnect the capacitor when uploading.

What board are you using? With echo "text" > /dev/ttyACM0`it obviously isn't an UNO. I tried your code on a Leonardo clone and it works fine with just the echo command.

I did change the LCD interface to use the hd44780ioClass/hd44780_I2Cexp.h library but that shouldn't make a difference. (I have given up on using direct pins and the hassle of the contrast adjust and just use an I2C backpack now.)
[EDIT]
OOPS - I thought that the /deV/ttyACM0 indicated a board with onboard USB support. I forgot that when they moved from the FTDI interface to an AVR interface the port changed from USBx to ACMx on real UNOs. I have been using to many clones :slightly_smiling_face:.

Those are Linux shell commands.

Putting a jumper from reset to 5v worked like a charm. Is there any particular reason I should use the capacitor then? And do you think it would be a better idea to just leave a process listening on the serial port in the background (as I'm doing right now) than mess with the reset pin?

If anyone presses the Reset button it will short the +5V power rail to Ground. Something will likely go pop. Electrical damage may occur.