Home Learning Resetting the I2C driver on a Raspberry Pi

Resetting the I2C driver on a Raspberry Pi

by shedboy71

This was a strange one, I had an example for an HMC5883 sensor written in python but no matter what i did I couldn’t get it to work. I checked my hardware and software, all looked OK.

I then decided to scan the I2C bus for a device using sudo i2cdetect -y 1, here is what I saw

sudo-fail

That’s not correct, what you should see is row’s of dashes and if an I2C device is detected it will be listed.

The next step was to remove the device attached, no difference. It was then I decided to reset the I2C bus by sending the following commands via the terminal

disable the I2C driver with
sudo rmmod i2c_dev
sudo rmmod i2c_bcm2708

re-enable it with
sudo modprobe i2c_bcm2708
sudo modprobe i2c_dev

Now run sudo i2cdetect -y 1 with the device connected properly

i2cset-pass

perfect the device is correctly detected at address 1E.

So if you have a problem with an I2C device maybe something to look at there, no idea how this happened.

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More