Weird characters coming over serial port

I'm working on this project with a arduino that has a moisture sensor attached. On the raspi I'm reading the serial/usb connection with python. 2 Things.

  1. sometimes, I know what digit to expect, but sometimes when starting the app and it seems the first read of the serial port, I get extra numbers.

expecting 1042\r\n

getting on first call 101042\r\n

  1. I've also noticed sometime I get this

▒95

Then python crashes.

This is basically the serial code.

serialPort = '/dev/ttyACM0'
ser = serial.Serial(serialPort, 9600, timeout=1)
sensor_data = ser.readline()
print sensor_data

Thanks in advance for any help.

Thanks in advance for any help.

Your problem is on line 47 of your Arduino code. Or, so my crystal ball says. Of course, it's been dropped a few times...