Search code examples
adbgpioi2candroid-thingsmagnetometer

In ADB Shell, PIO is not picking up I2C device


ADB PIO is not picking up an I2C device (HMC5883L Magnetometer).

I have the magnetometer connected correctly to VCC, GND, SDA & SCL. Then within adb shell I use pio i2c I2C1 0x3D read-raw 1 and it's giving me [WARNING:client_errors.cc(35)] error 6: No such device or address

I am wondering what I'm missing, any help would be appreciated!

Stats:
Android-Things
NXP i.MX7d on PICO-Pi
HMC5883L 3 Axis Magnetometer on I2C
Android Studio - Command Line ADB

Solution

  • I have the magnetometer connected correctly to VCC, GND, SDA & SCL. Then within adb shell I use pio i2c I2C1 0x3D read-raw 1 and it's giving me [WARNING:client_errors.cc(35)] error 6: No such device or address

    There are potentially a couple things wrong with this command, according to the HMC5883L datasheet:

    1. The device uses register-based access which means a raw read is likely to fail. You should be using a command like read-reg-byte to test communication with the device.
    2. The I2C device address is 0x1E. The datasheet gives you the completed 8-bit format of the address in a full byte (which is 0x3D and 0x3C, depending on the R/W bit), which is a bit confusing.

    So a better command for you to send and test your device would be this one, which should report the value of the STATUS register:

    $ pio i2c I2C1 0x1E read-reg-byte 0x09
    

    If you still receive the same error with the above command, check the pinout diagram to verify you are connected to the right I2C port (I2C1 vs. I2C2).