Openlog QWIIC and I2C sensors - random data loss

Hi all.

I have a SparkFun's Openlog Qwiic connected to an Adafruit BNO055 sensor and an Adafruit QT PY (a basic SAMD21 chip).
All are linked through the I2C Qwiic / stemmaST connectors.
I can log data but I get random characters missing when I look at the log file.

Just for reference …. The sensor outputs the data to the serial monitor perfectly.

By my own admission .... I'm the worst coder and relatively new at this so any help / guidance much appreciated.
The attached code has been adapted from others sketches.

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

#include "SparkFun_Qwiic_OpenLog_Arduino_Library.h"
OpenLog myLog; //Create instance

int ledPin = LED_BUILTIN; //Status LED connected to digital pin 13
  
Adafruit_BNO055 bno = Adafruit_BNO055(55);

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

  Wire.begin(); //Initialize I2C
  myLog.begin(); //Open connection to OpenLog (no pun intended)
  
  Serial.begin(9600);
  Serial.println("Orientation Sensor Test"); Serial.println("");
  
  /* Initialise the sensor */
  if(!bno.begin())
  {
    /* There was a problem detecting the BNO055 ... check your connections */
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
    while(1);
  }
  
  delay(1000);
    
  bno.setExtCrystalUse(true);
}

void loop(void) 
{
  /* Get a new sensor event */ 
  sensors_event_t event; 
  bno.getEvent(&event);
  
  /* Display the floating point data */
  Serial.print("X: ");
  Serial.print(event.orientation.x, 4);
  Serial.print("\tY: ");
  Serial.print(event.orientation.y, 4);
  Serial.print("\tZ: ");
  Serial.print(event.orientation.z, 4);
  Serial.println("");

  /* Log the floating point data */
  myLog.print("X: ");
  myLog.print(event.orientation.x, 4);
  myLog.print("\tY: ");
  myLog.print(event.orientation.y, 4);
  myLog.print("\tZ: ");
  myLog.print(event.orientation.z, 4);
  myLog.println("");
  
  myLog.syncFile();
  
  delay(100);
}

The customer comments in the product page SparkFun Qwiic OpenLog - DEV-15164 - SparkFun Electronics
mention problems with the SAMD21.

Have a look in Github to see if these problems have been submitted as bugs and if there are any fixes.

1 Like

And whiles the OP looks into issue with the SAMD21, what does missing data mean/look like?

Looking through the docs, I see a file needs to be created and opened for append to be able to add data to the file.

appending example,

though it looks like a sam d issue may have been addressed,

bool OpenLog::syncFile()
{
  _i2cPort->beginTransmission(_deviceAddress);
  _i2cPort->write(registerMap.syncFile);

  if (_i2cPort->endTransmission() != 0)
  {
#ifndef __SAMD21G18A__
    return (false);
#endif
  }

  return (1);
}

Hi Shannon.
Thanks for the responses.
Could I ask where about that code snippet (samd21 fix) goes within the sketch or which bit it substitutes ??

It's already in the library. See the link fm post#3.

Yep - found it.

So ...... if is not an issue with the SAMD21 .... any other ideas ???

Here is what the logged data looks like ....
Dropped characters in various places. Sometimes more than a single character.

|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|-7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y-78125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z:160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 1.7500|
|X: 225.5000|Y: -7.8125|Z: 16.7500|
|X225.5000|Y: -7.8125|Z: 160.7500|
|X: 2.5000|Y:-7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 2255000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 16.7500|
|X: 225.5000|Y:-78125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|-7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 1.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X225.5000|Y: -7.8125|Z: 160.7500|
|X: 2.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 1.7500|
|X: 225.5000|Y: -7.8125|Z: 16.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|
|X: 225.5000|Y: -7.8125|Z: 160.7500|

Just tried the appendfile sketch on its own and there is def something amiss.
Its only recorded fragments of what it should have.
This is all that was logged ....

This is r
If this file doesn't exis
anythi

Note: We can us

I have tried placing a small 15 milli delay in-between the serial.print lines and myLog.print lines but still get incomplete data logging :frowning:

that too low.

try without a delay, use millis() for delay if needed.

afterall,

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

#include "SparkFun_Qwiic_OpenLog_Arduino_Library.h"
OpenLog myLog; //Create instance

int ledPin = LED_BUILTIN; //Status LED connected to digital pin 13
  
Adafruit_BNO055 bno = Adafruit_BNO055(55);

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

  Wire.begin(); //Initialize I2C
  myLog.begin(); //Open connection to OpenLog (no pun intended)
  
  Serial.begin(9600);
  Serial.println("Orientation Sensor Test"); Serial.println("");
  
  /* Initialise the sensor */
  if(!bno.begin())
  {
    /* There was a problem detecting the BNO055 ... check your connections */
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
    while(1);
  }
  
  delay(1000);
    
  bno.setExtCrystalUse(true);
}
unsigned long delay100 = 100;
unsigned long pastTime = millis();
void loop(void) 
{
  if ( (millis() - pastTime) >= delay100)
  {
  /* Get a new sensor event */ 
  sensors_event_t event; 
  bno.getEvent(&event);
  
  /* Display the floating point data */
  Serial.print("X: ");
  Serial.print(event.orientation.x, 4);
  Serial.print("\tY: ");
  Serial.print(event.orientation.y, 4);
  Serial.print("\tZ: ");
  Serial.print(event.orientation.z, 4);
  Serial.println("");

  /* Log the floating point data */
  myLog.print("X: ");
  myLog.print(event.orientation.x, 4);
  myLog.print("\tY: ");
  myLog.print(event.orientation.y, 4);
  myLog.print("\tZ: ");
  myLog.print(event.orientation.z, 4);
  myLog.println("");
  
  myLog.syncFile();
  pastTime = millis();
  }
  
}

not tested but delay was removed.

Just tried it and still getting some data loss.

In the sparkfun hookup guide under "troubleshooting" it does mention sticking a small delay in between the serial.print lines but from what you suggest you don't think this is needed ??

I may have found the issue ...... after posting (and then quickly deleting) about how a processor swap had no effect on the problem ..... I'm retesting again with an older UNO R3 to see if I was wrong.

Yep - Its a processor conflict error.
The SAMD21 issue obviously not fixed :frowning:
Bugger !!!

Works fine with the UNO R3 :+1:
At least I know where the issue is.
:grinning:

So .... the story continues .....

I can get a chain of sensors (adxl375, bno055, bmp390) all connected to the Qwiic OpenLog and then to an UNO r3.
It all works perfectly on the r3 - logs data, records it to the sd card - no losses of data issues whatsoever.

I need to add gps to the mix which then creates a sketch too large for the diminutive memory of the r3.

I have tried with the long list of other processors - Adafruit QT PY M0 (SAMD21), Adafruit QT PY (rp2040), SparkFun thing Plus Artemis (Apollo3 cortex M4), Adafruit ItsyBitsy M4 (SAMD51) - and nothing works properly
I still get random data loss when writing to the sd card.

If anyone has ANY suggestions for boards that actually work with the Qwiic OpenLog - please can you post them here.

Cheers

One solution is to use an Uno as an interface between the SAMD and the Qwiic.
SAMD serial port send -> Uno serial port receive -> Qwiic

Update

The Qwiic Openlog library has had a small change to fix the issue.
See here https://forum.sparkfun.com/viewtopic.php?f=105&t=58787

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.