I was wondering which performs better? So i m sending integers over a wifi module, using Serial.print() which sends the integers as a string of characters. I can read these integers on matlab directly. I was wondering would splitting up the integers into individual bytes and sending via Serial.write() be faster or is there any particular reason why i should do it instead of Serial.print()?
write has always performed better for me. It isn't as apparent with the Serial functions as it is with the ethernet functions.
You can use Serial.print() to write an array of bytes. Those byte could represent binary integers.
Or use Serial.write() directly.
Using a binary integer is faster than a string. I would try it.
int x; Serial.write( highByte( x)); Serial.write( lowByte( x)); byte h = Serial.read(); byte l = Serial.read(); int y = word( h, l);
Thank you for the responses. For my task it appears that serial.write performs better for integers because its less overhead. eg an integer of 345 would be 2 bytes but sending as a string via serial.print is around 5 bytes.
So i m sending 3600 integers meaning it equates to about 8000 bytes with write, but sending as print is around 20000 bytes.