Ads 468x60px

##EasyReadMore##

25 12月, 2016

Setup i2c for Raspberry Pi

find i2c on raspberry Pi
Raspberry Pi 筆記(二):GPIO接腳與I2C及SPI安裝 - 天花板隨記 - https://goo.gl/z94TKa
image
i2c_sda at 3pin,i2c_scl at 5 pin ,3V at 1 pin, ground at 9 pin
install i2c-tools
pacman -S i2c-tools
Configure the bootloader to enable the i2c hardware by appending /boot/config.txt
vim /boot/config.txt
dtparam=i2c_arm=on
install device
modprobe i2c-dev
modprobe i2c-bcm2708
starup mount i2c device:
vim /etc/modules-load.d/raspberrypi.conf
i2c-dev
i2c-bcm2708
reboot

list i2c device
i2cdetect –l
image
Reboot the Raspberry Pi and issue the following command to get the hardware address
i2cdetect -y 1
如果出現  "can't use smbus quick write command on this bus"
可能是因為板本的關系 要改成 i2cdetect -r -y 1
image
只要有一個 i2c 裝置連上 上面就會出現一個代號
上圖因下指令的當下剛好沒有訊號
所以改用下面指令,每1秒監看一次
watch –n 1 i2cdetect -y 1

Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]
  I2CBUS is an integer or an I2C bus name
  ADDRESS is an integer (0x03 - 0x77)
  MODE is one of:
    b (read byte data, default)
    w (read word data)
    c (write byte/read byte)
    Append p for SMBus PEC
/ # i2cget -y 0 0x51 0xa0
0x32
/ # i2cget -y 0 0x51 0xa1
0x30
/ # i2cget -y 0 0x51 0xa2
0x31
/ # i2cget -y 0 0x51 0xa3
0x37

對應 ACII 讀到的值就是 2017

eeprog -f -q -r 0xa0:8 /dev/i2c-0 0x51

Raspberry Pi - ArchWiki - https://goo.gl/r34f7V

0 意見:

張貼留言

 
Blogger Templates