I want to launch a communication between two Arduinos, in which case the first Arduino (S) sends data to the second one (R). The type of the data is mixed, consisting of integers, longs, floats and maybe some text. For example:
{125, 1250, 12500, 125000, 1.25, 12.5, 125.0, "some text"}
I thought about converting each one value to string, adding up all strings to a big one, and send the final string with
Serial.print(Big_string)
. In that case I reckon that it would be difficult for the Receiver to extract the string to the exact substrings and convert them to real values.A second thought was to convert all values to bytes and create a byte (or char) array, but each value would be limited to 0-255 (let alone floats and text)
A third thought was to convert them to word type (let alone the text), but I think that
Serial.print( )
sends only bytes, not words.
In any case, which is the best way to send mixed data over serial?
Any thoughts would be appreciated.