title: How to Enable I2C of Raspberry Pi3 module (Using with Android Things as an OS)
body: <p>I am trying to develop a sample <strong>Android-Things</strong> app using Raspberry Pi module 3 which takes temperature reading from <strong>BME280</strong> sensor and display it on app. I have downloaded the sample project but facing an issue while opening I2cDevice with an address.</p>
  
  <p><strong>Below are the code details:</strong></p>
  
  <p>private static final int ADDRESS = 0x76;</p>
  
  <pre><code>private void printDeviceId() {
      List&lt;String&gt; deviceList = managerService.getI2cBusList();
      if (deviceList.isEmpty()) {
          Log.i(TAG, "No I2C bus available on this device.");
      } else {
          Log.i(TAG, "List of available devices: " + deviceList);
      }
      I2cDevice device = null;
      try {
          device = managerService.openI2cDevice(deviceList.get(0), ADDRESS);
          Log.d(TAG, "Device ID byte: 0x" + Integer.toHexString(device.readRegByte(0xD0)));
      } catch (IOException|RuntimeException e) {
          Log.e(TAG, e.getMessage(), e);
      } finally {
          try {
              device.close();
          } catch (Exception ex) {
              Log.d(TAG, "Error closing device");
          }
      }
  }
  </code></pre>
  
  <p>Actually its crashing on openI2cDevice method while deviceList have only one device i.e. <strong>deviceList.get(0) is "I2C1"</strong></p>
  
  <p><strong>Here is the crash log:</strong>
  android.os.ServiceSpecificException: I/O error (code 5)
                                                                          com.google.android.things.pio.PioException: android.os.ServiceSpecificException: I/O error (code 5)
                                                                              at com.google.android.things.pio.I2cDeviceImpl.readRegByte(I2cDeviceImpl.java:81)
                                                                              at com.example.pitepmerature.MainActivity.printDeviceId(MainActivity.java:92)
                                                                              at com.example.pitepmerature.MainActivity.onCreate(MainActivity.java:34)
                                                                              at android.app.Activity.performCreate(Activity.java:7000)
                                                                              at android.app.Activity.performCreate(Activity.java:6991)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                                                                              at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                              at android.os.Looper.loop(Looper.java:164)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:6494)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
                                                                           Caused by: android.os.ServiceSpecificException: I/O error (code 5)
                                                                              at android.os.Parcel.readException(Parcel.java:2018)
                                                                              at android.os.Parcel.readException(Parcel.java:1950)
                                                                              at com.google.android.things.pio.IPeripheralManagerClient$Stub$Proxy.I2cReadRegByte(IPeripheralManagerClient.java:1301)
                                                                              at com.google.android.things.pio.I2cDeviceImpl.readRegByte(I2cDeviceImpl.java:79)
                                                                              at com.example.pitepmerature.MainActivity.printDeviceId(MainActivity.java:92) 
                                                                              at com.example.pitepmerature.MainActivity.onCreate(MainActivity.java:34) 
                                                                              at android.app.Activity.performCreate(Activity.java:7000) 
                                                                              at android.app.Activity.performCreate(Activity.java:6991) 
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) </p>
  
  <p>I tried changing address to 0x77 as well but didn't work. Also gone through many blogs but didn't find the fix.</p>
  
  <p><strong>Blog link which i preferred to code and setup everything:</strong></p>
  
  <p><a href="http://zenandroid.io/writing-a-driver-for-android-things-bme280-humidity-sensor/" rel="nofollow noreferrer">http://zenandroid.io/writing-a-driver-for-android-things-bme280-humidity-sensor/</a></p>
  
  <p>Please help.</p>