0
\$\begingroup\$

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,

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Is there also a way of sending the data in a byte array or packets? \$\endgroup\$ – Seeerdar Sep 5 '14 at 11:21
  • \$\begingroup\$ The problem I see with sending raw binary data is that all possible byte values can be valid data, so it is difficult to see how to mark start-of-data to keep sender and receiver in sync. Some microcontroller UARTs can use a nineth bit as a command flag, but I don't think the usual PC/USB UARTs can handle that. \$\endgroup\$ – Peter Bennett Sep 6 '14 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.