Skip to content
Greg edited this page Oct 25, 2018 · 12 revisions

This code is a simple Arduino-based data logger. The Arduino (UNO for instance) should be connected to:

  • A real time clock DS3231 (RTC) module (I2C interface). [Note The DS3231 module is more accurate than the DS1307]
  • A SD card reader (with SPI interface).
  • an SSD1306 OLED display (I2C interface)

The systems monitors any change of state of a digital pin (here #2) of the Arduino, and writes the time and date of each change to the SD card (file "data.txt"). As a bonus, the temperature (from the internal temperature sensor of DS3231) is also written to the file. When booting, if the file "data.txt" does not exist, it is created. Otherwise the data are appended to it.

It is also possible to set the time and date of the RTC using a special file on the SD card ("setdate.txt" - see the code for the format). Finally, at each change of the input pin, the time is also printed on the OLED display.

Libraries

The code is based on the following libraries

  • SdFat : Library to access the SD card
  • Wire : Library for I2C bus communication (with the RTC module)
  • DS3231 : Real-time clock (RTC) module library
  • SPI : Library for SPI bus communication (with the SD card reader)
  • SSD1306Ascii and SSD1306AsciiWire: ASCII-only (uses less memory than graphical versions) OLED display library. Link: github.com/greiman/SSD1306Ascii
Clone this wiki locally