Close Menu
    Facebook X (Twitter) Instagram Pinterest YouTube
    Trending
    • Disable SSH Password Login on Raspberry Pi
    • Elecrow Meteor IPS Touchscreen with RGB LEDs
    • Pi Pico Pinout Display on the Command Line
    • How to Add a Raspberry Pi Pico Reset Button
    • Pi Pico Onboard LED
    • Pi Pico W Pinout and Power Pins
    • CrowPi L Raspberry Pi Laptop and Learning Platform
    • Pi Pico W Launched
    Mastodon YouTube Facebook Instagram Pinterest 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
        February 16, 2024

        Disable SSH Password Login on Raspberry Pi

        December 23, 2022

        How to Add a Raspberry Pi Pico Reset Button

        November 20, 2022

        Pi Pico Onboard LED

      1. Contact Us
      2. Site Map
      Raspberry Pi SpyRaspberry Pi Spy
      You are at:Home»Hardware»Interfaces»I2C»Enable I2C Interface on the Raspberry Pi
      I2C Bus On The Raspberry Pi

      Enable I2C Interface on the Raspberry Pi

      32
      By Matt on November 2, 2014 I2C, Tutorials & Help

      I2C is a multi-device bus used to connect low-speed peripherals to computers and embedded systems. The Raspberry Pi supports this interface on its GPIO header and it is a great way to connect sensors and devices. Once configured you can connect more than one device without using up additional pins on the header.

      Step 1 – Enable I2C Interface

      The default Raspbian image disables I2C by default so before you can use it the interface must be enabled. This can be done using either of two methods. I’ll describe all methods but the first one is probably easier and quicker.

      Method 1 – Using “Raspi-config” on Command Line

      From the command line or Terminal window start by running the following command :

      sudo raspi-config

      This will launch the raspi-config utility. Select “Interface Options” :

      Raspi-Config - Interfacing

      Highlight the “I2C” option and activate “<Select>”.

      Raspi-Config - Interfacing - I2C

      Select and activate “<Yes>” :

      Raspi-Config - Interfacing - I2C 1
      Raspi-Config - Interfacing - I2C 2

      Highlight and activate “<Ok>” :

      When prompted to reboot highlight and activate “<Yes>” :

      Raspi-Config - Reboot Prompt

      The Raspberry Pi will reboot and the interface will be enabled.

      Method 2 – Using “Raspberry Pi Configuration”

      If your Pi boots to the desktop you can either open a Terminal window and use Method 1 or use the graphical tool “Raspberry Pi Configuration”. This is found under Menu > Preferences > Raspberry Pi Configuration

      Raspberry Pi Configuration launch from menu

      Then you simply need to select the “Interfaces” tab and set I2C to “Enabled” :

      Raspberry Pi Configuration - Interfaces Tab - I2C

      Click the “OK” button. If prompted to reboot select “Yes” so that the changes will take effect.

      Raspberry Pi Configuration - Reboot Prompt

      The Raspberry Pi will reboot and the I2C interface will be enabled.

      Step 2 – Install Utilities

      To help debugging and allow the interface to be used within Python we can install “python-smbus” and “i2c-tools” :

      sudo apt-get update
      sudo apt-get install -y python3-smbus i2c-tools

      Step 3 – Shutdown

      Shutdown your Pi using :

      sudo halt

      Wait ten seconds, disconnect the power to your Pi and you are now ready to connect your I2C hardware.

      Checking If I2C Is Enabled (Optional)

      When you power up or reboot your Pi you can check the i2c module is running by using the following command :

      lsmod | grep i2c_

      That will list all the modules starting with “i2c_”. If it lists “i2c_bcm2708” then the module is running correctly.

      Testing Hardware (Optional)

      Once you’ve connected your hardware double check the wiring. Make sure 3.3V is going to the correct pins and you’ve got not short circuits. Power up the Pi and wait for it to boot.

      If you’ve got a Model A, B Rev 2 or B+ Pi then type the following command :

      i2cdetect -y 1

      If you’ve got an original Model B Rev 1 Pi then type the following command :

      i2cdetect -y 0

      Why the difference? Between the Rev 1 and Rev 2 versions of the Pi they changed the signals that went to Pin 3 and Pin 5 on the GPIO header. This changed the device number that needs to be used with I2C from 0 to 1.

      I used a Pi 2 Model B with a sensor connected and my output looked like this :

      pi@raspberrypi ~ $ i2cdetect -y 1
           0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
      00:          -- -- -- -- -- -- -- -- -- -- -- -- --
      10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
      70: -- -- -- -- -- -- -- --

      This shows that I’ve got one device connected and its address is 0x20 (32 in decimal).


      A full list of tutorials featuring this interface can be found by clicking here.

      Finally, there is more technical information about I2C on the Wikipedia page if you are interested.

      Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
      Previous ArticleHow To Configure WiFi On The Raspberry Pi
      Next Article New Raspberry Pi Model A+ Revealed

      Related Posts

      Disable SSH Password Login on Raspberry Pi

      How to Add a Raspberry Pi Pico Reset Button

      Pi Pico Onboard LED

      32 Comments

      1. Popescu Liviu on January 29, 2015 1:34 pm

        I try all this and I got this error. I have Rpi B+

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

        Reply
        • Matt on January 30, 2015 2:56 pm

          All I can suggest is using the latest Raspbian image and trying again.

          Reply
        • Bozzy P. on February 11, 2015 9:52 am

          Same here with Raspberry Pi 2 with latest Raspbian (kernel 3.18.6-v7+).
          Using raspi-config results in absolutely no modifications to the config files.
          Modifying the config files manually also gives no good news.

          SOLUTION: Searching the web, it appears that with new kernels (3.18) it’s necessary to modify another file. Edit /boot/config.txt and add the line:
          dtparam=i2c_arm=on

          It seems there’s another line to add, but I got i2c working without this one:
          dtparam=i2c1=on

          Good i2cing 😉

          Reply
          • Matt on February 11, 2015 9:52 pm

            After a bit of experimenting I’ve got my i2c hardware working. I’ve updated my articles so hopefully they now reflect the changes made in Raspbian.

            Reply
      2. Scott on March 3, 2015 7:40 pm

        There is a mistake in your /etc/modules script. You need to change the fallowing for it to work on the new Rpi2 board.

        “i2c-bcm2708” -> “i2c-bcm2835”.

        2708 is for the original Rpi1 board, but for it to work on the new Rpi2 board. You need to change it to 2835.

        Reply
        • Matt on March 3, 2015 11:17 pm

          i2c-bcm2708 works for both boards. i2c-bcm2835 works for the Pi 2 but stops a B+ booting. So at the moment I can’t see why you wouldn’t use i2c-bcm2708 and have your SD card work in a B+ and Pi 2.

          Reply
      3. Mike on March 9, 2015 1:49 pm

        Have followed the procedure as shown above, however, when I type “sudo i2cdetect -y 1 I get an error message “could not open file ‘/dev/i2c-1’ no such file or directory. I am totally new to the Raspberry Pi and it’s operating system so don’t know if the directory has been updated or how to correct it. Any help would be appreciated.

        Reply
        • Matt on March 10, 2015 8:03 pm

          What i2c device are you using and what model Pi?

          Reply
      4. Paul on April 13, 2015 5:28 pm

        Thanks – best article I’ve seen on this subject. It’s great to see that you keep it up to date. I have booked marked your site for future reference once I have got my IMU working.

        BTW: What does the i2c-bcm2835 module do that the i2c-bcm2708 doesn’t? (I have a PI 2 B board, I gather from your comments that it really doesn’t matter but it would be nice to know).

        Reply
      5. Paul on April 13, 2015 11:05 pm

        Here’s a tip: If you get I2C errors make sure that keep the leeds between the IMU and the PI short. I had made a test cable for various Arduino modules, it was quite long so I could move the model around to test it. I was able to successfully run the IMU on the Arduino and it worked fine but when I connected it to the PI, I would get “I2C 113, Unable to read FIFO Counter”, errors and none of the supplied software would work.

        I found that my Freetronics 9-DOF IMU (http://www.freetronics.com.au/collections/modules/products/9-dof-imu-accelerometer-gyroscope-magnetometer) has two 4.5K pull-up resistors and these should be disabled with the Pi because it has it’s own pulp resistors, 1.8K, so you really don’t want to add any extra ones into the circuit because they become connected in parallel and reduce the total pull values considerably (1/(1/1.8K+1/4.5K) = 1.285K, yikes!).

        Reply
      6. craig on April 29, 2015 3:01 am

        I have the new improved Pi2 1gb. I am using Raspbian and I have tried all of the steps to enable i2c. The statement- lsmod | grep i2c_ does return “i2c_bcm2708″ and one other module.
        But, sudo i2cdetect -y 1 does not work just the same. “sudo: i2cdetect: command not found” is the result. I am wondering if the problem is the RTC that I have installed. It came without any instructions of it’s own and other people are having trouble using a RTC on the Pi2.

        Reply
        • Matt on April 30, 2015 9:43 pm

          If i2cdetect is not recognised then it sounds like i2c-tools is not installed. Are you using a “Tiny RTC” module?

          Reply
          • craig on May 1, 2015 1:46 am

            Yes. Mini RTC or Tiny GPIO device. The real time clock works great now but I sure wish they had provided instructions with it.
            It was cheap though. Many thanks for your help.

            Reply
      7. craig on May 1, 2015 12:56 am

        Well, I just got i2cdetect to work on my Pi2 running Raspbian. My troubles were all due to the fact that I was trying to use a Wi-Fi adapter when installing python-smbus and i2c-tools. I connected a network cable and tried again. This time all is well and I can go on to set up the date and time on my new RTC (real time clock)
        Thanks for the info. Your instructions are the best I have found on the Internet.

        Reply
      8. Lily on May 18, 2015 4:57 pm

        Heya, I really can’t seem to get this right. the weird thing is, when connecting one device and scanning for i2c devices I get EVERY possible address filled instead of just 0x20. any ideas on what i might be doing wrong?

        Reply
        • Matt on May 23, 2015 12:03 am

          Are you using the latest version of Raspbian? How long are your wires?

          Reply
      9. Hugo on May 24, 2015 3:01 am

        After fallowing all steps I’m getting the error: Error: Could not open file `/dev/i2c-1′ or `/dev/i2c/1′: No such file or directory

        I tried every suggestion on this discussion without no luck. Can it be something with the wiring between the pi and the nano? Is there any picture or scheme on this?

        Thanks

        Reply
        • Matt on May 27, 2015 10:25 am

          Are you using the latest version of Raspbian? Does your /boot/config.txt contain the line :
          dtparam=i2c_arm=on
          If it does not then add it at the end by editing the file using :
          sudo nano /boot/config.txt

          Reply
      10. Anna on June 3, 2015 5:12 am

        Hi
        I had followed all the step above. It works fine until the lsmod |grep i2c_. However, when I key in the i2cdetect -y 1, I can’t detect the address of my device. I am using Raspi B+ with ina219. Can anyone help me with it???Thanks!!!

        Reply
        • Matt on June 3, 2015 7:57 pm

          If you run lsmod does it list the i2c modules? Did you reboot after editing the /etc/modules file?

          Reply
      11. Billy Bryant on July 14, 2015 7:55 pm

        I have followed every step here, I’m using a RaspberryPI 2 B+ 1GB and a DS3231 RTC Module. I am running the latest build version of Raspbian and have installed the i2c tools. When booting, it looks like it sees the module as the verbose booth shows it identifying the i2c controller and a device. However, when I run i2cdetect -y 1, it tells me that it cannot find `/dev/i2c-1′ or `/dev/i2c/1′. I am running on a Read-Only partition with UNIONFS for /etc and /var. I’m at my wits end, how do I get this working?

        Reply
        • Matt on July 14, 2015 8:09 pm

          All I can suggest is follow the process with a clean Raspbian image.

          Reply
      12. Paul on October 25, 2015 3:53 pm

        Was trying to install a RTC and was going round in circles trying to connect to the IC2 bus. This guide helped me sort out everything, thanks very much. (there is a lot of very poor stuff out there which is either wrong o is asumming prior knowledge)

        Reply
      13. Harvey on October 30, 2015 3:23 am

        I used I2C on an Arduino, and after considerable thrashing I got it to behave. The Pi looks a lot more difficult. Your excellent article is going to save me a great deal of grief trying to get the Newhaven NHD-0216K3Z-FL-GBW LCD to do what I want it to do.

        Reply
      14. Hesham on January 11, 2016 8:24 pm

        Thank you for this article
        my question is

        How many devices can i connect by i2c ?

        if i want to connect many arduino ? how many arduino can be connected to raspberry pi by i2c

        thank you so much

        Reply
      15. Derek Stanbridge on April 19, 2016 11:23 am

        For a 75 year old new starter in “Pi Land” this was very helpful.

        Thank You.

        Reply
      16. Peem on June 29, 2016 5:09 pm

        Having problems.
        When i do i2cdetect -y 1

        I dont get any other numbers listed in the chart…. 00 to 70 down left. And 0-9…a-f along top.

        Any ideas as to what issue could be? Thanks

        Reply
        • Matt on July 29, 2016 11:48 am

          Double check your wiring to the I2C module. Ensure the connections aren’t loose. Reboot and check the module is running.

          Reply
      17. Ian on August 25, 2017 5:29 am

        Hi there Happy PiPeople,
        Would I be expecting too much for this to work on my RPi ZERO W please?

        Reply
        • Matt on August 28, 2017 11:19 am

          Hi Ian, the I2C option is now under “Interfacing Options”. I’ve updated this post to reflect the change.

          Reply
      18. Verma on December 9, 2020 10:56 am

        Hi,
        I have followed all the instruction given in this page. However, my raspberry pi board still not able to detect the i2c device. Another thing is that the same i2c device is working fine with arduino uno. This shows that used i2c device is ok to use. Kindly, let me know what to do for further check?

        Reply
        • Matt on January 20, 2021 7:17 pm

          Have you definitely followed the I2C post on setting up I2C and installing the correct software?
          Enable I2C Interface on the Raspberry Pi

          Reply
      Leave A Reply Cancel Reply

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

      Recent Posts
      February 16, 2024

      Disable SSH Password Login on Raspberry Pi

      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      December 23, 2022

      How to Add a Raspberry Pi Pico Reset Button

      November 20, 2022

      Pi Pico Onboard LED

      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
      Arduino audio battery berryclip Birthday bluetooth cambridge camera CamJam DigiMakers display games GPIO I2C interface Kickstarter Kodi LCD LED Linux media Minecraft Model A motionEyeOS PCB photography photos Pi-Lite Pi Pico power python Raspberry Jam Raspberry Pi Bootcamp raspbian Retrogaming retroPie screen SD card security sensor SPI SSH 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

      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 © 2025 - All Rights Reserved - Matt Hawkins

      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

      Latest Posts
      February 16, 2024

      Disable SSH Password Login on Raspberry Pi

      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      Mastodon YouTube Instagram Facebook Pinterest 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 © 2025 - All Rights Reserved - Matt Hawkins

      mastodon.social@RPiSpy

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