I am not experienced about I2C communications, but I do happen to have two HMC5883L magnetometer modules that I wish to connect to a single arduino. It uses I2C protocol, and hence the slave device will have a fixed address. Now Can I change the address of one of my sensors so that the Arduino can differentiate between the two? (I seem to find no way out by reading the datasheet) Thanks in Advance Siddharth Jha

P.S. Can an MPU 6050 module be used to find angle of rotation in X-Y plane (Parallel to the ground)?

  • Just take a look at the datasheet for this component. Typically, when a component is likely to exist in several instances on the same I2C bus, then that component has a way to select one among a few addresses; that's typically done through little switches on the board (or possibly by soldering a short somewhere on the PCB).
    – jfpoilpret
    Jan 21 '15 at 22:19

The problem is with the magnetometer: "The HMC5883L has a fixed I2C address, you can only connect one sensor per microcontroller!" Wiring and Test

Also, it says it in the specs on page 2: I2C Address 8-bit read address 0x3D 8-bit write address 0x3C 3-Axis Digital Compass IC HMC5883L

Low cost magnetometers appear to have fixed I2C addresses. One solution would be to get a different one in addition to yours. For example, the MAG3110 has I2C address 0x0E and the FXMS3110CDR1 has I2C address 0x0F. Xtrinsic MAG3110 Three-Axis, Digital Magnetometer

More information on this page:

How to connect multiple of the same device to an Arduino using I2C?

P.S. You are more likely to get an answer to your second question by posting it separately (and help others in the process).


You can't change the address. You could connect it to some other pins, and bit-bang the I2C protocol.

Or connect the vcc of the unit to an arduino pin, so you can turn it on and off.

  • 1
    Enabling only one device is a good idea; doing it by switching Vcc usually isn't. In addition to possible startup time, generally speaking IOs should not exceed the supply voltage except where it is documented that is allowed. Jan 22 '15 at 18:02
  • Good point. You could add a some buffer logic, but that would make it a bit more complicated.
    – Gerben
    Jan 22 '15 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.