Connect iMX6UL-EVK with magnetic sensor GY-271(HMC5883L) via i2c

cancel
Showing results for 
Search instead for 
Did you mean: 

Connect iMX6UL-EVK with magnetic sensor GY-271(HMC5883L) via i2c

265 Views
toanjunifer
Senior Contributor I

Hi NXP,

I have a problem in connect magnetic sensor GY-271 with iMX6UL-EVK.

Firstly, I access menuconfig and turn driver of this sensor on. 

Device Drivers > Industrial I/O support > Magnetometer Sensors > Honeywell HMC5843/5883/5883L 3-Axis Magnetometer (I2C) 

Secondly, I customize device tree imx6ul-14x14-evk.dts in arch/arm/boot/dts by adding these line at the end of file:

&i2c4 {
    status = "okay";
    clock-frequency = <100000>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c2>;
    
    hmc5883l@1e {
        compatible = "honeywell,hmc5883l";
        reg = <0x1e>;
        position = <0>;
    };
};

Thirdly, I connect 4 pins of sensor to iMX6Ul kit with power supply is 3,3V and pin 9(SDA)-10(SCL) of J1704 header. <This step is fine>

Lastly, I check with command:

$ i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- UU -- -- -- 1e --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

It's not return UU in section 1e. It's mean I configured wrong somewhere.

1. What should I do now ?

2. How can I get data from sensor assume that I configured correctly?

As I know that If a device connect correctly, data will display in: /sys/bus/iio/devices/. That's true ?

Thank you so much,

Toan

Labels (1)
6 Replies

95 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Toan

one can check if SION bit is set for i2c signals, it is described

in IOMUX Chapter of i.MX6UL Reference Manual and check i2c signals

with oscilloscope.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

95 Views
toanjunifer
Senior Contributor I

Hi igorpadykov‌,

My question is:

  • How can I configure iMX6UL to connect with sensor ?

   In my case, iMX6UL detected sensor but when It isn't notice that connection successfully. It's only show address of sensor is 1e. If connection is successfully, It will show UU instead of 1e.

  • How can I get data from i2c sensor ?

Best regards,

      Toan

0 Kudos

95 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Toan

 

suggest to check i2c signals with oscilloscope.

 

Best regards
igor

95 Views
toanjunifer
Senior Contributor I

Hi igorpadykov‌,

Actually, I don't have any scope. So, Do we have another way ?

Thank you so much,

      Toan

0 Kudos

95 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Toan

had you obtained (created) driver for that module :

https://www.raspberrypi.org/forums/viewtopic.php?t=184556 

Best regards
igor

95 Views
toanjunifer
Senior Contributor I

Hi igorpadykov‌,

I turned on driver sensor in menuconfig and rebuild.

Thank you so much,

      Toan

0 Kudos