How to connect 30 BNO055 Sensors to RPI

Hi,

I want to connect maximum of 30 BNO055 9DOF motion sensors to RPI module. Could you please suggest how it can be done.

Thanks,
Arindam

3 Likes

Hi Arindam,

You’re going to run into address conflict issues. You can however get I2C address changer ICs that sit in between and allow you to effectively run multiple devices with the same address on a single bus - can’t remember what they’re called off the top of my head but I’m sure a quick google will set you straight.

I think sparkfun or adafruit have some on a breakout.

Also don’t forget to cut the pull ups on must of them - or your devices won’t be able to pull the bus low to be able to communicate.

5 Likes

Thank you Oliver for response. I just bought Gravity: Digital 1-to-8 I2C Multiplexer, to connect 8. Now if I have 2 of then does it mean I can connect 16. I am googling last few days could not find proper guidance on the same

really appreciate if you could help.

6 Likes

I2C multiplexer - that’s it :slight_smile:

The default I2C address of the multiplexer is 0x70, and you can adjust from 0x70 to 0x77.

Looks like it should work for you just fine. DFRobot have only got code for an Arduino though so you’ll need to write your own for a Pi. Looking at their Arduino library code and the datasheet will be very helpful.

Yes, 2 will let you connect 16 devices.

Here’s the link to the wiki:
https://wiki.dfrobot.com/Gravity__Digital_1-to-8_I2C_Multiplexer_SKU_DFR0576

6 Likes

Thank you so much. Much appreciated.

Here is RPI code. Hope this will work

6 Likes

Thanks for confirming that Oliver, I was unsure if you could add more than one multiplexer when Arindam asked via the website chat today, but looks like I just missed that line in the Wiki that confirms!

Great to hear Arindam, you can now connect your 60 I2C devices together as you hoped by adding extra multiplexers! :smiley:

4 Likes

Ahh, awesome, nice find! They just need to update their wiki page, they do have a pyrhon library for it.

Fingers crossed you should be all sorted!

1 Like

Hi All
Excuse me for butting in here. I have not had a play with I2C as yet but from reading forum posts there seems to be quite a short distance limitation when it comes to communicating with this format.

What are you going to do with 30 sensors. I believe that if you are going to use I2C to communicate they will all have to be on the same table or all in one spot which will be a bit of an overkill if you are detecting motion.

I don’t want to throw a spanner in the works but has anyone considered this???
Cheers Bob

5 Likes

It’s a good point! Depends how fast your clock speed is, and how much data throughput you need. I2C doesn’t have a minimum clock speed specified so you can run it pretty slow if need be to help with transmission line issues.

There are also active signal boosters available - some which just add some extra current to help square up the waveform, and some that are designed as long range extenders that convert it to a different electrical transmission method, then back to normal I2C at the other end, which can get you very long runs (more than 50m).

4 Likes

Hi Oliver
With RS485 a claimed 1200M and a max of 32 drops… Need to be a bit careful here though. It was previously discovered that some of these converters had on board 120Ω terminating resistors fitted. all these except the end units have to be removed or links removed (I think some have linkable resistors).Far better to remove all of them and fit physical resistors so they can easily be seen.
Cheers Bob

5 Likes

Hello all,
My son is building a human motion capture suit for his gaming program in the school. He needs 17 sensors for human body to capture the orientation data. 1 sensors will go to the head. 10 sensors will be used in the figures.
Maximum distance between the sensors to RPI will be 30cm. And the frequency of all the sensor data will be no more than 10ms.

All the sensors orientation data he will transmit from RPI to his game via bluetooth or WIFI. That’s why this I2C solution was been asked.

Is that feasible?

Please let me know.

Thanks,
Arindam

6 Likes

Hi Arindam,

While the electronics of the project is do-able, some bus lengths have been tested to well over 2m and still worked, the motion capture portion of it will be quite a project if there isnt already software to achieve this.

Unfortunately there arent really many sensors that are able to measure absolute position, camera’s(with some software attached) can measure objects relative to eachother, and potentiometers and encoders can map a voltage to a position (depending on which type you get).
These motion sensors are really good at measuing acceleration and angular rotation but finding a velocity can get hard(very hard with position).

There’s a neat video here of something similar being demonstrated: Live motion tracking - Raspberry Pi

5 Likes

Hi Arindam,

The mathematics and modelling required to get that to work nicely is advanced University level stuff - probably final year undergrad or post graduate level, and this would probably take 12-24 months to get working well.

I’d strongly recommend starting with a proof of concept with just one accelerometer, and explain how that could be expanded to a full motion capture suit - even this would be a very impressive challenge for any school student.

Combining inputs from multiple sensors, assuming they aren’t rigidly connected and in parallel orientations, requires advanced trigonometry and matrix algebra, and then you need to be able to program that maths into a microcontroller.

See:

If he can grasp it conceptually, that would be more than enough. The implementation is definitely too much though.

4 Likes

Hi All,

I just came across this video that explains an integral part of the project: Accelerometers and Gyroscopes - Sensor Fusion #1 - YouTube

5 Likes

Hi Guys,

Thank you very much for the information. We are well aware of the complication and we already have done that by using Kalman Filter. In the sensors we have implemented the calibration logic to fix the sensor bias due to the magnetic interference.

We already have implemented the stage one, where we get the data out of MPU9250 and send it to PC via serial port communication.

Here is how the data looks like when we received it in PC.
a(g): -0.0215 0.0469 1.0098 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1694.0000 5107.0000 16946.0000 Angle(deg): 2.6697 1.2469 -103.0682
a(g): -0.0220 0.0469 1.0098 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1688.0000 5104.0000 16972.0000 Angle(deg): 2.6697 1.2415 -103.0682
a(g): -0.0215 0.0469 1.0103 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1686.0000 5111.0000 16946.0000 Angle(deg): 2.6697 1.2415 -103.0682
a(g): -0.0220 0.0469 1.0098 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1682.0000 5119.0000 16977.0000 Angle(deg): 2.6697 1.2415 -103.0682
a(g): -0.0215 0.0474 1.0103 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1691.0000 5113.0000 16954.0000 Angle(deg): 2.6697 1.2415 -103.0682
a(g): -0.0220 0.0469 1.0103 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1702.0000 5115.0000 16987.0000 Angle(deg): 2.6697 1.2469 -103.0682
a(g): -0.0210 0.0469 1.0098 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1685.0000 5113.0000 16961.0000 Angle(deg): 2.6697 1.2469 -103.0682
a(g): -0.0215 0.0464 1.0098 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1679.0000 5108.0000 16969.0000 Angle(deg): 2.6697 1.2469 -103.0682
a(g): -0.0229 0.0474 1.0103 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1685.0000 5112.0000 16980.0000 Angle(deg): 2.6697 1.2469 -103.0682
a(g): -0.0220 0.0464 1.0103 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1688.0000 5113.0000 16962.0000 Angle(deg): 2.6697 1.2469 -103.0682
a(g): -0.0215 0.0469 1.0098 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1691.0000 5108.0000 16970.0000 Angle(deg): 2.6697 1.2469 -103.0682
a(g): -0.0220 0.0469 1.0093 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1701.0000 5116.0000 16976.0000 Angle(deg): 2.6697 1.2469 -103.0682
a(g): -0.0205 0.0469 1.0103 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1686.0000 5116.0000 16971.0000 Angle(deg): 2.6697 1.2469 -103.0682
a(g): -0.0225 0.0469 1.0103 w(deg/s): 0.0000 0.0000 0.0000 Mag: 1689.0000 5118.0000 16985.0000 Angle(deg): 2.6697 1.2469 -103.0682

Currently frequency I have set around 10ms.

The same data when we ported to Unreal engine it looks like below:

The reason I asked the original question is to figure out the electronics part, when I havw more than 1 sensors data coming in -

  1. We are changing the connectivity from TTL to I2C and using RPI + Multiplexer connect multiple such sensors.
  2. RPI is to make the communication remote over UDP via WIFI

I have already received the multiplexer and now need to solder the sensors with it so that I can get multiple sensor data.

It will be fun :slight_smile:

Once again thank you for the help. Will update you the progress, if you are interested.

Thanks,
Arindam

7 Likes

Hi Guys,

Thank you for the support. I have achieved the initial milestone, which is RPI 4 + I2C Multiplexer (Gravity) + 2 BNO055. I have used python to extract the data. Here is the code.

import board
import adafruit_tca9548a
import adafruit_bno055
from datetime import datetime
import socket

i2c = board.I2C()
tca = adafruit_tca9548a.TCA9548A(i2c)
for channel in range(8):
    if tca[channel].try_lock():
        print("Channel {}:".format(channel), end="")
        addresses = tca[channel].scan()
        print([hex(address) for address in addresses if address != 0x70])
        tca[channel].unlock()

sensor0 = adafruit_bno055.BNO055_I2C(tca[0])
sensor1 = adafruit_bno055.BNO055_I2C(tca[1])
last_val = 0xFFFF
serverAddressPort   = ("192.168.1.143", 3002)
UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)

def temperature(sensor):
    global last_val  # pylint: disable=global-statement
    result = sensor.temperature
    if abs(result - last_val) == 128:
        result = sensor.temperature
        if abs(result - last_val) == 128:
            return 0b00111111 & result
    last_val = result
    return result

time.sleep (2)

while True:
    now = datetime.now()
    current_time = now.strftime("%H:%M:%S")
    print("Sensor0: ", current_time, " Temperature: {} degrees C".format(temperature(sensor0)), " Accelerometer (m/s^2): {}".format(sensor0.acceleration), " Euler angle: {}".format(sensor0.euler), " -- Calibration: {}".format(sensor0.calibration_status))
    # message = '{ "x":%10.4f,"y":%10.4f, "z":%10.4f}'%sensor0.euler
    # UDPClientSocket.sendto(str.encode(message), serverAddressPort)
    print()
    print("Sensor1: ", current_time, " Temperature: {} degrees C".format(temperature(sensor1)), " Accelerometer (m/s^2): {}".format(sensor1.acceleration), " Euler angle: {}".format(sensor1.euler), " -- Calibration: {}".format(sensor1.calibration_status))
    print()
    time.sleep(1/10)

So far performance is pretty good. And BNO055 calibration takes 10 sec
I am waiting for my other BNO055 to arrive.

Here is the circuit and output:

Output:

Sensor0:  07:28:11  Temperature: 29 degrees C  Accelerometer (m/s^2): (6.71, 0.63, -7.32)  Euler angle: (187.625, 42.375, -171.875)  -- Calibration: (3, 3, 3, 3)

Sensor1:  07:28:11  Temperature: 30 degrees C  Accelerometer (m/s^2): (4.8, 6.18, -6.140000000000001)  Euler angle: (314.3125, 30.0, -134.375)  -- Calibration: (3, 3, 3, 3)

Sensor0:  07:28:11  Temperature: 29 degrees C  Accelerometer (m/s^2): (6.54, 0.89, -7.17)  Euler angle: (187.75, 42.375, -171.9375)  -- Calibration: (3, 3, 3, 3)

Sensor1:  07:28:11  Temperature: 30 degrees C  Accelerometer (m/s^2): (4.86, 6.22, -5.96)  Euler angle: (314.375, 30.0, -134.25)  -- Calibration: (3, 3, 3, 3)

Sensor0:  07:28:11  Temperature: 29 degrees C  Accelerometer (m/s^2): (6.53, 0.8300000000000001, -7.21)  Euler angle: (187.6875, 42.1875, -171.9375)  -- Calibration: (3, 3, 3, 3)

Sensor1:  07:28:11  Temperature: 30 degrees C  Accelerometer (m/s^2): (4.78, 6.33, -6.03)  Euler angle: (314.8125, 29.75, -134.25)  -- Calibration: (3, 3, 3, 3)

I hope this helps. If need more information happy to provide. If something I am not doing right please guide.

Thanks,
Arindam

5 Likes

Hi Arindam,

Looks like quite the project! I’m keen to see this one come through! Would you mind sharing the equations you used in the Kalman filter? I’m quite curious :smiley:

PS: from the look of the connections to your sensors they look to be uncovered, it would definitely be worth getting a housing or some electrical tape around them.

5 Likes

Hi Liam,

Here is the link of Kalman filter.
https://pykalman.github.io/

I had to use it for MPU9250 as it’s orientation is not accurate due to magnetometer bias, And honestly, calibration took long time. Hence I tried BNO055, which has inbuilt sensor fusion and the library is exposed by adafruit. Here is the link
https://circuitpython.readthedocs.io/projects/bno055/en/latest/api.html

So for me, I just had to implement the library and watch the calibration status - 0 (Not calibrated) - 3 (Fully calibrated) for system, gyro, accel, magnetometer.

I spent lot of time understanding the sensor fusion between accel + gyro and magnetometer. It’s fun reading but don’t want to implement by myself as it is already there. Here are some nice tutorials, which you can follow to learn.

So far, I have tested BNO055 in several situation. Honestly, it is much better product and very much stable. If you want to try it with Arduino, here is the link


Regarding sensor cover, I am planning to enclose it inside a plastic case, so that I can fix it in several body position by tape. Could you please guide me how / where from I can get such enclosers? Currently my cable lengths are small, just googleing how can I get bigger jumper cables.

I do not have any electronics background, so far google knowledge, any help to bring this prototype live will be appreciated.

Thanks,
Arindam

5 Likes

Hi Arindam,

As for seperate customised enclosures you’ll have a few options, CAD up your own and 3D print them, or use a vacuum forming machine to make some quick ones.

I also think Liam was refering to the cables electrical contacts being exposed, there is definitely a risk of a short happening in there, to close up some standard crimp pins you can use these connector housings

For longer cables you could go down the route of creating your own, check out Core’s tutorial here: https://core-electronics.com.au/tutorials/how-to-crimp-custom-connectors.html
There’s also been some good discussion on cable flexibility on this topic from Bob and James, this will definitely come into play here.

Let us know how you go!
Liam

4 Likes

Hi Liam,

Thanks for the information. I am learning a lot, much appreciated. For my project I am looking for 4 female black plastic encloser and 6 female black plastic encloser. In the diagram, 6 female will connect to BNO055 and 4 female will connect to Gravity i2c multiplexer. Could you please share some link of core-electronics site so that I can order the black caps of 4 and 6 so that I can add them together.

Also could you please share a link to buy the cables - red, black, green and white.

Might be my ask is very novice, but with you honestly I am learning a lot.

Regarding custom encloser, I do not have any 3d printer or cad tool. Could you guy can hep me build those or may be a link from where I can order those without buying a 3D printer, as it is one time for me.

Thanks again
Arindam

3 Likes