SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By CountVlad
#170399
Hi,
I'm very new to the arduino world so please bear with me. I've recently purchased an Arduino Mega 2560, LS20031 GPS, 9DOF Stick and an OpenLog SD card in order to record an RC plane flight. Unfortunately I'm unable to get the OpenLog card to record/store any files.

I've wired the chip according to the instructions where I've only used the RX on the board to connect to Pin 53 on the Mega board. Since I'm not looking to access files on the card I figured I wouldnt need to wire the TX pin.

I've tried numerous codes that I've found online but with no success. However, every single one of them had code written in such way that it would initialize the card then either write or open a file. Since there isnt an arduino TX pin to the OpenLog I'm not really sure if I have to wire it or not.

Could someone please provide me with a simple code to check or write on the sd card?

Thank you
By CountVlad
#170417
According to everything that I've read pin 53 is the SS pin on the Mega board.

If there are other suggestions on which way to wire would be greatly appreciated.
By Mee_n_Mac
#170419
Why use the SS pin ? For any device you want the serial out (Tx) of the device to be connected to the serial in (Rx) of the logger. From the Arduino product page:
http://arduino.cc/en/Main/ArduinoBoardMega2560
Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX) and 16 (TX); Serial 3: 15 (RX) and 14 (TX). Used to receive (RX) and transmit (TX) TTL serial data. Pins 0 and 1 are also connected to the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip.

So skip using the serial port shared w/the USB connection and use Serial1, 2 or 3 (and code appropriately). That would be pins 18, 16 or 14 repectively.

http://arduino.cc/en/Reference/Serial
The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). To use these pins to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega's USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Mega to your device's ground.

http://arduino.cc/en/Serial/Begin
Arduino Mega only:
Serial1.begin(speed)
Serial2.begin(speed)
Serial3.begin(speed)
Serial1.begin(speed, config)
Serial2.begin(speed, config)
Serial3.begin(speed, config)


Note how the code is told which serial port/pins to use above, by using SerialX.cmd, where X denotes the port.
By CountVlad
#170457
so i've tried your advice but without success.

Maybe i'm missing something, maybe the wiring is not right.

OpenLog --- Arduino
VCC to 3 or 5V
BLK to GND
RXI to TX(I've tried pin 1,14,16,18)
Code: Select all
/*
4-14-2010
SparkFun Electronics 2012
Nathan Seidle
This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
This is a simple test sketch for OpenLog. It sends a large batch of characters to the serial port at 9600bps.
Original test was recomended by ScottH on issue #12:
http://github.com/nseidle/OpenLog/issues#issue/12
Arduino TX to OpenLog RXI
Arduino 5V to OpenLog VCC
Arduino GND to OpenLog GND
To use this sketch, attach RXI pin of OpenLog to TX pin on Arduino. Power OpenLog from 5V (or 3.3V) and GND pins from Arduino.
After power up, OpenLog will start flashing (indicating it's receiving characters). It takes about 1 minute for
the sketch to run to completion. This will create a file that looks like this:
...
6:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#
7:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#
8:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#
9:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#
#:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#
1:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#
2:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#
...
The reason for creating these character blocks is it allows for a reader to very quickly scan the visible characters and
indentify any byte errors or glitches along the way. Every 9 lines we print a 10th line that has a leading character
such as # or !. These allow us to quickly see the different blocks of 10 lines.
Note: Bootloading an Arduino will cause OpenLog to drop to command mode. This is because OpenLog is looking for the
escape character (ctrl+z). During a bootload, all sorts of characters get sent to the Arduino and therefore ctrl+z is likely
to get sent to OpenLog. v1.51 of the OpenLog firmware fixes this potential error by requiring three escape characters.
*/

void setup()
{

  Serial.begin(9600); //9600bps is default for OpenLog
  Serial1.begin(9600);
  Serial2.begin(9600);
  Serial3.begin(9600);
  
  //Serial.begin(57600); //Much faster serial, used for testing buffer overruns on OpenLog
  //Serial.begin(115200); //Much faster serial, used for testing buffer overruns on OpenLog

  delay(1000); //Wait a second for OpenLog to init

  Serial.println();
  Serial.println("Run OpenLog Test");
  Serial1.println("Run OpenLog Test");
  Serial2.println("Run OpenLog Test");
  Serial3.println("Run OpenLog Test");


  int testAmt = 2;

  //Each test is 100 lines. 10 tests is 1000 lines (11,000 characters)
  for(int numofTests = 0 ; numofTests < testAmt ; numofTests++)
  {
    //This loop will print 100 lines of 110 characters each
    for(int k = 33; k < 43 ; k++)
    {
      //Print one line of 110 characters with marker in the front (markers go from '!' to '*')
      Serial.write(k); //Print the ASCII value directly: ! then " then #, etc
      Serial.println(":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#");
      Serial1.println(":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#");
      Serial2.println(":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#");
      Serial3.println(":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#");
      
      //delay(50);

      //Then print 9 lines of 110 characters with new line at the end of the line
      for(int i = 1 ; i < 10 ; i++)
      {
        Serial.print(i, DEC);
        Serial.println(":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#");
        Serial1.println(":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#");
        Serial2.println(":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#");
        Serial3.println(":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!#");
      
        //delay(50);
      }

    }
  } //End numofTests loop

  unsigned long totalCharacters = (long)testAmt * 100 * 110;
  Serial.print("Characters pushed: ");
  Serial.println(totalCharacters);
  Serial.print("Time taken (s): ");
  Serial.println(millis()/1000);
  Serial.println("Done!");
}

void loop()
{

} 
By CountVlad
#170513
Found the issue:

The 8 Gb card did not work although i followed the formatting instructions, etc. I used a different card (512MB) and worked right away. Lame