Artemis Global Tracker and qwiic openLog

Hi everyone,

I am trying to use the qwiic openLog with my artemis global tracker, but it create some Mbed OS errors. I’m building my code over Example15_BetterTracker.

I wonder what might be the problem. I know that the artemis global tracker has other i2c devices (barometric sensor and iridium) connected. In the examples for the openlog we need to use Wire and those other device use Twowire.

I wonder if creating two instances can create some bug.

#include <Wire.h> // Needed for I2C
const byte PIN_AGTWIRE_SCL = 8;
const byte PIN_AGTWIRE_SDA = 9;
TwoWire agtWire(PIN_AGTWIRE_SDA, PIN_AGTWIRE_SCL); //Create an I2C port using pads 8 (SCL) and 9 (SDA)

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

void setup()
{
  // Start the console serial port
  Serial.begin(115200);
  Wire.begin();
  myLog.begin();

Whenever I use myLog.println(someString) the program crashes. But when I use only the examples of the openlog qwiic library it works without problem. So I wonder, if the problem comes from using Wire and twoWire at the same time.

Here’s the error i’m getting:

++ MbedOS Fault Handler ++

FaultType: HardFault

Context:
R0: 10009FFC
R1: 186A0
R2: 1123456
R3: 50008000
R4: 0
R5: 10009FFC
R6: 10007B2C
R7: 39
R8: 10001404
R9: 10001088
R10: 10007AC8
R11: 10007A74
R12: 30679
SP   : 10007958
LR   : 31D79
PC   : 35498
xPSR : 1000000
PSP  : 100078F0
MSP  : 1005FF70
CPUID: 410FC241
HFSR : 40000000
MMFSR: 0
BFSR : 82
UFSR : 0
DFSR : 0
AFSR : 0
BFAR : 50008214
Mode : Thread
Priv : Privileged
Stack: PSP

-- MbedOS Fault Handler --



++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x35498
Error Value: 0x10006BB8
Current Thread: main Id: 0x10004F94 Entry: 0x2FA09 StackSize: 0x1000 StackMem: 0x10006C18 SP: 0x10007958 
For more info, visit: https://mbed.com/s/error?error=0x80FF013D&tgt=SFE_ARTEMIS_ATP
-- MbedOS Error Info --

Let me know if you need more info.

Hi,isn’t it the standard to include all the libraries at the beginning of the code? If you write

#include <Wire.h> 
#include "SparkFun_Qwiic_OpenLog_Arduino_Library.h"

then the rest of the code, do you see any improvement?

No, as long as i don’t use code that belongs to a library before including it, it’s fine. But thanks for the suggestion!

Hi Pilowz,

I don’t have a Qwiic OpenLog, but it should work OK. You just need to ‘begin’ it properly.

Looking at the source code for begin in the Qwiic OpenLog Arduino Library, it will let you specify a ‘custom’ TwoWire port:

https://github.com/sparkfun/SparkFun_Qw … ary.h#L129

So, your code would look something like this:

#include <Wire.h>

TwoWire agtWire(9,8); //Create an I2C port using pads 8 (SCL) and 9 (SDA)

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

#include <SparkFun_PHT_MS8607_Arduino_Library.h> //http://librarymanager/All#SparkFun_MS8607
MS8607 barometricSensor; //Create an instance of the MS8607 object

void setup()
{
  Serial.begin(115200);

  agtWire.begin(); // Set up the I2C pins

  myLog.begin(QOL_DEFAULT_ADDRESS, agtWire); //Open connection to OpenLog

  if (barometricSensor.begin(agtWire) == false)
  {
    Serial.println("MS8607 sensor did not respond. Trying again...");
    if (barometricSensor.begin(agtWire) == false)
    {
      Serial.println("MS8607 sensor did not respond. Please check wiring.");
      while(1)
        ;
    }
  }

I hope this helps!

Paul