title: Bad data received from Arduino serial while reading from analog port
body: <p>Maybe this is just a nonsense, but it's driving me crazy. I'm trying to read one analog port in Arduino and send the value through the serial port to JavaScript using node. When I show the data in the Arduino console, everything works fine, but when I use the terminal in Mac, some values appear splited in two lines.</p>
  
  <pre><code>460
  460
  4
  60
  460
  </code></pre>
  
  <p>The code I'm using is:</p>
  
  <p>Arduino:</p>
  
  <pre><code>const int analogInPin = A0;
  int sensorValue = 0;
  
  void setup() {
    Serial.begin(500000);
  }
  
  void loop() {
    sensorValue = analogRead(analogInPin);
    Serial.print(sensorValue);
    delay(200);
  }
  </code></pre>
  
  <p>Node:</p>
  
  <pre><code>var com = require('serialport').SerialPort;
  
  var opts = {baudrate: 500000};
  
  var serialPort = new com('/dev/tty.usbmodem641', opts);
  
  serialPort.on('data', function(data) {
    console.log(data.toString());
  });
  </code></pre>
  
  <p>The code couldn't be simpler, but still doesn't work properly. I know I'm missing something but I can't see it. I have tested different baudrates, but nothings works. Could you please help me?</p>
  
  <p>Thanks in advance</p>