Raspberry Pi - a virtual I2C GPIO

Preface:

Unfortunately, raspberry pie did not take long, I2C interfaces can not detect.

Try holding the psychological, to the group asked a question, the results were sprayed, saying: "Now more than silly money of so many people, what they do, but also play raspberry pie."

I thought to myself, Is Raspberry Pi is really "the tall"?

 

Things like this:

A few days ago received a 6wd robot Raspberry Pi expansion board for a few days, and then on the camera, the camera work.

But not long after, probably because of insufficient power supply, raspberry pie WiFi suddenly blocked, restart several times the board is still not resolved.

Hindsight I would Raspberry Pi into the computer USB3.0 port, WiFi recovery.

The next test I2C, I2C but can not detect, like a bolt from the blue, it is caught off guard, modify parameters, reinstall the system ...

Because they are not doing hardware debug device did not cause I2C broken has not been found.

Here, if fortunate enough to encounter a nice ring, can help guide guidance, but also educated us, very grateful! ! !

(Do not take offense, for unknown reasons, cut the map can not be uploaded directly with the map business, if inappropriate, please!)

 

Without further ado, we offer solutions:

Because also just got the board, knowledge of the Raspberry Pi is poorly understood and explored about two days.

Later, find Device Trees , found inside the dtoverlay very powerful.

Dawn in Changing i2c sda1 scl1 pin this article, the article told me Raspberry Pi can be multiple virtual I2C interface by setting dtoverlay.

Holding the dead horse as living horse medicine attitude, according to the article, I modified dtoverlay, set it to i2c-gpio, bus = 3, i2c_gpio_delay_us = 2, i2c_gpio_sda = 5, i2c_gpio_scl = 6.

Run i2cdetect -l, appeared i2c-3 equipment:

root@raspberrypi:/home/pi# i2cdetect -l
i2c-3   i2c             i2c@3                                   I2C adapter
i2c-1   i2c             bcm2835 I2C adapter                     I2C adapter

Run i2cdetect -y 3, found 6wd:

root@raspberrypi:/home/pi# i2cdetect -y 3
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- 41 -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --

Then modify the I2C bus 6wd control script and run, the perfect solution!

/boot/config.txt modified as follows:

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on
dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=2,i2c_gpio_sda=5,i2c_gpio_scl=6

Remarks:

Wherein i2c_gpio_sda = 5 and i2c_gpio_scl = 6 refer to pin 29 and pin 31.

Guess you like

Origin www.cnblogs.com/herman1221/p/11761541.html