Use with BMI160 adafruid TCA9548A multiplexer
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Lmuh
- Posts: 3
- Joined: Sun Jan 23, 2022 8:31 am
Use with BMI160 adafruid TCA9548A multiplexer
I have a project where I use the BMI160 sensor. I am using raspberry pi in my project. I need to use 6 BMI160s in my project. When I use only one BMI160, I can read all the data correctly. I use i2c as the communication protocol. In order to read 6 BMI160 sensors, I need to use Adafruid TCA9548A multiplexer. How can I read these 6 sensors that I want from you through the multiplexer? As a result of my research, I couldn't find a decent code. By the way, I am using python as programming language. Can anyone help me with a sample code on this? Thanks
- dastels
- Posts: 15655
- Joined: Tue Oct 20, 2015 3:22 pm
- Lmuh
- Posts: 3
- Joined: Sun Jan 23, 2022 8:31 am
Re: Use with BMI160 adafruid TCA9548A multiplexer
Thank you for your response. I applied the example in this link, I applied it to my own project, but it was not successful. While BMI160 is reading the data, I am reading it using the BMI160 i2c library. If you want to help with this, I can send you the code I wrote. Maybe you can help better that way.
- dastels
- Posts: 15655
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Use with BMI160 adafruid TCA9548A multiplexer
What problem are you seeing?
Dave
Dave
- Lmuh
- Posts: 3
- Joined: Sun Jan 23, 2022 8:31 am
Re: Use with BMI160 adafruid TCA9548A multiplexer
Code: Select all
from BMI160_i2c import Driver
import time
class BMI160(object):
def __init__(self):
self.adr=Driver(0x69)
self.AcXArray = list()
self.AcYArray = list()
self.AcZArray = list()
self.GcXArray = list()
self.GcYArray = list()
self.GcZArray = list()
def data(self):
while True:
self.read_data = self.adr.getMotion6()
self.gyro_xout_scl = (self.read_data[0]-37.725) / 131
self.gyro_yout_scl = (self.read_data[1]-25.214) / 131
self.gyro_zout_scl = (self.read_data[2]+61.08) / 131
self.GcXArray.append(self.gyro_xout_scl)
self.GcYArray.append(self.gyro_yout_scl)
self.GcZArray.append(self.gyro_zout_scl)
self.accel_xout_scl = (self.read_data[3]-300.367) / 16384.0
self.accel_yout_scl = (self.read_data[4]+540.228) / 16384.0
self.accel_zout_scl = (self.read_data[5]-533.868) / 16384.0
self.AcXArray.append(self.accel_xout_scl)
self.AcYArray.append(self.accel_yout_scl)
self.AcZArray.append(self.accel_zout_scl)
time.sleep(0.010)
After installing the BMI160 i2c library the above
I can read both acceleration and gyro data with codes. When I read with multiplexer, the data lists are empty when I do as in the example codes you sent. Below is a small sample code that I use while reading with multiplexer.
import time
import board
import BMI160
import adafruit_tca9548a
i2c = board.I2C()
tca = adafruit_tca9548a.TCA9548A(i2c)
IMU1 = BMI160.sensor1(tca[0])
# IMU2 = BMI160.sensor2(tca[1])
while True:
print(IMU1.data)
time.sleep(0.01)
Last edited by dastels on Mon Jan 24, 2022 12:05 pm, edited 1 time in total.
Reason: add code tags
Reason: add code tags
- dastels
- Posts: 15655
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Use with BMI160 adafruid TCA9548A multiplexer
You think? What, exactly happens? What gets output in the REPL?
If you aren't familiar with using the REPL (or even just the serial connection), see
https://learn.adafruit.com/welcome-to-c ... al-console
https://learn.adafruit.com/welcome-to-c ... al-console
https://learn.adafruit.com/welcome-to-c ... n/the-repl
Dave
If you aren't familiar with using the REPL (or even just the serial connection), see
https://learn.adafruit.com/welcome-to-c ... al-console
https://learn.adafruit.com/welcome-to-c ... al-console
https://learn.adafruit.com/welcome-to-c ... n/the-repl
Dave
Please be positive and constructive with your questions and comments.