Good practice for sending data from Arduino to Processing

there are many ways, but for datasets i use CSV style,

1024,1024,1024,1024,

per line what actually requires good documentation what data is what sensor…
and it is faster insofar as the line sending and line catching via serial/USB
( you would send 4 lines )
takes more time as the string separation.
( your way also needs that value decoding… )

but there are many other way,
the fastest still would be a byte stream ( not ASCII ) but i hate, as i can not read it in
Arduino IDE terminal
the slowest would be a full text way what i actually can recommend,
it is a JSON record

{ "unit1" : { "S1" : 1024 , "S2" : 1024, "S3" : 1024, "S4" : 1024 }, "unit2" : {....} }

so sending a lot of “redundant” text looks like a waste of “bandwidth”…
but is very clear, readable for us and a JSON function from reading to saving to file…
there is a kind of frame check ( too short lines would be rejected… )

is this to slow for you??
well why not run with

 Serial.begin(57600);

if you need slow 9600Bd to get connection you have heavy cable issues
like free wiring or too long cable…

1 Like