First character of serial data print being replaced

Hi,

Just pulled up an old project and began serial data to help with some sanity checks.

It seems every time it is started or reset, the first character of the serial data is replaced with an ASCII character, in this case ‘S’ is constantly being replaced with ‘|’ (not capital i).

When this line is omitted from the sketch, ‘EL Online’ will print with the ASCII character ‘ÿ’ before it on the same line.

The sketch is very long so I’ve attached the setup. Has anyone any ideas?

  void setup() {
  pinMode(latchDevice, OUTPUT);
  pinMode(indLED, OUTPUT);
  pinMode(programSwitch, INPUT);
  pinMode(pinClr, INPUT);
  pinMode(clearLED, OUTPUT);
  pinMode(appPWR, OUTPUT);
  pinMode(resetButton, INPUT);
  pinMode(10, OUTPUT);
  
Serial.begin(9600);  
 Serial.println("Soter AMS build");
 
 if (digitalRead(pinClr) == HIGH) {
    for (int i = 0; i < 512; i++)
      EEPROM.write(i, 0);
    digitalWrite(clearLED, HIGH);
  }
  value = EEPROM.read(address);

  myFile.close();

  int stateOne = digitalRead(programSwitch);
  int stateTwo = digitalRead(resetButton);

  if (!SD.begin(4)) {
    Serial.println("EL Failure");
    return;
  }
  Serial.println("EL Online"); 

  Ethernet.begin(mac, ip);
  server.begin();
  //Serial.print("Server Established ");
  Serial.println(Ethernet.localIP());  
  Udp.begin(localPort);

  if (stateOne == 0 && stateTwo == 0) {
    b=0;
    if (EEPROM.read (0) != 0xff) {
      for (int i = 0; i < maximumPulses; ++i )
        storedCode[i] = EEPROM.read (i);
    }
  }
  if (value >= 1) {
    digitalWrite(appPWR, HIGH);   
    Serial.println("SP Exists"); 
  }
  else {
    digitalWrite(appPWR, LOW); 
    Serial.println("SP Empty"); 
  }
  delay(100);// added in v3 for delay in sensor rail 2 bug
}

Regards,
B

Please post your whole program or a smaller one that exhibits the problem. Which Arduino are you using ? How much memory does the program use ?

When this line is omitted from the sketch

What line?

benzure:
<…>
It seems every time it is started or reset, the first character of the serial data is replaced with an ASCII character, in this case ‘S’ is constantly being replaced with ‘|’ (not capital i).
<…>

Far Out guess:
SD cards may cause power “dips” if the bulk capacitor on the PS is not sufficient; “dips” on the uC can cause noise which maybe manifest as characters in the output,(or input) serial buffer.

Try Serial.flush() after .begin() but before the first Serial.print()

Also, if you have a scope, take a view of Vcc to Gnd when resetting uC.