Hi Everyone,

We are now able to send multiple sensor values using ArduinoBle library.
as suggested at the following link:

Our next issue is that we are traying to connect multiple sensors to Arduino nano 33 ble using TCA9548A multiplexer and collecting the data using I2c Protocol.

We would like to send the data collected from multiple sensors using the multiplexer using ble.
However, when we try to do so the bluepy library (python code) is not able to connect to the arduino using ble.
it gives the following error (on raspbery pi zero, using bluepy python library):

"buepy.btle.BTLEDisconnectError: Failed to coonect to peripheral"

We are using the following code

#include "Arduino.h"
/* For the bluetooth funcionality */
#include <ArduinoBLE.h>
#include <Arduino_LSM9DS1.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#define TCAADDR 0x70
Adafruit_MPU6050 mpu;

// Defining Characteristics
#define BLE_UUID_SENSOR_DATA_SERVICE              "2BEEF31A-B10D-271C-C9EA-35D865C1F48A"
#define BLE_UUID_MULTI_SENSOR_DATA                "4664E7A1-5A13-BFFF-4636-7D0A4B16496C"

// Creating a union to store data

const int ledPin = LED_BUILTIN; // set ledPin to on-board LED
union multi_sensor_data
  struct __attribute__( ( packed ) )
    float values[NUMBER_OF_SENSORS];
  uint8_t bytes[ NUMBER_OF_SENSORS * sizeof( float ) ];

union multi_sensor_data multiSensorData;

// Given sensor i, select and write to it
void tcaselect(uint8_t i) {
  if (i > 7) return;

  Wire.write(1 << i);

//Service for publish Accelerometer value...

BLEService sensorDataService( BLE_UUID_SENSOR_DATA_SERVICE );
multiSensorDataCharacteristic( BLE_UUID_MULTI_SENSOR_DATA, BLERead | 
BLENotify, sizeof multiSensorData.bytes );
float acc_x, acc_y, acc_z;

void setup() {
  while (!Serial);

  pinMode(ledPin, OUTPUT); // use the LED as an output
  // BLE initialization
  if (!BLE.begin()) {Serial.println("starting BLE failed!");
    while (1);
  // IMU initialization
  if (!IMU.begin())
  {Serial.println("Failed to initialize IMU!");
    while (1);
  // set the local name peripheral advertises
  // BLE add characteristics
  sensorDataService.addCharacteristic( multiSensorDataCharacteristic );
  // add service
  BLE.addService( sensorDataService );
  // set the initial value for the characeristic:
  multiSensorDataCharacteristic.writeValue( multiSensorData.bytes, sizeof multiSensorData.bytes );
  Serial.println("Bluetooth Device Active, Waiting for Connections...");
  Serial.println(" AX \t AY \t AZ");

void loop() {
  BLEDevice central = BLE.central();
  if(central) {
    Serial.print("Connected to Central: ");
    while(central.connected()) {
            IMU.readAcceleration(acc_x, acc_y, acc_z);
            multiSensorData.values[0] = acc_x;
            multiSensorData.values[1] = acc_y;
            multiSensorData.values[2] = acc_z;
            // We can easily capture and send acc_x,acc_y and acc_z in our data packet using ble
            // If we exclude the following part of the code, then we can collect the data in python using our previous code. 
            sensors_event_t a, g, temp;
            mpu.getEvent(&a, &g, &temp);
            multiSensorData.values[3] = a.acceleration.x; //a.acceleration.x;
            multiSensorData.values[4] = a.acceleration.y; //a.acceleration.y;
            multiSensorData.values[5] = a.acceleration.z; //a.acceleration.z;
           // if we add a.acceleration.x,a.acceleration.y,a.acceleration.z then the python code gives us 
           // the above error
            multiSensorDataCharacteristic.writeValue( multiSensorData.bytes, sizeof multiSensorData.bytes );

  Serial.print("Disconnected from Central: ");


Any suggestions are welcome.

I am a beginner in embedded software design, and it would help me a lot if I can learn to get over this issue.
Thank you in advance

Can you post a schematic, not a frizzy thing showing all the interconnections, links to technical information on all hardware devices. This could be an interface problem (3.3 to 5) qne or a grounding problem.

I am able to read the values and display them in the serial plotter. The error is when I try and send it over ble.

We still need the the requested information. You state parts but I do not have a clue what they are. "inbuilt" into what? The TCA9548A is a chip what module are you using, they are not all the same.