This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE Softdevice crashes when more than one device on I2C bus

Hi

I'm working with the following products to develop a product and have chosen to use a IDE based around Arduino and Visual Studio Code. This iDE along side off the shelf products allows for rapid simple programme and hardware construction for testing and evaluation without the for deep C knowledge prior to moving to a formal product development cycle. Therefore some of the products being used rely on the Adafruit versions of the Arduino libraries to function.

Products:

SparkFun Pro nRF52840 Mini - Bluetooth Development Board - https://www.sparkfun.com/products/15025?_ga=2.135426737.141134967.1579786966-1791920524.1576505606

SparkFun IMU Breakout - MPU-9250 - https://www.sparkfun.com/products/13762?_ga=2.218676889.141134967.1579786966-1791920524.1576505606

SparkFun Micro OLED Breakout - https://www.sparkfun.com/products/14532

I'm using I2C for the communications bus between the nrf52 and the two peripherals (MPU-9259 & Micro OLED). I have successfully connected both devices and driven output to the display and received a response from the IMU, using the following code:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <MPU9250.h>
#include <SFE_MicroOLED.h> // Include the SFE_MicroOLED library - I2C address of 0X3D (ADDR pin open 0X3D | closed 0X3C)
#define SerialDebug true // Set to true to get Serial output for debugging
// MicroOLED Definition
#define PIN_RESET 9 // Connect RST to pin 9 (req. for SPI and I2C)
#define DC_JUMPER 1 // Set to either 0 (default) or 1 based on jumper, matching the value of the DC Jumper
// Also connect pin 13 to SCK and pin 11 to MOSI
// Declare a MicroOLED object. The parameters include:
// 1 - Reset pin: Any digital pin
// 2 - D/C pin: Any digital pin (SPI mode only)
// 3 - CS pin: Any digital pin (SPI mode only, 10 recommended)
MicroOLED oled(PIN_RESET, DC_JUMPER); //Example I2C declaration, uncomment if using I2C
//MPU9250 Definition
#define I2Cclock 400000
#define I2Cport Wire
#define MPU9250_ADDRESS MPU9250_ADDRESS_AD0 // Use either this line or the next to select which I2C address your device is using
//#define MPU9250_ADDRESS MPU9250_ADDRESS_AD1
MPU9250 myIMU(MPU9250_ADDRESS, I2Cport, I2Cclock);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The following output is produced with the phrase 'StingRay' displayed on the OLED:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
setup - Serial.begin()
setup - Wire.begin()
setup - oled.begin()
MPU9250 Test
------------
MPU9250 I AM 0x71 I should be 0x71
MPU9250 is online...
x-axis self test: acceleration trim within : 1.4% of factory value
y-axis self test: acceleration trim within : 0.0% of factory value
z-axis self test: acceleration trim within : 2.5% of factory value
x-axis self test: gyration trim within : -4.4% of factory value
y-axis self test: gyration trim within : -1.1% of factory value
z-axis self test: gyration trim within : -0.3% of factory value
MPU9250 initialized for active data mode....
AK8963 I AM 0x48 I should be 0x48
AK8963 initialized for active data mode....
X-Axis factory sensitivity adjustment value 1.18
Y-Axis factory sensitivity adjustment value 1.18
Z-Axis factory sensitivity adjustment value 1.14
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

My problem starts when I begin the implementation BLE. I add the following code:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <bluefruit.h>
void setup()
{
...
...
...
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.begin();
if (SerialDebug) {
Serial.println("setup - Bluefruit.begin()");
}
Bluefruit.setTxPower(4); // Check bluefruit.h for supported values
Bluefruit.setName("mStingRay");
...
...
...
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

At this point I have not implemented any more BLE functionality as my device crashes as soon as I reach Bluefruit.begin().

Any help/guidance please.

Thanks in advance ...