Writing data over Serial comm //Arduino & MPU6050 gyro+accelerometer

arduinoci2cprocessingserial

I'm new to serial communication and I am just scratching the surface, therefore please bare with me.

What I need to accomplish is the transfer of the gyroscope data I gather on my Arduino to Processing on my Macbook. I already have the code ready that reads my gyro/accel data, applies a complementary filter and outputs this to the serial monitor as a string.

I'd like to learn how to send this data directly from the Arduino to Processing.

  • What would be the most effective way of sending data that can be positive and negative over serial?
  • I've searched around and came across using strings over serial and read/split them in Processing. I'm not a fan of this method. HighByte& lowByte and float/char byte array seems as an alternative but gets too complicated for my current knowledge and understanding.

It would be great if someone could push me in the right direction or just help me altogether with learning serial communication and sending/reading data from a Arduino to Macbook/Processing app. I know in theory whats going on inside but code-wise i'm kinda lost.

Thanks in advance,

Best Answer

My preference is to use plain text for such data transfers - you can read the data with a terminal program to verify that the Arduino is sending what you think (or not!) to help isolate any problems.

I use a simple protocol (actually based on NMEA-0183) - form the data into "sentences", with a start-of-sentence character that won't occur in the data (I usually use "$"), then send the data items separated by commas, and ending with a newline or CR/LF.