Sketch starts only after opening the serial monitor

Hello everyone,

I have a problem with my Ardunio Uno, I ve connected an RFID reader an the LCD display of seeedstudios. The arduino sketch starts only after opening the serial monitor. When connected to only to the power supply or the usb port the programm doesnt start.

#include <SerialLCD.h>
#include <SoftwareSerial.h>
#include <WiFly.h>	
#include <SoftwareSerial.h>   // for xbee shield v1.1
#ifndef __CREDENTIALS_H__
#define __CREDENTIALS_H__
SoftwareSerial serial2 (3, 4); // for xbee shield v1.1
char passphrase[] = "";
char ssid[] = "camo";
char ntp_server[] = ""; // or your favorite ntp server.
byte server[] = { xxx, xxx, xxx, xxx}; // 
WiFlyClient client("", yy);
#define DEVICE_NAME "Alpha"

SoftwareSerial RFID (10, 11);
int val = 0;
char code[10];
int bytesread = 0;

SerialLCD slcd(12,13);

void setup(void)
 Serial.println("Setup started");
 serial2.begin (9600);  // for xbee shield v1.1
 while (!WiFly.join(ssid)){Serial.println("Association failed.");delay(1000);}
 // RFID
 RFID.begin (9600);
 Serial.println("Setup finished");

void loop(void)
Serial.println("Loop started");

if(RFID.available() > 0) { // if data available from reader
if((val = == 2) { // check for header
bytesread = 0;
while(bytesread<10) { // read 10 digit code

if( RFID.available() > 0) {

val =;

if((val == 2)||(val == 3)) { // if header or stop bytes before the 10 digit reading

break; // stop reading

code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
if(bytesread == 10) { // if 10 digit read is complete
 	Serial.print("TAG code is: "); // possibly a good TAG
 	Serial.println(code); // print the TAG code
 	if (client.connect ())
     	client.print ("get");
     	client.print (DEVICE_NAME);
     	client.print ("/RackNr/");
     	client.print (code);
     	slcd.print (code);
     	Serial.println("RackNr on Display!");
     	Serial.println("Message sent!");
     	client.stop ();
     	delay (2000);
   bytesread = 0;


Would be great to find a solution for this. Thanks!

The arduino sketch starts only after opening the serial monitor.

Is that still the case if you comment out all the Serial method calls?

Including SoftwareSerial.h once is usually sufficient.

The #define/#endif guard to prevent multiple inclusions is hardly needed in the sketch.

The SerialLCD class is using SoftwareSerial, too. Multiple instances of SoftwareSerial need to be used with care. Only one instance at a time can listen. You need to be sure to make the RFID-reader active again after EVERY call to write to the LCD.

Having three instances of SoftwareSerial as well as an instance of HardwareSerial is a sure sign that you are using the wrong hardware.

Hi Pauls,

I disabled the LCD display. This is not really necessary for the application. Now the RFID reader works fine.

I will try to include the LCD again later.

Thank you for the help!