write a byte array of various data types

Is there any way to write multiple data types (in bytes) into the same array using the arduino library? It would be like JAVA's OutPutStream, ArrayOutPutStream. I would like to add data of various types automatically and have an array of bytes. THANKSS :slight_smile:

Yes. How comfortable are you of implementing it?

Yes, I developed a java application to send data via post http from a datalogger, now I want to make a similar application for arduino, but as I don't want to modify the server I prefer to send the data the old way, a byte array containing char, float, int, long. I would like a simpler way to concatenate all this data, using arrayoutputstrem in java was easy. I hope you understand my english. thanks.

Are the types fixed in the byte array?
for example, your array always contains: char, float, not, long?

Yess. Should I use struct ?

To avoid a language confusion, I will ask you to explain further what you mean when you said, "write multiple data types (in bytes) into the same array". Please give an example of the multiple data types and an example of how the array might look in your mind, ignoring syntax rules for now.

Ok.

8 bytes - timestamp - uint64_t
2 bytes - sizeof(name) - uint16_t
x bytes - name - char[]
4 bytes - value - float
.
.
.

Something like this.

So, i need use the serial.write(), and send all this data in the same time.

I've answered this question for you multiple times:
https://forum.arduino.cc/index.php?topic=636835.msg4311439#msg4311439
https://forum.arduino.cc/index.php?topic=636803.msg4311162#msg4311162