pythoni2craspberry-pi

python smbus/i2c frequency


I would like to change i2c bus frequency in order to allow for slightly longer cables.

I am using python-smbus package and it does work very well, however, I am unable to find how to set the bus frequency.

I have looked through the docs but was unable to find anything even remotely related to setting bus parameters.

Is that anything that could be done in python or do I need something lower level?

I am using Raspberry PI, which is an ARM architecture.


Solution

  • On the Raspberry Pi with the latest Jessie image, you can use this to check the current I2C frequency:
    sudo cat /sys/module/i2c_bcm2708/parameters/baudrate.

    To change the frequency, you can add/change this parameter:

    dtparam=i2c_baudrate=50000

    (replace 50000 with the desired frequency) in:

    /boot/config.txt

    and reboot to change the frequency.