Setting up the Raspberry pi i2c ports




Дата канвертавання26.04.2016
Памер4.91 Kb.

Setting up the Raspberry PI i2c ports

The i2c Ports on the raspberry pi are not enabled by default. Follow these steps to enable the i2c port. These instructions are for the official Raspbian distro.


First you will need to to edit the config file that disables the i2c port by default. This setting is stored in /etc/modprobe.d/raspi-blacklist.conf. we will use nano to edit this but you could use any editor you are comfortable with.
$sudo nano /etc/modprobe.d/raspi-blacklist.conf
Once this file is open find this line blacklist i2c-bcm2708 and comment it out by adding a # to the front of it.
#blacklist i2c-bcm2708
You can now save this file with Ctrl+O and pressing enter and exit nano with Ctrl+X. Once you are back at the command prompt reboot your raspberry pi.
$sudo reboot
Once the reboot has finished you need to make the ports active by running this command:
$sudo modprobe i2c-dev
Now you should be able to see the i2c ports listed in your /dev/ directory
$ls /dev/i2c*
You should see /dev/i2c-0 and /dev/i2c-1 listed. To be able to use these ports you need to give yourself permission to access them.
$sudo chmod o+rw /dev/i2c*
Now your i2c ports will be ready for you to use. You will have to run the modprobe and chmod commands every time you login to activate the ports and apply the permissions. If you wish to automate this process so the commands are run every time you log in then you can edit /etc/rc.local and add the commands in.


База данных защищена авторским правом ©shkola.of.by 2016
звярнуцца да адміністрацыі

    Галоўная старонка