Sending Packets of Serial data


I am working on an Arduino project where I have to send values for time, position, and measurement data frequently to Matlab for post-processing. Is there any way I can send them all as one object (like a packet) and have Matlab pick it up? I know how to send one measurement at a time, but I couldn't find anything that would allow me send a few different values all at once.

I'm pretty new to this so I really appreciate your guidance and patience!

Sure just Serial.print them one after another. Serial data only goes out one byte at a time. The concept of a packet is an agreement between the sender and receiver. The receiver relies on the fact that the sender will send all of some set of particular things in some order. Then we call it a data packet. It's nothing special about how the data is formatted, just that the sender and receiver have agreed on some format. Since you are writing the code on both ends, you get to decide, for example, does the temperature come first or the pressure and then write the receiving code to expect things in that order.

^ agreed..

Also.. maybe think of sending an SOP and an EOP (start of packet and end of packet) character so you know when and what to parse...

theres an example in the second/third post here:,124394.0.html

but I couldn’t find anything that would allow me send a few different values all at once.

Do you really need to do that? Is that the way Matlab demands its data?

Maybe the reason why you couldn’t find anything is because it’s a pointless exercise.

I suggest you read Nick Gammon's excellent discussion of moving data over serial/Arduino HERE: