I2C Connection Magnetometer


I am trying to get the MAG3110 Triple Axis Magnetometer to work with the jetson nano, through some python code. The first I am doing is seeing if the jetson will even detect it with the


command and it does when I do

i2cdetect -y -r 1

Due to me connecting the SDA/SCl into the bus 1 ports. My output in the terminal gives me a 0e which is correct for the address that is for the Magnetometer (0x0e hexadecimal or 14 decimal).

I’m curious when I run simple commands in python from the smbus2 library such as


I get stuff that repeat and make no sense. I get a bunch of 0s followed by a 196, then 0s by 247 and this repeats.

When I hook the MAG3110 to an Arduino and run

#include <SparkFun_MAG3110.h>

MAG3110 mag = MAG3110(); //Instantiate MAG3110
void setup() {
  mag.initialize(); //Initializes the mag sensor
  mag.start();      //Puts the sensor in active mode
void loop() {
  int x, y, z;
  //Only read data when it's ready
  if(mag.dataReady()) {
    //Read the data
    mag.readMag(&x, &y, &z);
    Serial.print("X: ");
    Serial.print(", Y: ");
    Serial.print(", Z: ");

It works like a charm.

Anyone run into the same problem with a MAG3110 or any i2c data reading problems?

Does i2cget get correct value?

Hi ShaneCCC,

If I do

i2cget -y 1 0x0E

I get


If I do

i2cget -y 1 0x0E 0x0E b

I get


If I do

i2cget -y 1 0x0E 0x0E w

I get


Any kernel message while do the i2cget command?

No none

I think there no problem for the host, you may need consult with vendor what’s the correct way to access this device.