serial monitor only shows output when I press reset

I am trying to transfer data between to Arduino’s using serial. It works fine, but only when I push reset on the sender does the serial monitor show the received data, which is correct.

Send code:

// Arduino Serial Example #1 Remote Control Blink - Master
 
void setup() 
{
    Serial.begin(9600);  
    // wait for the serial port to connect. Required for Leonardo/Micro native USB port only
    //while (!Serial1) {  ;  }
     Serial.write("n201409181111");
}
 
 
void loop() 
{
  delay(340);
sendStuff();
  }

int sendStuff(){  
  Serial.write("n201409181111");
  return 0;
}

Receive code:

// Arduino Serial Example #1 Remote Control Blink - Slave
 #include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 13); // RX, TX
//char c  = ' ';
byte LED = 13;
 String data;
char command = 'q';
int left = 0;
int right = 0;
int left_pwm = 0;
int right_pwm = 0;
int s = 0;
void setup() 
{
   pinMode(LED, OUTPUT);
   mySerial.begin(9600);
   Serial.begin(9600);
   Serial.println("START");
}
 
 
void loop()
{
   if(mySerial.available())
   {
    data = mySerial.readString();
sscanf(data.c_str(), "%c%04d%02d%02d%02d%02d", &command, &left, &right, &left_pwm, &right_pwm,&s);
       Serial.print(command);
    Serial.print(left);
    Serial.print(right);
    Serial.print(left_pwm);
    
    Serial.print(right_pwm);
    Serial.println(s);
    //  Serial.println(data);
   }
 
}

I am completely baffled by this. Thank you

you should really follow the tutorial of robin2 how to read data from serial and how to process the data

@noiasca

Okay, thanks, it works thus far.

readString() will read characters from the serial interfaced until a timeout occurs. (see Timeout) the timeout is 1000 msec by default.

if you keep sending characters before the timeout is reached, it may not return

why don't you try changing you delay from 340 to 2000?

Download a version of ide from a few years ago and give it a whirl. I too have had weird issues with serial monitor all summer. So far all have been with eps8266 devices.