I have two questions relating to a magnetometer connected via I2C.
- I’m trying to debug a magnetometer *1 and an accelerometer *2 on a Sony Spresense using I2C, and I see some curious behavior. If I have just the magnetometer connected, and run “I2C> scan -v”, it finds the magnetometer, though not at the correct address as given in the data sheet. If I connect the accelerometer, I don’t see either device in the BP “scan” output. However, under Nuttx on the Spresense, I have the “i2c” tool installed, and it shows both devices attached.
So the Spresense sees both devices, and the BP sees neither. I’d question my wire connections, but since the Spresense sees both, I think it has to be something else. Any idea?
- The other question relates to I2C IDs. In the data sheet for the HMC5883L magnetometer, it says the address is 0x1E (7 bit), but it actually appears at 0x0d. The Spresense also lists the device at 0x0d, so I think it’s plausible. “scan -v” lists the device as “MLX90393 3-Axis Magnetometer.” Is that from an internal table of possible devices at given I2C IDs, or is that read from the device itself? Do I2C devices sometimes have the wrong ID?
#1: HMC5883L GY-273 Three-axis Magnetic Field Sensor
#2: Adafruit Triple-Axis Accelerometer - ±2/4/8g @ 14-bit - MMA8451 : ID 2019 : Adafruit Industries, Unique & fun DIY electronics and kits