openLog and Arduino

Hi I’m new in Arduino and openlog I want to use them with a project to keep data from sensors. I have download all the necessary files to test my openlog I have tried all the suggested connections but the only thing I have managed to see written to the SD card, is the config file some txt files "log000300" and so on. Is there any literature or sketch that will teach me how to use it? Please can you help me?

What are you doing to test it? Have you tried sending it any data, or sending it into command mode?

First I run the sketch from the openLog file “OpenLog_CommandTest nothing happens, it just makes the config file and a LOG00325.txt
Then the OpenLog_ReadExample that I insert some Serial.prinln step to monitor the process

/*
 /*
 2-22-2012
 SparkFun Electronics 2011
 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 an exampe of writing to a file then read from a file contain OpenLog
 
 Connect the following OpenLog to Arduino:
 TXO of OpenLog to pin 3 on the Arduino
 RXI to 3
 GRN to 4
 VCC to 5V
 GND to GND
 
 This example code assumes the OpenLog is set to operate at 9600bps in NewLog mode, meaning OpenLog 
 should power up and output '12<'. This code then sends the three escape characters and then sends 
 the commands to create a new random file called log###.txt where ### is a random number from 0 to 999.
 The example code will then read back the random file and print it to the serial terminal.
 
 This code assume OpenLog is in the default state of 9600bps with ASCII-26 as the esacape character.
 If you're unsure, make sure the config.txt file contains the following: 9600,26,3,0
 
 Be careful when sending commands to OpenLog. println() sends extra newline characters that 
 cause problems with the command parser. The new v2.51 ignores \n commands so it should be easier to 
 talk to on the command prompt level. This example code works with all OpenLog v2 and higher.
 
 */

#include <SoftwareSerial.h>

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//Connect TXO of OpenLog to pin 3, RXI to pin 2
SoftwareSerial OpenLog(3, 2); //Soft RX on 3, Soft TX out on 2
//SoftwareSerial(rxPin, txPin)

int resetOpenLog = 4; //This pin resets OpenLog. Connect pin 4 to pin GRN on OpenLog.
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

int statLED = 13;

float dummyVoltage = 3.50; //This just shows to to write variables to OpenLog

void setup() {                
  pinMode(statLED, OUTPUT);
  Serial.begin(9600);

  setupOpenLog(); //Resets logger and waits for the '<' I'm alive character
  Serial.println("OpenLog online");
}

void loop() {

  randomSeed(analogRead(A0)); //Use the analog pins for a good seed value
  int fileNumber = random(999); //Select a random file #, 0 to 999
  char fileName[12]; //Max file name length is "12345678.123" (12 characters)
  sprintf(fileName, "log%03d.txt", fileNumber);
Serial.println("step1");
  gotoCommandMode(); //Puts OpenLog in command mode
  Serial.println("step2");
  createFile(fileName); //Creates a new file called log###.txt where ### is random
Serial.println("step3");
Serial.println("file step");
  Serial.print("Random file created: ");
  Serial.println(fileName);

  //Write something to OpenLog
  OpenLog.println("Hi there! How are you today?");
  OpenLog.print("Voltage: ");
  OpenLog.println(dummyVoltage);
  dummyVoltage++;
  OpenLog.print("Voltage: ");
  OpenLog.println(dummyVoltage);

  Serial.println("Text written to file");
  Serial.println("Reading file contents:");
  Serial.println();

  //Now let's read back
  gotoCommandMode(); //Puts OpenLog in command mode
  Serial.println("step11");
  readFile(fileName); //This dumps the contents of a given file to the serial terminal
Serial.println("step12");
  Serial.println();
  Serial.println("step13");
  Serial.println("File read complete");

  //Infinite loop
  Serial.println("Yay!");
  while(1) {
    digitalWrite(13, HIGH);
    delay(250);
    digitalWrite(13, LOW);
    delay(250);
  }
}

//Setups up the software serial, resets OpenLog so we know what state it's in, and waits
//for OpenLog to come online and report '<' that it is ready to receive characters to record
void setupOpenLog(void) {
  pinMode(resetOpenLog, OUTPUT);
  OpenLog.begin(9600);

  //Reset OpenLog
  digitalWrite(resetOpenLog, LOW);
  delay(100);
  digitalWrite(resetOpenLog, HIGH);

  //Wait for OpenLog to respond with '<' to indicate it is alive and recording to a file
  while(1) {
    if(OpenLog.available())
      if(OpenLog.read() == '<') break;
  }
}

//This function creates a given file and then opens it in append mode (ready to record characters to the file)
//Then returns to listening mode
void createFile(char *fileName) {

  //Old way
  /*OpenLog.print("new ");
  OpenLog.print(fileName);
  OpenLog.write(13); //This is \r
*/
  //New way
  Serial.println("step5");
  OpenLog.print("new ");
  Serial.println("step6");
  OpenLog.println(fileName); //regular println works with OpenLog v2.51 and above
Serial.println("step7");
  //Wait for OpenLog to return to waiting for a command
  while(1) {
    if(OpenLog.available())
      if(OpenLog.read() == '>')break;
  }

  OpenLog.print("append ");
  OpenLog.print(fileName);
  OpenLog.write(13); //This is \r

  //Wait for OpenLog to indicate file is open and ready for writing
  while(1) {
    if(OpenLog.available())
      if(OpenLog.read() == '<') break;
  }

  //OpenLog is now waiting for characters and will record them to the new file  
}

//Reads the contents of a given file and dumps it to the serial terminal
//This function assumes the OpenLog is in command mode
void readFile(char *fileName) {

  //Old way
  /*OpenLog.print("read ");
  OpenLog.print(fileName);
  OpenLog.write(13); //This is \r*/

  //New way
  OpenLog.print("read ");
  OpenLog.println(fileName); //regular println works with OpenLog v2.51 and above

  //The OpenLog echos the commands we send it by default so we have 'read log823.txt\r' sitting 
  //in the RX buffer. Let's try to not print this.
  while(1) {
    if(OpenLog.available())
      if(OpenLog.read() == '\r') break;
  }  

  //This will listen for characters coming from OpenLog and print them to the terminal
  //This relies heavily on the SoftSerial buffer not overrunning. This will probably not work
  //above 38400bps.
  //This loop will stop listening after 1 second of no characters received
  for(int timeOut = 0 ; timeOut < 1000 ; timeOut++) {
    if(OpenLog.available()) {
      Serial.write(OpenLog.read()); //Take the character from OpenLog and push it to the Arduino terminal
      timeOut = 0;
    }
    delay(1);
  }

  //This is not perfect. The above loop will print the '.'s from the log file. These are the two escape characters
  //recorded before the third escape character is seen.
  //It will also print the '>' character. This is the OpenLog telling us it is done reading the file.  

  //This function leaves OpenLog in command mode
}

//This function pushes OpenLog into command mode
void gotoCommandMode(void) {
  //Send three control z to enter OpenLog command mode
  //Works with Arduino v1.0
  OpenLog.write(26);
  OpenLog.write(26);
  OpenLog.write(26);

  //Wait for OpenLog to respond with '>' to indicate we are in command mode
  while(1) {
    if(OpenLog.available())
      if(OpenLog.read() == '>');
     Serial.println("step command pass"); 
      break;
  }
}

The only that I get in my monitor is

OpenLog online
step1
step command pass
ster2
step5
step6
step7

and in the sd just the config and some log00#### txt files
i want to make aproject like

//Program by Jeremy Blum
//www.jeremyblum.com
//SD Card Demonstration
//Based on Example by Tom Igoe

#include <SD.h>

//Set by default for the SD Card Library
//MOSI = Pin 11
//MISO = Pin 12
//SCLK = PIN 13
//We always need to set the CS Pin
int CS_pin = 10;
int pow_pin = 8;

float refresh_rate = 0.0;

void setup()
{
  Serial.begin(9600);
  Serial.println("Initializing Card");
  //CS Pin is an output
  pinMode(CS_pin, OUTPUT);
  
  //Card will Draw Power from Pin 8, so set it high
  pinMode(pow_pin, OUTPUT);  
  digitalWrite(pow_pin, HIGH);
  
  if (!SD.begin(CS_pin))
  {
      Serial.println("Card Failure");
      return;
  }
  Serial.println("Card Ready");
  
  //Read the Configuration information (COMMANDS.txt)
  File commandFile = SD.open("COMMANDS.txt");
  if (commandFile)
  {
    Serial.println("Reading Command File");
    
    float decade = pow(10, (commandFile.available() - 1));
    while(commandFile.available())
    {
      float temp = (commandFile.read() - '0');
      refresh_rate = temp*decade+refresh_rate;
      decade = decade/10;
    }
    Serial.print("Refresh Rate = ");
    Serial.print(refresh_rate);
    Serial.println("ms");
  }
  else
  {
    Serial.println("Could not read command file.");
    return;
  }
  
}

void loop()
{
  
  String dataString = "Hello";
  
  //Open a file to write to
  //Only one file can be open at a time
  File logFile = SD.open("LOG.txt", FILE_WRITE);
  if (logFile)
  {
    logFile.println(dataString);
    logFile.close();
    Serial.println(dataString);
  }
  else
  {
    Serial.println("LOG.txt");
    Serial.println("Couldn't open log file");
  }
  delay(refresh_rate);
}

xazirhs:
First I run the sketch from the openLog file “OpenLog_CommandTest nothing happens, it just makes the config file and a LOG00325.txt
Then the OpenLog_ReadExample that I insert some Serial.prinln step to monitor the process

So are you actually sending it any data to log?

i dont thats way i ask if ther is a skech to test it the openLog _TestSkech gives knothing to

so is someone that can tell me how to send data and test the openlog?

xazirhs:
so is someone that can tell me how to send data and test the openlog?

Openlog logs what you send it on the serial port. So, you need to send it data over the serial port in order for it to log anything. (I'm puzzled that you have got this far without understanding what openlog does.)

I’m new in programming and I’m not familiar with sending from serial port. So I tried that sketch.

#include <SoftwareSerial.h>

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//Connect TXO of OpenLog to pin 3, RXI to pin 2
SoftwareSerial OpenLog(3, 2); //Soft RX on 3, Soft TX out on 2
//SoftwareSerial(rxPin, txPin)

int resetOpenLog = 4; //This pin resets OpenLog. Connect pin 4 to pin GRN on OpenLog.
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

int statLED = 13;
int testNumber =687682376;

void setup() {                
  pinMode(statLED, OUTPUT);
  Serial.begin(9600);

  setupOpenLog(); //Resets logger and waits for the '<' I'm alive character
  Serial.println("OpenLog online");
}

void loop() {
  gotoCommandMode(); //Puts OpenLog in command mode
  

 //Write something to OpenLog
  OpenLog.println("Hi there! How are you today?");
  OpenLog.print("hello ");
  OpenLog.println(testNumber);
 
  OpenLog.print("Voltage: ");
  OpenLog.println(testNumber);

  Serial.println("Text written to file");
  Serial.println("Reading file contents:");
  Serial.println(); 
  delay(50);
}

void setupOpenLog(void) {
  pinMode(resetOpenLog, OUTPUT);
  OpenLog.begin(9600);

  //Reset OpenLog
  digitalWrite(resetOpenLog, LOW);
  delay(100);
  digitalWrite(resetOpenLog, HIGH);

  //Wait for OpenLog to respond with '<' to indicate it is alive and recording to a file
  while(1) {
    if(OpenLog.available())
      if(OpenLog.read() == '<') break;
  }
}
//This function pushes OpenLog into command mode
void gotoCommandMode(void) {
  //Send three control z to enter OpenLog command mode
  //Works with Arduino v1.0
  OpenLog.write(26);
  OpenLog.write(26);
  OpenLog.write(26);

  //Wait for OpenLog to respond with '>' to indicate we are in command mode
  while(1) {
    if(OpenLog.available())
      if(OpenLog.read() == '>');
     Serial.println("step command pass"); 
      break;
  }
}

I thing that it will set the openlog to command mode and the data but it doesn’t works

I tried this modified sketch

/*
 2-22-2012
 SparkFun Electronics 2011
 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 an exampe of writing to a file then read from a file contain OpenLog
 
 Connect the following OpenLog to Arduino:
 TXO of OpenLog to pin 3 on the Arduino
 RXI to 3
 GRN to 4
 VCC to 5V
 GND to GND
 
 This example code assumes the OpenLog is set to operate at 9600bps in NewLog mode, meaning OpenLog 
 should power up and output '12<'. This code then sends the three escape characters and then sends 
 the commands to create a new random file called log###.txt where ### is a random number from 0 to 999.
 The example code will then read back the random file and print it to the serial terminal.
 
 This code assume OpenLog is in the default state of 9600bps with ASCII-26 as the esacape character.
 If you're unsure, make sure the config.txt file contains the following: 9600,26,3,0
 
 Be careful when sending commands to OpenLog. println() sends extra newline characters that 
 cause problems with the command parser. The new v2.51 ignores \n commands so it should be easier to 
 talk to on the command prompt level. This example code works with all OpenLog v2 and higher.
 
 */

#include <SoftwareSerial.h>

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//Connect TXO of OpenLog to pin 3, RXI to pin 2
SoftwareSerial OpenLog(10,11); //Soft RX on 3, Soft TX out on 2
//SoftwareSerial(rxPin, txPin)

int resetOpenLog = 12; //This pin resets OpenLog. Connect pin 4 to pin GRN on OpenLog.
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

int statLED = 13;

float dummyVoltage = 3.50; //This just shows to to write variables to OpenLog
int val;
int val1;
int val2;
void setup() {                
  pinMode(statLED, OUTPUT);
  pinMode(resetOpenLog, OUTPUT);
  Serial.begin(9600);
  
  setupOpenLog(); //Resets logger and waits for the '<' I'm alive character
  Serial.println("OpenLog online");
}

void loop() {

  randomSeed(analogRead(A0)); //Use the analog pins for a good seed value
  int fileNumber = random(999); //Select a random file #, 0 to 999
  char fileName[12]; //Max file name length is "12345678.123" (12 characters)
  sprintf(fileName, "log%03d.txt", fileNumber);
  val = OpenLog.read();
  Serial.print(val);
  gotoCommandMode(); //Puts OpenLog in command mode
  createFile(fileName); //Creates a new file called log###.txt where ### is random

  Serial.print("Random file created: ");
  Serial.println(fileName);

  //Write something to OpenLog
  OpenLog.println("Hi there! How are you today?");
  OpenLog.print("Voltage: ");
  OpenLog.println(dummyVoltage);
  dummyVoltage++;
  OpenLog.print("Voltage: ");
  OpenLog.println(dummyVoltage);

  Serial.println("Text written to file");
  Serial.println("Reading file contents:");
  Serial.println();

  //Now let's read back
  gotoCommandMode(); //Puts OpenLog in command mode
  Serial.println("pass command mode");
  readFile(fileName); //This dumps the contents of a given file to the serial terminal

  Serial.println();
  Serial.println("File read complete");

  //Infinite loop
  Serial.println("Yay!");
  while(1) {
    digitalWrite(13, HIGH);
    delay(250);
    digitalWrite(13, LOW);
    delay(250);
  }
}

//Setups up the software serial, resets OpenLog so we know what state it's in, and waits
//for OpenLog to come online and report '<' that it is ready to receive characters to record
void setupOpenLog(void) {
  pinMode(resetOpenLog, OUTPUT);
  OpenLog.begin(9600);

  //Reset OpenLog
  digitalWrite(resetOpenLog, LOW);
  delay(100);
  digitalWrite(resetOpenLog, HIGH);

  //Wait for OpenLog to respond with '<' to indicate it is alive and recording to a file
  while(1) {
    if(OpenLog.available())
    val1 = OpenLog.read();
  Serial.write(val1);
  Serial.println();
      if(val1 == '<') break;
  }
}

//This function creates a given file and then opens it in append mode (ready to record characters to the file)
//Then returns to listening mode
void createFile(char *fileName) {

  //Old way
  OpenLog.print("new ");
  OpenLog.print(fileName);
  OpenLog.write(13); //This is \r

  //New way
  //OpenLog.print("new ");
  //OpenLog.println(filename); //regular println works with OpenLog v2.51 and above

  //Wait for OpenLog to return to waiting for a command
  while(1) {
    if(OpenLog.available())
      if(OpenLog.read() == '>') break;
  }

  OpenLog.print("append ");
  OpenLog.print(fileName);
  OpenLog.write(13); //This is \r

  //Wait for OpenLog to indicate file is open and ready for writing
  while(1) {
    if(OpenLog.available())
      if(OpenLog.read() == '<') break;
  }

  //OpenLog is now waiting for characters and will record them to the new file  
}

//Reads the contents of a given file and dumps it to the serial terminal
//This function assumes the OpenLog is in command mode
void readFile(char *fileName) {

  //Old way
  OpenLog.print("read ");
  OpenLog.print(fileName);
  OpenLog.write(13); //This is \r

  //New way
  //OpenLog.print("read ");
  //OpenLog.println(filename); //regular println works with OpenLog v2.51 and above

  //The OpenLog echos the commands we send it by default so we have 'read log823.txt\r' sitting 
  //in the RX buffer. Let's try to not print this.
  while(1) {
    if(OpenLog.available())
      if(OpenLog.read() == '\r') break;
  }  

  //This will listen for characters coming from OpenLog and print them to the terminal
  //This relies heavily on the SoftSerial buffer not overrunning. This will probably not work
  //above 38400bps.
  //This loop will stop listening after 1 second of no characters received
  for(int timeOut = 0 ; timeOut < 1000 ; timeOut++) {
    if(OpenLog.available()) {
      Serial.write(OpenLog.read()); //Take the character from OpenLog and push it to the Arduino terminal
      timeOut = 0;
    }
    delay(1);
  }

  //This is not perfect. The above loop will print the '.'s from the log file. These are the two escape characters
  //recorded before the third escape character is seen.
  //It will also print the '>' character. This is the OpenLog telling us it is done reading the file.  

  //This function leaves OpenLog in command mode
}

//This function pushes OpenLog into command mode
void gotoCommandMode(void) {
  //Send three control z to enter OpenLog command mode
  //Works with Arduino v1.0
  OpenLog.write(26);
  OpenLog.write(26);
  OpenLog.write(26);
Serial.println("send three 26");
  //Wait for OpenLog to respond with '>' to indicate we are in command mode
  while(1) {
    if(OpenLog.available())
    Serial.println("openlog available");
      val2 = OpenLog.read();
  Serial.print(val2);
  if(val2 == '>') break;
  }
}

Result in the serial is shown her

1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
<
OpenLog online
-1send three 26
-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1openlog available
49openlog available
50-1-1-1-1-1-1-1-1openlog available
60-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1

i thing the openlog dosn't send the >
what is your opinion?

xazirhs:
what is your opinion?

I think I'm confused about what you're trying to achieve, and so are you.

OpenLog is a serial port data logger. You can send it data over the serial port and it will log it. How this relates to your sensor data I have no idea. Is your sensor connected to the Arduino via its serial port? If not, how is Openlog useful to you?

What you mean when you say collects, data what kind of data
I use an arduino Uno can I make a csv file in the SD card and add every one hour data and then take the data to my pc.
All this time as I said in my first post I'm tring to make it word with the code of jeremi Blum
//Program by Jeremy Blum
//www.jeremyblum.com
//SD Card Demonstration
//Based on Example by Tom Igoecan
can the openlog work us an SD shield?
If not what it does and how because I don’t see any other respond from it except from making the config file and the log00### files empty of course.

xazirhs:
What you mean when you say collects, data what kind of data

I'm puzzled that you're asking me what openlog does. It has its own web site that explains exactly what it does. Since you've chosen to use it, I would expect you to have understood what it is for.

The basic concept of openlog is that it produces a device with a serial port which will log anything it receives over the serial port. What data you send it is up to you.

In this case you aren't sending it any data so it is not logging anything. Since your data is not accessed via a serial port, openlog seems irrelevant to your problem and I would have thought it made more sense to write a sketch that uses the SD library to open a file on the SD card and write your data to it. It is up to you to figure out what data to write, how often to retrieve it and write it to the file, and in what format. CSV is a good general purpose format and easy to implement, if that's what you're after. Look at the examples for the SD library - writing data to a file is its basic purpose and there are plenty of examples showing you how to do it.

Let’s take it from the start. I want to make a project with arduino Uno and use an openlog to store my data, that I collect from various sensors.
I try to make the openlog write that data to a file.
How can I do that, which are the connections and the commands.
The only sketches that I have found on the net are from the openlog file found here GitHub - sparkfun/OpenLog: Open Source Hardware Datalogger
I have run them and I don’t get any file created as I explained above
Does anybody have made something similar to tell me how?