1

I am trying to set up my magnetometer QMC5883L with my raspberry pi 4.

But the pi is somehow not reading the magnetometer.

I ran the command i2cdetect -y 1, but there is no detection.

My connections seem to be secure, and I have installed and updated all the necessary components also:

  1. sudo apt-get update
  2. sudo apt-get upgrade
  3. sudo apt-get install i2c-tools
  4. sudo apt-get install python-smbus
  5. sudo apt-get install python3

I have set up the i2c interface active as well, using:

sudo raspi-config -> Interface -> i2c -> "YES"

I have also crossed checked the presence of all the required kernels at boot up time

  1. i2c-dev
  2. i2c-bcm2835
  3. snd-bcm2835

I am still not able to figure out what the issue exactly is, have I missed some module or kernel out ?

Following is the link of the module/sensor being used:

https://robu.in/product/gy-271-hmc5883l-3-axis-electronic-compass-module-magnetic-field-sensor-china-chip/

(The above link has all the attachments like datasheet and library of the magnetometer)

2 Answers 2

0

You have not properly connected the device to the I2C bus.

Can not say any more than that as there is no link to the device being used or clear photos of the wiring.

4
  • I have added the link of the magnetometer which I missed out on earlier. Hopefully this can give a better picture of my dilemma.
    – Omickey
    Commented Jul 17, 2021 at 7:36
  • We need a clear photo showing the wiring. A common error is to not solder the header pins to the device.
    – joan
    Commented Jul 17, 2021 at 9:02
  • Okay, I shall update a picture asap, but does the rest look fine ?
    – Omickey
    Commented Jul 17, 2021 at 10:30
  • turns out it was a soldering issue, thanks for the help @joan
    – Omickey
    Commented Jul 21, 2021 at 9:26
0

I agree, most likely it's a wiring issue, check that you don't have SCL/SDA reversed and check if you have power at the the device.

a couple more things to consider. you might need pull-up resistors.

the other possibility is that this could be an issue with clock stretching. I had a difficult time when I tried to interface a NEO-M9N gps module to the pi using I2C. I wrote about it here https://vinthewrench.substack.com/p/picar-raspberry-pi-car-radio-project-f0b

I setup an additional I2C port (GPIO 19 and 26) using the software bit-banging code in the driver. Added this to /boot/config.txt file:

dtoverlay=i2c-gpio,i2c_gpio_sda=19,i2c_gpio_scl=26

This created another I2C port at /dev/i2c-22.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.