Facebook Twitter Instagram Pinterest YouTube
    Trending
    • Pi Pico W Launched
    • Add Kodi to RetroPie Menu
    • Disable Auto-login in Raspberry Pi OS
    • Raspberry Pi Cloud Storage with MEGA
    • RetroPie Temperature Monitor from Menu
    • Pi Pico Pinout and Power Pins
    • Install Arduino IDE on Raspberry Pi
    • Raspberry Pi 400 SSD Upgrade
    Facebook Twitter Instagram Pinterest YouTube RSS
    Raspberry Pi SpyRaspberry Pi Spy
    • Home
    • Categories
      • General
      • Hardware
      • Programming
      • Python
      • Software
      • Tutorials & Help
    • BerryClip
      • BerryClip Instructions
      • BerryClip Plus Instructions
      • Videos & Reviews
    • Buy
      • Buy Pi
      • Buy Pi Accessories
      • Buy Books
    • Tools
      • Ultimate Raspberry Pi Alexa Skill
      • Pi Power Estimator App
      • Pi-Lite 14×9 LED Matrix Sprite Editor
      • RPiREF Pin-out Reference App
      • Simple Ohm’s Law Calculator
      • Web Sites & Links
    • Tutorials & Help
        Featured
        November 9, 20200

        Raspberry Pi Temperature Monitoring

        Recent
        May 6, 2022

        Add Kodi to RetroPie Menu

        February 26, 2022

        Disable Auto-login in Raspberry Pi OS

        February 2, 2022

        Raspberry Pi Cloud Storage with MEGA

      1. Contact Us
      2. Site Map
      Raspberry Pi SpyRaspberry Pi Spy
      You are at:Home»Hardware»Interfaces»I2C»Change Raspberry Pi I2C Bus Speed
      I2C Bus On The Raspberry Pi

      Change Raspberry Pi I2C Bus Speed

      3
      By Matt on February 28, 2018 I2C, Tutorials & Help

      Changing the default I2C bus speed on the Raspberry Pi can help improve the performance of some projects. This is particularly important when using the I2C interface to control a display module. In the newer versions of Raspbian this change must be made using a Device Tree parameter.

      The bus speed is sometimes referred to as “baudrate” although the two aren’t actually the same thing.

      Step 1 – Enable the I2C Interface

      Before the interface baudrate can be changed the I2C interface must be enabled. This can be done using “raspi-config” on the command line or “Raspberry Pi Configuration” on the Raspbian desktop.

      For step-by-step instructions on how to do this please take a look at the Enable I2C Interface on the Raspberry Pi post.

      Step 2 – Edit Config.txt File to set I2C Bus Speed

      Using the following command the config.txt file can be edited :

      sudo nano /boot/config.txt

      Find the line containing “dtparam=i2c_arm=on”.

      Add “,i2c_arm_baudrate=400000” where 400000 is the new speed (400 Kbit/s). Note the comma.

      This should give you a line looking like :

      dtparam=i2c_arm=on,i2c_arm_baudrate=400000

      This enables the bus and sets the baudrate at the same time with a comma separating both parameters.

      Use CTRL-X, then Y, then RETURN to save the file and exit.

      Step 3 – Reboot

      Finally, reboot the Pi for the new setting to take effect :

      sudo reboot

      I2C Baudrate Values

      The BCM2835 ARM Peripherals specification (page 28) says that the Pi has a “fast-mode” (400Kb/s) driver. For this reason I would recommend using 100000 or 400000 as baudrate values. The default is usually set to 100000.

      I successfully used 400000 with an OLED display module to increase the rate at which images could be updated.


      Finally, for a list of I2C related articles click here.

      More information about the I2C protocol can be found on Wikipedia.

      Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
      Previous ArticleRC522 RFID Tag Reading with the Raspberry Pi
      Next Article Pi Party at Cotswold Jam 2018

      Related Posts

      Add Kodi to RetroPie Menu

      Disable Auto-login in Raspberry Pi OS

      Raspberry Pi Cloud Storage with MEGA

      3 Comments

      1. Shawn on March 3, 2018 4:16 pm

        Hi Matt, thanks for the nice tutorial.

        I found that sometimes we need to reduce the i2c speed instead. For example, when implementing an I2C slave with ATtiny84, who has no hardware support for I2C.

        When using software to support I2C on slave, the slave may behave slow and need “clock stretching”, which is not well supported by Raspberry Pi until now (https://www.raspberrypi.org/forums/viewtopic.php?t=13771).

        In my case, I reduced the I2C to 10kbps (dtparam=i2c1_baudrate=10000) to avoid clock stretching, and it worked well.

        Reply
        • Simon Blake on August 17, 2019 4:26 pm

          The Raspberry Pi i2c hardware has a bug which prevents it from correctly implementing clock stretching. However this can easily be overcome by disabling the standard i2c hardware and replacing it with a device tree overlay. This will allow slave devices which require clock stretching, like the BNO055 IMU, to be used with the Raspberry Pi. For full details of the procedure please see https://gps-pie.com/pi_i2c_config.htm

          Reply
      2. phil on January 6, 2021 5:44 pm

        wow you made my day, my i2c stream got interrupted all the time until I setup this

        thank you so much

        Reply

      Leave A Reply Cancel Reply

      This site uses Akismet to reduce spam. Learn how your comment data is processed.

      Recent Posts
      June 30, 2022

      Pi Pico W Launched

      May 6, 2022

      Add Kodi to RetroPie Menu

      February 26, 2022

      Disable Auto-login in Raspberry Pi OS

      February 2, 2022

      Raspberry Pi Cloud Storage with MEGA

      January 7, 2022

      RetroPie Temperature Monitor from Menu

      Categories
      • 1-wire
      • 3D Printing
      • Add-ons
      • BBC Micro:bit
      • BerryClip
      • Books
      • Camera Module
      • Cases
      • Events
      • General
      • Hardware
      • I2C
      • Infographics
      • Interfaces
      • Minecraft
      • Model A+
      • Model B+
      • News
      • Pi Models
      • Pi Pico
      • Pi Zero
      • Power
      • Programming
      • Python
      • Raspberry Pi OS
      • Raspbian
      • RetroGaming
      • Robotics
      • Sensors
      • Software
      • SPI
      • Tutorials & Help
      Tags
      3D Printing Arduino audio battery berryclip Birthday bluetooth cambridge camera CamJam DigiMakers display games GPIO I2C interface Kickstarter LCD LED Linux media Minecraft Model A Model B motionEyeOS PCB photography photos Pi-Lite portable power python Raspberry Jam Raspberry Pi Bootcamp raspbian Retrogaming retroPie screen SD card security sensor SPI temperature ultrasonic video
      Raspberry PI Related
      • Adafruit Blog
      • Average Maker
      • Official RaspBerry Pi Site
      • Raspberry Pi Pod
      • RasPi.tv
      • RaspTut
      • Stuff About Code
      Tech Resources
      • MattsBits – Pi Resources
      • Microbit Spy
      • Technology Spy
      Archives
      About

      Unofficial site devoted to the Raspberry Pi credit card sized computer offering tutorials, guides, resources,scripts and downloads. We hope to help everyone get the most out of their Pi by providing clear, simple articles on configuring, programming and operating it.

      Popular Posts
      September 19, 2014

      Top 5 Reasons The Raspberry Pi Sucks

      July 27, 2012

      16×2 LCD Module Control Using Python

      October 20, 2013

      Analogue Sensors On The Raspberry Pi Using An MCP3008

      Recent Posts
      June 30, 2022

      Pi Pico W Launched

      May 6, 2022

      Add Kodi to RetroPie Menu

      February 26, 2022

      Disable Auto-login in Raspberry Pi OS

      Facebook Twitter Instagram Pinterest YouTube RSS

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2022 - All Rights Reserved - Matt Hawkins

      Type above and press Enter to search. Press Esc to cancel.