I probably have a misunderstanding one way or another, so this may be a bad question, but whenever I see sketches of projects that are outputting realtime data or in general, I always see the use of buffers.

For example if you were collecting temperature data in realtime from 3 separate sensors, I could understand using a buffer to first collect those 3 samples, storing them in a buffer, and then outputting that buffer over Serial instead of individually at a time.

But for cases where say you're just sampling a single temperature sensor, I would think you wouldn't need or use a buffer since theres no need to organize the data in such way.

Is there a computational advantage of first reading all values, storing them in a buffer, then outputting the buffer to Serial over just printing the values one at a time in a continuous stream? or am I missing something completely?

closed as unclear what you're asking by Juraj, sempaiscuba, VE7JRO, MichaelT, AltAir Mar 22 at 7:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    for network, SPI, I2C transfer it is better to collect the data into a buffer, because they have an overhead of transport framing bytes. for Serial? where did you see it? – Juraj Mar 8 at 13:53
  • @Juraj this is a small example forum.arduino.cc/index.php?topic=154348.0, maybe the use of buffers is only for incoming data, where you have to wait for the full transmission to complete before evaluating or doing anything with the data? – Dante Biase Mar 8 at 13:59
  • so yes processing a number digit by digitt is hard. much better is to collect the digits and convert them to a number. – Juraj Mar 8 at 14:04
  • ah I see I was overthinking this. Thanks. – Dante Biase Mar 8 at 14:15
  • Serial already uses an output buffer. – Gerben Mar 8 at 15:21