embeded/raspberry pi2015. 8. 24. 15:30


raspi-config 면 기본 설정을 될테고..

나머지는 간단한(?) 테스트용 유틸리티 설치?


$ sudo apt-get install i2c-tools libi2c-dev python-smbus

$ sudo i2cdetect -y 1

[링크 : http://www.rasplay.org/?p=6409]

[링크 : https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c]


예제코드 / 스켈레톤 코드

char *fileName = "/dev/i2c-0";

fd = open(fileName, O_RDWR);

ioctl(fd, I2C_SLAVE, address);

write(fd, buf, 1);

read(fd, buf, 2); 

[링크 : http://www.robot-electronics.co.uk/files/rpi_sd21.c]

    [링크 : http://www.robot-electronics.co.uk/htm/raspberry_pi_examples.htm]


pi@raspberrypi ~ $ i2cdetect

Error: No i2c-bus specified!

Usage: i2cdetect [-y] [-a] [-q|-r] I2CBUS [FIRST LAST]

       i2cdetect -F I2CBUS

       i2cdetect -l

  I2CBUS is an integer or an I2C bus name

  If provided, FIRST and LAST limit the probing range. 


활성화 시키지 않으면 이런 에러가 발생한다.

pi@raspberrypi ~ $ i2cdetect -y 1

Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory 


근데..

전에 처럼 또.. 연결 안하고 안켜면 활성화도 안되는 기분?

pi@raspberrypi ~ $ sudo i2cdetect -y 1

Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory


pi@raspberrypi ~ $ dmesg | grep i2c

[    3.872815] bcm2708_i2c_init_pinmode(1,2)

[    3.874707] bcm2708_i2c_init_pinmode(1,3)

[    3.877782] bcm2708_i2c 3f804000.i2c: BSC1 Controller at 0x3f804000 (irq 79) (baudrate 100000) 



Posted by 구차니