Qwiic Open Log erratic writing

Hello there,

I have a simple setup that logs temperature over time.

I use the RTC from my board https://support.sodaq.com/Boards/ExpLoRer/ and the onboard temp sensor.

formatting my log file is important, so here is the code i wrote from the examples

#include <Wire.h>
#include "SparkFun_Qwiic_OpenLog_Arduino_Library.h"
#define debugSerial SerialUSB
OpenLog myLog; //Create instance
#include <RTCZero.h>


/* Create an rtc object */
RTCZero rtc;

/* Change these values to set the current initial time */
byte seconds = 0;
byte minutes = 0;
byte hours = 0;

/* Change these values to set the current initial date */
byte day = 1;
byte month = 1;
byte year = 1970;

void setup() {
  // put your setup code here, to run once:
    delay(10000);
    debugSerial.begin(9600);
    debugSerial.println("starting logger...waiting for 10 sec");
    Wire.begin(); //Initialize I2C
    myLog.begin(); //Open connection to OpenLog (no pun intended)
    rtc.begin(); // initialize RTC
    rtc.setEpoch(0);
    myLog.println("format descriptor : heures, minutes, secondes,Temp °C");
    
    
    //Set the temperature sensor pin as input
  pinMode(TEMP_SENSOR, INPUT) ;
  //Set ADC resolution to 12 bits
  analogReadResolution(12) ;
  //myLog.println(rtc.getMinutes());
  //debugSerial.println(rtc.getSeconds());
  

}

void loop() {
  // put your main code here, to run repeatedly:
  float temperature = getTemperature();
  myLog.print(String(rtc.getHours()));
  myLog.print(",");
  myLog.print(String(rtc.getMinutes()));
  myLog.print(",");
  myLog.syncFile();
  myLog.print(String(rtc.getSeconds()));
  myLog.print(",");
  myLog.println(String(temperature));
  delay(15);
  myLog.syncFile();
  debugSerial.println(temperature);
  delay(6000);
  
  
  
  

}
void print2digits(int number) {
  if (number < 10) {
    debugSerial.print("0"); // print a 0 before if the number is < than 10
  }
  debugSerial.print(number);
}
float getTemperature()
{
  uint8_t samples = 10;

  float sum = 0.0 ;    // reset averaged reading to start at 0
  // This loop does 10 readings of the voltage, and adds this to the variable
  for(int i = 0; i < samples; i++)
    sum += 3.3/4095.0 * (float)analogRead(TEMP_SENSOR) ;

  // Divide the voltage to get average
  float voltage = sum / samples ;
  
  // Convert voltage to temperature
  double temperature = (voltage - 0.5) * 100.0 ;
  return temperature;
}

it records well, but from time to time the println is not taken into account and produces inconsictency in my file

EX : See Attached logfile

Any help appreciated

LOG00171.TXT (4.64 KB)

Hi laurentchivot,

If you can, try adding some short delays in between each print to the OpenLog and that should help with the inconsistency. [The Troubleshooting Section of our Hookup Guide for the Qwiic OpenLog has a good example of that along with some other helpful troubleshooting tips for the board.](Qwiic OpenLog Hookup Guide - SparkFun Learn)

Hi, Thanks for advising, i wiil do that.

I also discovered from another post that i’ve been delivered with 2.0 firmware logger

I’ll keep you informed

Laurent

Ah, v2.0 firmware could also be an issue here since the syncfile command only works on v3.0. Luckily, the Qwiic OpenLog can have its firmware updated fairly easily if you have a serial to USB converter. We briefly cover how to update the firmware in the [Qwiic OpenLog Hookup Guide.

Let us know if adding delays does not help and if you need any assistance updating the firmware and we would be happy to help.](Qwiic OpenLog Hookup Guide - SparkFun Learn)

Hi,

My openlog states version 255.255 from the get version example. I’m assuming this is firmware 2.0.

Whilst trying to update to the latest version I get the following error when compiling:

‘FatFile* FatVolume::vwd()’ is private within this context

This error is line 351 of the commands.ino.

Any ideas on how to fix this?

Thank you very much.

Josh