ardulog openlog rtc

hello , i have bought a ardulog - rtc data logger, (http://fr.hobbytronics.co.uk/ardulog-rtc)

i want to log serial stream from other microcontroller ,
since now i always use the code from
https://github.com/sparkfun/OpenLog/tree/master/firmware/OpenLog_Minimal

and it's work pretty fine,

but i want to name my log file not just "LOG13.txt" but with the time from rtc ( eg ,"12_24.txt") at each restart of the ardulog.

i tried several things but i never could have a good result .

if someone have a good idea

if someone have a good idea

Well, yeah, actually I do.

i tried several things but i never could have a good result .

Pick one of them. POST YOUR CODE. Explain what it actually does, and how that differs from what you want.

char fileName[12];
byte hour = 12;
byte minute = 36;

sprintf(fileName, "%02d_%02d.txt", hour, minute);
// fileName will be "12_24.txt"

biogene2006:
i tried several things but i never could have a good result .

Try creating file names based on date!

For example, if you want to have a different file name per day, create file name from date like "yyyymmdd.txt":
20160120.txt ==> log file name for January 20th, 2016
20160121.txt ==> log file name for January 21st, 2016
20160122.txt ==> log file name for January 22nd, 2016

The advantage of such log file naming is then: chronological order and alphabetical order of the file names is the same, so you can simply take the SD card from your Arduino, put it into a PC, and the alphabetical sorted list of files is shown in chronological order at the same time.

If you read the date/time from RTC and create the file name each time before you open the log file for appending data, you easily can switch over from one to the next file name on-the-fly without restarting the sketch.

yes i have to explain where exactly is my problem:
it is not in formating the date time , it is when i try to get a new data from rtc it doesn’t work ,
it work the first time after i upload a new sketch but never again.

if you look at the code below it would be normale that at each time a reset my arduino by pressing the button i would have a new date time, but it’s not the case , i have always the same date time ( the date time when i upload my sketch). and what is very strange is when i unplug and plug again my arduino i have again the same date time.

/*
 12-3-09
 Nathan Seidle
 SparkFun Electronics 2012

 OpenLog hardware and firmware are released under the Creative Commons Share Alike v3.0 license.
 http://creativecommons.org/licenses/by-sa/3.0/
 Feel free to use, distribute, and sell varients of OpenLog. All we ask is that you include attribution of 'Based on OpenLog by SparkFun'.

 OpenLog is based on the work of Bill Greiman and sdfatlib: https://github.com/greiman/SdFat-beta

 This version has the command line interface and config file stripped out in order to simplify the overall 
 program and increase the receive buffer (RAM).

 The only option is the interface baud rate and it has to be set in code, compiled, and loaded onto OpenLog. To
 see how to do this please refer to https://github.com/sparkfun/OpenLog/wiki/Flashing-Firmware

 If you go through the hassle of compiling and loading this firmware you'll benefit from

 */

#define __PROG_TYPES_COMPAT__ //Needed to get SerialPort.h to work in Arduino 1.6.x

#include <SPI.h>
#include <SdFat.h> //We do not use the built-in SD.h file because it calls Serial.print
#include <EEPROM.h>
#include <FreeStack.h> //Allows us to print the available stack/RAM size

#include <avr/sleep.h> //Needed for sleep_mode
#include <avr/power.h> //Needed for powering down perihperals such as the ADC/TWI and Timers

#include <SerialPort.h>
// port 0, 1024 byte RX buffer, 0 byte TX buffer
SerialPort<0, 1024, 0> NewSerial;

//Debug turns on (1) or off (0) a bunch of verbose debug statements. Normally use (0)
//#define DEBUG  1
#define DEBUG  0

#define SD_CHIP_SELECT 10 //On OpenLog this is pin 10

//Internal EEPROM locations for the user settings
#define LOCATION_FILE_NUMBER_LSB  0x03
#define LOCATION_FILE_NUMBER_MSB  0x04

//STAT1 is a general LED and indicates serial traffic
const byte stat1 = 5;  //This is the normal status LED
const byte stat2 = 13; //This is the SPI LED, indicating SD traffic

//Blinking LED error codes
#define ERROR_SD_INIT   3
#define ERROR_NEW_BAUD    5
#define ERROR_CARD_INIT   6
#define ERROR_VOLUME_INIT 7
#define ERROR_ROOT_INIT   8
#define ERROR_FILE_OPEN   9

SdFat sd;

long setting_uart_speed = 115200;

#include <Arduino.h>
#include <Wire.h>         // this #include still required because the RTClib depends on it
#include "RTClib.h"
RTC_Millis rtc;

//Handle errors by printing the error type and blinking LEDs in certain way
//The function will never exit - it loops forever inside blinkError
void systemError(byte errorType)
{
  NewSerial.print(F("Error "));
  switch (errorType)
  {
    case ERROR_CARD_INIT:
      NewSerial.print(F("card.init"));
      blinkError(ERROR_SD_INIT);
      break;
    case ERROR_VOLUME_INIT:
      NewSerial.print(F("volume.init"));
      blinkError(ERROR_SD_INIT);
      break;
    case ERROR_ROOT_INIT:
      NewSerial.print(F("root.init"));
      blinkError(ERROR_SD_INIT);
      break;
    case ERROR_FILE_OPEN:
      NewSerial.print(F("file.open"));
      blinkError(ERROR_SD_INIT);
      break;
  }
}

void setup(void)
{
  pinMode(stat1, OUTPUT);

  //Power down various bits of hardware to lower power usage
  set_sleep_mode(SLEEP_MODE_IDLE);
  sleep_enable();

  //Shut off TWI, Timer2, Timer1, ADC
  ADCSRA &= ~(1 << ADEN); //Disable ADC
  ACSR = (1 << ACD); //Disable the analog comparator
  DIDR0 = 0x3F; //Disable digital input buffers on all ADC0-ADC5 pins
  DIDR1 = (1 << AIN1D) | (1 << AIN0D); //Disable digital input buffer on AIN1/0

  power_twi_disable();
  power_timer1_disable();
  power_timer2_disable();
  power_adc_disable();

  //Setup UART
  NewSerial.begin(setting_uart_speed);
  NewSerial.print(F("1"));
  
    rtc.begin(DateTime(F(__DATE__), F(__TIME__)));
    DateTime now = rtc.now();
    
    NewSerial.print(now.year(), DEC);
    NewSerial.print('/');
    NewSerial.print(now.month(), DEC);
    NewSerial.print('/');
    NewSerial.print(now.day(), DEC);
    NewSerial.print(' ');
    NewSerial.print(now.hour(), DEC);
    NewSerial.print(':');
    NewSerial.print(now.minute(), DEC);
    NewSerial.print(':');
    NewSerial.print(now.second(), DEC);
    NewSerial.println();
    
  //Setup SD & FAT
  if (!sd.begin(SD_CHIP_SELECT, SPI_FULL_SPEED)) systemError(ERROR_CARD_INIT);

  NewSerial.print(F("2"));

#if DEBUG
  NewSerial.print(F("\n\nFreeStack: "));
  NewSerial.println(FreeStack());
#endif

}

// .... the end of the code is like 
// https://github.com/sparkfun/OpenLog/tree/master/firmware/OpenLog_Minimal
// but i can't write it there because is more than 9000 characters

if you look at the code below it would be normale that at each time a reset my arduino by pressing the button i would have a new date time

When I look at the code, I see that each time you reset the Arduino, the time/date is set to the time/date the sketch was compiled. That you expect to have something different happen says more that your expectations are wrong.

biogene2006:
yes i have to explain where exactly is my problem:
it is not in formating the date time , it is when i try to get a new data from rtc it doesn't work ,

It works exactly as the code tells how it shall work.

This line:

RTC_Millis rtc;

means actually: DO NOT USE any RTC module which might be connected to the Arduino, but simply derive the time from the millis() function.

And this line:

    rtc.begin(DateTime(F(__DATE__), F(__TIME__)));

means: Reset the time to the date and time of compilation.

So whether you have connected a RTC module to your Arduino or not, the program always does the same and no RTC module is ever used.

The time and date you get is always derived from date and time of compilation and from millis().

ok i was completly out of space ,

i understand that i was wrong ,
i didn't read the top of the code of the example of softrtc from rtclib....( none the title)

i apologize and really thank you to light my darkness head...

i will improve my code and back to you if i need

thank you very much paul and jurs

have a good day