Arduino Sensor data Logging

I am currently using a Teensy 3.2 to log data from a sensor. My current strategy is to print the sensor data onto the serial port using a 115200 Baud rate. I then use Putty to log the serial data into a CSV file.

The serial port really limits the amount of data samples I can log per second. I want to log as fast as I can. Ideally, I would like to log as fast as I sample the sensor data, but I believe that may be too difficult without an RTOS.

In general, what are the best ways to log data as quickly as possible. I have seen two approaches so far:

1. Use an SD card and write to the SD card. After this, convert that data to a CSV.

2. Store all the data in an array, and then serial.println the array and log that into putty. Writing to the array should be faster, and thus you can collect more data points.

Are there any other ways to go about this? Do you think just writing straight to a CSV as opposed to the serial port would be faster?

Thanks

• I want to log as fast as I can. Ideally, I would like to log as fast as I sample the sensor data ... why don't you simply say how fast you would like to log? Jul 2 at 1:30
• The virtual com port via USB (CDC) is not limited to 115200. You can set 1MBit or more.
– Jens
Jul 2 at 3:00
• The teensy has a usb interface that is emulating a com port, it should be capable of data rates well in excess of 115200bps, and in fact the configured data rate probably doesn’t make a difference to the speed (I’m willing to be wrong on that last bit). Have you tried benchmarking it? Jul 2 at 3:02
• @Bryan 12 MBit is physical limit of Teensy 3.2, the other end may have other limits. Yes, the configured baudrate is irrelevant, available USB timing is used.
– Jens
Jul 2 at 3:05
• It is difficult to estimate how much data there is per sample and where can you save bytes. Is it 8-bit samples, 10-bit or what? Do you print it in decimal, hex, base64, or what? Is there one sample per line? Do you use one or two bytes for end-of-line marker? Jul 2 at 7:27