Hi there. I'm trying to use two I2C sensors (HW-246 GY-271) simultaneously. From what I've read it should be possible to have the two sensors connected to the same pins on the Arduino. I also have a Teensy, which has multiple I2C pins. But the libraries (QMC5883L) I'm using don't have any method for assigning pins. Can any one guide me a bit into the ins and outs of this? I'm quite lost in between assigning I2C pins in the libraries used and identifying multiple I2C devices and can't really find info on either topic...
Please give a link to the datasheet.
Unfortunately not.
You will need to use an I2C multiplexer to use two at the same time.
Unfortunately the sensor has no provisions for multiple I2C addresses. See #3 for a solution.
Some libraries allow to set a I2C bus.
Other libraries use just "Wire", but you can make a copy of the *.h and *.cpp file and add them to your project, and change all the "Wire" with "Wire1".
Give the files and the class a different names, so they are not confused with the original library.
Ok great! I'm going to dive into this. Thanks!
This looks like a very solid alternative. Thank you!
One other alternative is to use a software version of the I2C. It will enable you to create another I2C bus , so no need for a multiplexer
So one compass connected to the Hardware I2C and one connected to the Software I2C.
Followed instructions in topic underneath and now have two compass sensors running simultaneously on two I2C busses on a Teensy 4.1
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.