4

I've been following a tutorial to hook up an electronic compass that relays info to the Pi via i2c. The only differences between my equipment and the tutorial's is that I am using a Raspberry Pi 3 with Python 3 already installed, and the HMC5883L compass I am using has been bundled with a few more sensors than that being used in the tutorial.

I've triple checked my connections, and am certain that VCC is hooked up to 3.3V, GND to GDN, SDA to SDA, and SCL to SCL.

The back of the compass

I have confirmed that i2c-tools and libi2c-dev are installed, as well as python-smbus.

i2c-devand i2c-bcm2708 have been added to /etc/modules

dtparam=i2c_arm=onand dtparam=i2c1=onhave been added to /boot/config.txt

i2c-bcm2708has been removed from the blacklist.

However, when I type the

i2cdetect -y 1

command, all I see is an empty address field.

UPDATE

It has been brought up that this is an SPI device and not an i2c device. I am not sure if that is the issue, as the vendor page says that it outputs in the i2c format. In addition, the data sheet the vendor provides for the compass on the sensor directly describes the compass as an i2c device.

More explicitly, my question is "how to I get the Raspberry Pi 3 to recognize an i2c device?"

FIX

Connecting the chip directly to the SDA and SCL from the Pi to the chip with no breadboard intermediate fixed the problem. wat

15
  • How are the pins labelled on the sensor and have you a link to the sensor specs?
    – joan
    Commented Apr 21, 2017 at 22:14
  • Hi. The spec sheets are available to download from the vendor's page here. The pins are labeled VCC_IN, 3.3V, GND, SCL, SDA, FSYNC,INTA, DRDY
    – Patchwork
    Commented Apr 21, 2017 at 22:50
  • No offense, I know you said you triple-checked the connections, but if pinouts on your module are the same as the module in the tutorial, it sure looks to me like your SDA and SCL are reversed. Going by the pin labels shown in the tutorial, starting at the edge of the board, VCC, GND, SCL, SDA. This is also what you've described above, but in your picture the 3rd wire in (purple, SCL) is going to the second pin in (pin #3) on the GPIO header (SDA). Commented Apr 21, 2017 at 23:16
  • No offense taken, but after checking again, I can confirm that all input to the chip are correct.
    – Patchwork
    Commented Apr 21, 2017 at 23:28
  • The linked device is SPI not I2C. Could you add or change the photo so we can see the pin labels and the wire colours so we can trace from sensor pin to Pi pin?
    – joan
    Commented Apr 22, 2017 at 7:20

4 Answers 4

4

[FIXED]

I've fixed the problem, but I don't know what it was.

It turns out there was an issue passing the SDA and SCL line through a breadboard. The chip was still getting power through the breadboard, however SDA and SCL were not getting through.

Moving the chip to a different position on the breadboard, and to different breadboard completely still messed up the connection.

The solution was to connect the pinouts on the RPi 3 DIRECTLY to the chip, and I am now able to interact with the device.

Thanks to everyone who commented and helped me get this working, but honestly this solution is just raising more questions than answers. o_O

1
  • A breadboard adds capacitance to the circuit. That could have been enough to mess up the high-speed connection.
    – NomadMaker
    Commented Jun 8, 2018 at 23:41
1

I spent hours trying to solve that problem today. The issue was also some bad connections in the breadboard. If you face this problem, make sure that both your VCC and GROUND of the device is connected to the Raspberry Pi and also try pushing / moving a little bit the device in the breadboard to see if the i2cdetect identifies it.

0

enable I2C in the kernel

 sudo raspi-config

and find advanced options (Number 8) -> I2C (A7) -> enable I2c interface (Yes)

Installing Kernel Support (Manually)

sudo nano /etc/modules

and add to file

i2c-bcm2708 
i2c-dev

exit and save (ctrl + X ->Y)

reboot your raspberry sudo reboot

please visit this page

Tutorial

4
  • 2
    If the i2c_detect command works without complaining about a missing bus it indicates that I2C has been configured properly.
    – joan
    Commented Apr 22, 2017 at 11:09
  • most active i2c port in the kernel otherwise OS not find I2C port
    – Hamed
    Commented Apr 23, 2017 at 9:56
  • 1
    I'm just pointing out the questioner must have properly enabled I2C. If he hadn't he would have got an error message when he ran i2c_detect (as mentioned in the question).
    – joan
    Commented Apr 23, 2017 at 10:41
  • Yes, you are right. But still, I believe must be enabled in the kernels. I tried :/ @joan
    – Hamed
    Commented Apr 23, 2017 at 11:49
0

In my case it was a combination of loose wires and a chip (SC16IS750) which can be set to I2C or SPI. The pin was floating so the device was in a state of limbo.

From the datasheet: I2C-bus or SPI interface select. I2C-bus interface is selected if this pin is at logic HIGH. SPI interface is selected if this pin is at logic LOW.

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.