Changing I2C address

Hello.
I want to use 2 maxsonar sensors(I2CXL-MaxSonar-EZ4) for my pixhawk 4 mini.
However, after I connect two sensors, I can get the data from only one sensor.
Then I realized that I should change the address of them.
But I cannot find the way of changing the address.
I’m using ubuntu 18.04 and pixhawk 4 mini.
Please help me.
Thank you.

A procedure for changing the address via I2C is on page 3 of this datasheet, and on page 2 it says you can pull pin 1 low to use the address stored in memory via that procedure.

It might be easiest to hook up one sensor to an Arduino to configure the address if you can.

Thank you for your reply!
I didn’t have any plan to use arduino but I should use it.
Thank you for your help again.

I’m still trying to change the address…
Can you help me with the pinout using Sonar sensor and arduino nano?
Do I have to use pin1 and pin2 on the Sonar sensor?

Sure thing. Are you familiar at all with hooking up I2C and with things like pull-ups and pull-downs?

In short, no, you don’t need pin 1 or 2 hooked up on the Arduino.

Based on the datasheet, pin 1 and 2 aren’t important for your Arduino hookup.

Pins 4 and 5 are the I2C should be hooked up to their corresponding pins on the Nano.

As far as Arduino code goes, here’s an example that even includes address changing:

Since you will eventually have two sensors mounted, this guide I happened upon might also be useful to you once you get them addressed properly.

Thank you for your reply!!
Refer to your reply, I have succeeded to change the address of my sensor.
However, according to the Maxsonar datasheet, I have to pull pin 1 high or disconnect to use the address that I changed.
Am I right?
Thanks again.

Great!

You are correct about pin 1; I guess I mixed it up in my head.

1 Like