3

I try to use AndroidThings to measure temperature with Raspberry Pi 3 and BMP280.

enter image description here

3,3V i have choosed because of specification of BMP280:

To power the board, give it the same power as the logic level of your microcontroller

Then i want to initialize sensor

mTemperatureSensorDriver = new Bmx280SensorDriver("I2C1");

And by execution i receive following exeption

Error configuring sensor
    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:215)
    at com.google.android.things.contrib.driver.bmx280.Bmx280.<init>(Bmx280.java:193)
    at com.google.android.things.contrib.driver.bmx280.Bmx280.<init>(Bmx280.java:180)
    at com.google.android.things.contrib.driver.bmx280.Bmx280SensorDriver.<init>(Bmx280SensorDriver.java:55)

Also by 5V Power i receive the same exception.

I have found this. But i have no idea how to check, if the BMP280 is realy connected to Raspberry with adb.

By own testing the connectivity i receive by device.readRegByte(0xD0) the same exeption.

Does it mean, that BMP280 is not correctly connected? If yes, how to correctly connect BMP280 with Raspberry?

Is some resistor needed by connection?

UPDATE

solved by soldering BMP280 with header strip.

Also to work with sensor is permission requiered that could be granded only in command line. ref

adb shell pm grant app.package com.google.android.things.permission.MANAGE_SENSOR_DRIVERS

anatoli
  • 1,663
  • 1
  • 17
  • 43
  • Try to access to BMP280 sensor with [PIO CLI Tool](https://developer.android.com/things/sdk/pio/pio-cli.html#I2C): `pio i2c I2C1 0x12 read-reg-byte 0x76` - or something like that, to find the issue. Also, take a look at [this](https://raspberrypi.stackexchange.com/a/74598/59288) answer. – Andrii Omelchenko Dec 18 '17 at 17:43
  • it gives me `[WARNING:client_errors.cc(35)] error 5: I/O error`. by calling `pio list i2c` i receive `I2C1` – anatoli Dec 19 '17 at 08:44

3 Answers3

0

Looking at your fritzing diagram you had SDO connected to BCM3?

From the datasheet the SDO pin is what determins the address of your sensor.

datasheet

Connecting SDO to GND results in slave address 1110110 (0x76); connection it to VDDIO results in slave address 1110111 (0x77)

Most importantly:

The SDO pin cannot be left floating; if left floating, the I²C address will be undefined.

com.google.android.things.pio.PioException: android.os.ServiceSpecificException: I/O error (code 5)

Therefore your problem is likely an undefined i2c address.

Looking at the code you are using for the Bmx280SensorDriver, it uses the address 0x77

https://github.com/androidthings/contrib-drivers/blob/master/bmx280/src/main/java/com/google/android/things/contrib/driver/bmx280/Bmx280.java#L48

Therefore you should ensure your SDO line is connected to 5V on your raspberry pi. This will ensure your sensor has the correct address.

Or alternatively connect SDO to Ground and use this constructor:

mTemperatureSensorDriver = new Bmx280SensorDriver("I2C1", 0x76);

If you want to understand what the sensor driver is doing "under the hood" there is a great blog post and repo to see that:

http://blog.blundellapps.co.uk/tut-android-things-temperature-sensor-i2c-on-the-rainbow-hat/

https://github.com/blundell/androidthings-i2c-input/blob/master/app/src/main/java/com/blundell/tut/MainActivity.java

;-)

Blundell
  • 75,855
  • 30
  • 208
  • 233
  • the icon for BMP280 is too big. There connected: VIN, GND, SCK and SDI – anatoli Dec 18 '17 at 20:01
  • connecting it to ground gives an address of `0x76` you need to either connect it to 5v or use the other constructor (written in my answer) – Blundell Dec 18 '17 at 20:02
  • at [this](https://raspberrypi.stackexchange.com/questions/74492/android-things-i2c-avc-denied/74598#74598) answer is said, that 3,3V is correct to work with. – anatoli Dec 19 '17 at 08:41
  • one another question: could BMP280 work without soldering? Is it possible? :) – anatoli Dec 19 '17 at 10:01
  • if SDO is connected to ground, you need to use this constructor: `new Bmx280SensorDriver("I2C1", 0x76);` – Blundell Dec 19 '17 at 12:35
0

Thanks for informations, for right connection

bmx280 = new Bmx280("I2C1",0x76); and SDO to gnd.

But read values is strange.

myweatherstation D/statie: temp: 186.83298 pres: -296.47287

Is possible to be sensor damaged?

TNX

Cris

Pabs123
  • 3,385
  • 13
  • 29
Cristi
  • 1
  • 1
  • If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/low-quality-posts/19550433) – 19greg96 Apr 25 '18 at 19:03
  • Yes, its my first post. TNX for advice – Cristi Apr 26 '18 at 16:31
0

To read data from IoT Device, the contact should be fixed without any loose connection.

This could be only reached with soldering of BMP280 with header strip

Only then the connection could be etablished

anatoli
  • 1,663
  • 1
  • 17
  • 43