Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Continuous Logging

thenickdude edited this page · 12 revisions

How can I achieve continuous logging?

There are multiple reports of users having problems with logs containing dropped characters at baud rates above 9600bps. Here are some tips and tricks to get more of your characters logged at higher baud rates.

Format your card
Remember to use a clean card with few or no files on it. A microSD card with 3.1GB worth of ZIP files or MP3s has a slower response time than an empty card.

Add delays between character writes
By adding a small delay between Serial.print() statements you can give OpenLog a chance to record its current buffer. For example:

for(int i = 1 ; i < 10 ; i++) {
    Serial.print(i, DEC);     

May not work because there are a lot of characters being sent right next to each other.
for(int i = 1 ; i < 10 ; i++) {
    Serial.print(i, DEC);     

Inserting a small delay of 15ms between large character writes will help OpenLog record without dropping characters.

Use 9600 baud
OpenLog in based on the ATmega328 and has a limited amount of RAM (2048 bytes). When you send serial characters to OpenLog these characters get buffered. The SD Group Simplified Specification allows an SD card to take up to 250ms (section Write) to record a data block to flash memory.
At 9600bps that is 960 bytes (10 bits per byte) per second. That is 1.04ms per byte. OpenLog currently uses a 512 byte receive buffer so it can buffer about 500ms of characters. This allows OpenLog to successfully receive all characters coming in at 9600bps. As you increase the baud rate, let’s see how long our buffer will last:

  • 9600bps = 1.04ms per byte = 532ms before buffer is overrun
  • 57600bps = 0.174ms per byte = 88ms before buffer is overrun
  • 115200bps = 0.087ms per byte = 44ms before buffer is overrun

Most SD cards have a faster record time than 250ms but you won’t know ahead of time. This response time can be affected by the ‘class’ of the card and by how much data is already on the card. The solution is to use a lower baud rate or increase the amount of time between the characters sent at the higher baud rate. There have also been discussions of moving to an external RAM solution.

This card works but this one doesn’t
There are many different types of card manufacturers, relabeled cards, card sizes, and card classes. It’s maddening. We always use a regular, generic, 1GB microSD card. It works great for us at 9600bps. If you need higher baud rates you may want to try larger, class 6 and above cards. We cannot guarantee that a faster card will work better – the problem is very spotty and hard to track down.

Related Issues
Be sure to search the current and past Issues to see if other people have had the same issue.

OpenLog Wiki Pages:

Something went wrong with that request. Please try again.