Managed to determine that there seems to be some sort of conflict between Bridge and the SparkFun BMI270 library. If I create an app that just reads and prints magnetometer from the BMM150 it seems to work.
Sketch:
#include <Arduino_RouterBridge.h>
#include "Wire.h"
#include "DFRobot_BMM150.h"
DFRobot_BMM150_I2C bmm150(&Wire1, 0x13); //0x10-nano, 0x13dfrobot
void setup() {
Bridge.begin();
Serial.begin(115200);
delay(2000);
Wire1.begin();
Wire1.setClock(1000000);
while(bmm150.begin()){
Serial.println("bmm150 init failed, Please try again!");
delay(1000);
} Serial.println("bmm150 init success!");
bmm150.setOperationMode(BMM150_POWERMODE_NORMAL);
bmm150.setPresetMode(BMM150_PRESETMODE_HIGHACCURACY);
bmm150.setRate(BMM150_DATA_RATE_25HZ);
bmm150.setMeasurementXYZ();
}
void loop() {
sBmm150MagData_t magData = bmm150.getGeomagneticData();
Serial.print("mag x = "); Serial.print(magData.x); Serial.println(" uT");
Serial.print("mag y = "); Serial.print(magData.y); Serial.println(" uT");
Serial.print("mag z = "); Serial.print(magData.z); Serial.println(" uT");
float compassDegree = bmm150.getCompassDegree();
Serial.print("the angle between the pointing direction and north (counterclockwise) is:");
Serial.println(compassDegree);
Serial.println("--------------------------------");
Bridge.call("get_data", magData.x, magData.y, magData.z);
delay(50);
}
Python
from arduino.app_utils import *
def get_data( mx: int, my: int, mz: int):
"""Callback invoked by the board sketch via Bridge.notify to send sensor samples.
"""
values = []
values.append(mx)
values.append(my)
values.append(mz)
process_values(values)
def process_values(values):
print("Mag: %d, %d, %d" % (values[0], values[1], values[2]))
print("---------------------------------------")
#Create bridge to arduino
Bridge.provide("get_data", get_data)
print("Starting App...")
App.run()
However if I change the sketch and start the BMI270
Then the bus fault appears again
[00:00:00.221,000] os: ***** BUS FAULT *****
[00:00:00.228,000] os: Precise data bus error
[00:00:00.236,000] os: BFAR Address: 0x200c798c
[00:00:00.244,000] os: r0/a1: 0x20055ee8 r1/a2: 0x200c7988 r2/a3: 0x00000001
[00:00:00.255,000] os: r3/a4: 0x0000e328 r12/ip: 0x46002400 r14/lr: 0x08016ed5
[00:00:00.266,000] os: xpsr: 0x29002c00
[00:00:00.273,000] os: s[ 0]: 0x00000010 s[ 1]: 0x08016ff7 s[ 2]: 0x00000002 s[ 3]: 0x20055ee8
[00:00:00.286,000] os: s[ 4]: 0x2001e269 s[ 5]: 0x00000000 s[ 6]: 0x08094930 s[ 7]: 0x00000c30
[00:00:00.298,000] os: s[ 8]: 0xffffffff s[ 9]: 0x08017327 s[10]: 0x20021d68 s[11]: 0x00000008
[00:00:00.311,000] os: s[12]: 0x2001e269 s[13]: 0x0800adf3 s[14]: 0x0800ade1 s[15]: 0x20021d68
[00:00:00.324,000] os: fpscr: 0x2001e22d
[00:00:00.331,000] os: Faulting instruction address (r15/pc): 0x08016eac
[00:00:00.341,000] os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:00.351,000] os: Current thread: 0x200029d0 (main)
[00:00:00.360,000] os: Halting system
Not really sure why since when I ran it under 0.51.0 there was no issue. See: First App: BMM150/BMI270 IMU/AHRS Test - UNO Family / UNO Q - Arduino Forum