I2SD Hello World!

Photo by FlorinC

So WyoLum is working on the I2SD. This is a SD card interface that sits on the I2C bus, also known as the Two Wire Interface or TWI.  We created the board so that we could add an SD card to ClockTHREE and ClockTHREEjr .  But while we were at it, we made this board as useful as we could so that it can be used in several applications.

Features:

  • Can be used as a stand alone data logger.
  • Arduino Shield adding real time clock and SD to any Arduino.  This saves 8KB of program memory over just using the SD library.
  • Chronodot compatible! This means you can add an SD card to any project that already has a ChronoDot slot.
  • Integrated Real time clock.
  • Two LEDs, no WyoLum project is complete without LEDs.

 

Hello World

Required Parts

  1. Arduino
  2. I2SD

Steps

  1. Write a long file to the SD card called “TEST.TXT”  For example this one.
  2. Connect I2SD to the Arduino.
  3. Upload code below to the Arduino.
  4. Monitor the serial port on the Arduino.

If everything goes right, the file on the SD card should stream through the serial port on the Arduino.  If an error occurs, an “error code” will flash on the I2SD.  This is all pretty new, so you may encounter unforeseen situations.  If so, just let me know and I will address them as soon as I can.

The Code

/*
Read and write some data to the I2SD
*/

#include "C3SB.h"
#include "I2SD.h"
#include "SD.h"
#include "Wire.h"
const boolean WRITE_TEST = true;
const int DBG = 13;

I2SD i2sd;

void setup(){
  uint8_t msg_back[100];
  unsigned long n_byte;

  Serial.begin(57600);
  Wire.begin(); // DON'T FORGET THIS!!!!

// wait for I2SD hardware to start up
  Serial.println("PING...");
  while(!i2sd.ping((uint8_t*)"PING", 4)){
    delay(100);
  }
  Serial.println("PONG received");

  i2sd.open("TEST.TXT", FILE_READ);
}

void loop(){
  const int n_byte = 32 * 7;
  char big_data[n_byte];

  i2sd.read((uint8_t*)big_data, n_byte);
  Serial.print(big_data);
}

Leave a Reply