Hi all.
I have an Openlog Qwiic connected to an Adafruit BNO055 sensor and an Adafruit QT PY (a basic SAMD21 chip).
I can log data but I get random characters missing when I look at the log file.
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);
}