-1

I am studying Raspberry Pi 3 by android things dp 5.1.

I build and play sample sources which is androidthings weatherstation.

(https://github.com/androidthings/weatherstation)

I cannot playing app and below logs.

I cannot use i2c on RP3 by android things 5.1?

How to fix this?


pin connection picture:

pin connections picture.

upside picture for BME280:

upside picture for BME280.

downside picture for BME280:

downside picture for BME280.


logcat at launching application:

10-30 19:05:31.307 23-23/? I/kdevtmpfs: type=1400 audit(0.0:155): avc: denied { create } for name="i2c-1" scontext=u:r:kernel:s0 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
10-30 19:05:31.307 23-23/? I/kdevtmpfs: type=1400 audit(0.0:156): avc: denied { setattr } for name="i2c-1" dev="devtmpfs" ino=33671 scontext=u:r:kernel:s0 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
10-30 19:05:31.317 23-23/? I/kdevtmpfs: type=1400 audit(0.0:157): avc: denied { getattr } for path="/i2c-1" dev="devtmpfs" ino=33671 scontext=u:r:kernel:s0 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
10-30 19:05:31.317 23-23/? I/kdevtmpfs: type=1400 audit(0.0:158): avc: denied { unlink } for name="i2c-1" dev="devtmpfs" ino=33671 scontext=u:r:kernel:s0 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1
10-30 19:05:31.347 2153-2153/com.example.androidthings.weatherstation E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.androidthings.weatherstation, PID: 2153
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidthings.weatherstation/com.example.androidthings.weatherstation.WeatherStationActivity}: java.lang.RuntimeException: Error initializing BMP280
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
     Caused by: java.lang.RuntimeException: Error initializing BMP280
        at com.example.androidthings.weatherstation.WeatherStationActivity.onCreate(WeatherStationActivity.java:205)
        at android.app.Activity.performCreate(Activity.java:6975)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6541) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
     Caused by: 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.google.android.things.contrib.driver.bmx280.Bmx280.connect(Bmx280.java:174)
        at com.google.android.things.contrib.driver.bmx280.Bmx280.<init>(Bmx280.java:152)
        at com.google.android.things.contrib.driver.bmx280.Bmx280SensorDriver.<init>(Bmx280SensorDriver.java:54)
        at com.example.androidthings.weatherstation.WeatherStationActivity.onCreate(WeatherStationActivity.java:199)
        at android.app.Activity.performCreate(Activity.java:6975) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6541) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
     Caused by: android.os.ServiceSpecificException: I/O error (code 5)
        at android.os.Parcel.readException(Parcel.java:1956)
        at android.os.Parcel.readException(Parcel.java:1888)
        at com.google.android.things.pio.IPeripheralManagerClient$Stub$Proxy.I2cReadRegByte(IPeripheralManagerClient.java:1465)
        at com.google.android.things.pio.I2cDeviceImpl.readRegByte(I2cDeviceImpl.java:79)
        at com.google.android.things.contrib.driver.bmx280.Bmx280.connect(Bmx280.java:174) 
        at com.google.android.things.contrib.driver.bmx280.Bmx280.<init>(Bmx280.java:152) 
        at com.google.android.things.contrib.driver.bmx280.Bmx280SensorDriver.<init>(Bmx280SensorDriver.java:54) 
        at com.example.androidthings.weatherstation.WeatherStationActivity.onCreate(WeatherStationActivity.java:199) 
        at android.app.Activity.performCreate(Activity.java:6975) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6541) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

migrated from stackoverflow.com Oct 30 '17 at 14:37

This question came from our site for professional and enthusiast programmers.

0

Android Things is encountering an error trying to open the I2C device connection: I/O error (code 5).

This could happen if you have another app running that has already opened the same I2C bus, or if a wiring problem is preventing the device from communicating successfully with the peripheral.

From the pictures you've taken, SDA/SCL seem to be in the right place, but you are providing 5V to a sensor that is only rated to accept 3.6V maximum. You might try powering the sensor from Pin 1 instead of Pin 4.

  • I cannot solve this issue. the application can open i2c device. but can not read byte at address 0xD0 yet. I try to read byte after removed other sensors. but not resolved. Good news is sometimes read byte and working well. – Dennis Nov 3 '17 at 2:19
  • I added relay to bme280 ground. so.. working well..link – Dennis Nov 9 '17 at 3:56
0

Here is My code for BMP280 Sensor Using Android Thing BMX280-Driver, before using this code please make sure your wire connections are correct.

class BMP280Activity : Activity() {

    private var mBmx280: Bmx280? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_bmp280)

        //mBmx280 = Bmx280("I2C1", Bmx280.DEFAULT_I2C_ADDRESS) // This line is 
        //creating issue with some sensors....

        mBmx280 = Bmx280("I2C1", 0x76) //Need to test on sensor before using....
        mBmx280?.temperatureOversampling = Bmx280.OVERSAMPLING_1X
        mBmx280?.pressureOversampling = Bmx280.OVERSAMPLING_1X
    }

    override fun onResume() {
        super.onResume()
        tv_temp.text = "${mBmx280?.readTemperatureAndPressure()?.get(0)} And ${mBmx280?.readTemperatureAndPressure()?.get(1)}"
    }


    override fun onDestroy() {
        mBmx280?.close()
        super.onDestroy()
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.