sparkfun / OpenLog

Open Source Hardware Datalogger
https://www.sparkfun.com/products/9530
Other
547 stars 215 forks source link

OpenLog only functions after arduino reset #236

Open Rob-Fox opened 4 years ago

Rob-Fox commented 4 years ago

I have a SparkFun OpenLog that I am trying to use to log data. The OpenLog's config is: 57600,36,3,2,1,1,0. Starting in command mode it should immediately accept my command to: OpenLog.print("append ");OpenLog.print(date);OpenLog.println(".csv\r"); but this only functions if the Arduino board has been powered on and then had the reset button pressed. If the reset button is not pressed then no file is created.

I am using a Sainsmart Nano V3.0 (arduino nano with ATmega328p old bootloader). The device is powered, I am using a library called AltSoftSerial which means the OpenLog TX is connected to arduino pin 8 and RX is connected to arduino pin 9.

OpenLog reports: OpenLog v4.2

Currently the OpenLog is being powered via the Arduino board which is receiving power from its Mini-usb cable.

#include <AltSoftSerial.h>

AltSoftSerial OpenLog;

unsigned long date = 16082020;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(57600);
  OpenLog.begin(57600);
  OpenLog.print("append ");OpenLog.print(date);OpenLog.println(".csv\r");
}
int count = 0;
void loop() {
  Serial.println("Hello");
  if(count < 10){
    Serial.println(count);
    OpenLog.print("This Text goes into the log");OpenLog.print(count);OpenLog.print("\r");
    count++;
  }
  delay(1000);
}

All I have to do is run this code to get the issue. On cold-boot it does nothing, but after reset (from built in reset button) code behaves as expected the first time, The second time the words "append" the unsigned long "date" and ".csv" are written into the logfile rather than being used as a file name (which suggests to me that the soft reset performed by using the hardware button does not remove power from the OpenLog).

Expected Behavior: On cold boot a log file is made that is named "date".csv (or if it already exists it continues to be appended to). 10 lines are written to this file, containing "This Text goes into the log#".

Actual Behavior: No log file is created, as such no text is written. If log file already exists, no text is written.