> For the complete documentation index, see [llms.txt](https://amobile-solutions.gitbook.io/yocto-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://amobile-solutions.gitbook.io/yocto-developer-guide/test-and-use-the-interface/g-sensor/g-sensor-iot-800n-g420.md).

# G-sensor - IOT-800N-G420

## Overview

|           |                                            |
| --------- | ------------------------------------------ |
| Part      | Bosch BMI270, 6-axis IMU                   |
| Interface | I2C0 at 0x69                               |
| Driver    | mainline `bmi270_i2c`, exposed through IIO |
| Interrupt | GPIO5                                      |

The address is 0x69 because SDO is pulled high on this board.

{% hint style="info" %}
Android runs this sensor on the SCP with MediaTek's sensor hub. IoT Yocto has no sensor hub, so the sensor is driven from the AP through the mainline IIO subsystem instead.
{% endhint %}

## Finding the device

```
ls /sys/bus/iio/devices/
cat /sys/bus/iio/devices/iio:device0/name
```

```
bmi270
```

The device number varies with probe order, so it is worth locating it rather than assuming:

```
for d in /sys/bus/iio/devices/iio:device*; do
    [ "$(cat $d/name)" = "bmi270" ] && echo "$d"
done
```

## Reading values

```
D=/sys/bus/iio/devices/iio:device0

cat $D/in_accel_x_raw $D/in_accel_y_raw $D/in_accel_z_raw
cat $D/in_accel_scale

cat $D/in_anglvel_x_raw $D/in_anglvel_y_raw $D/in_anglvel_z_raw
cat $D/in_anglvel_scale
```

The physical value is `raw × scale`. Acceleration is in m/s², so with the board flat the Z axis reads about 9.8.

## Continuous reading

```
D=/sys/bus/iio/devices/iio:device0
while true; do
    S=$(cat $D/in_accel_scale)
    X=$(cat $D/in_accel_x_raw)
    Y=$(cat $D/in_accel_y_raw)
    Z=$(cat $D/in_accel_z_raw)
    awk -v s=$S -v x=$X -v y=$Y -v z=$Z \
        'BEGIN{printf "accel  %7.3f %7.3f %7.3f m/s^2\n", x*s, y*s, z*s}'
    sleep 0.3
done
```

Tilting the board changes the distribution between the axes while the magnitude stays near 9.8 in any orientation. That is the most direct check that the sensor is working.

## Available attributes

```
ls /sys/bus/iio/devices/iio:device0/
```

| Attribute                               | Meaning             |
| --------------------------------------- | ------------------- |
| `in_accel_[xyz]_raw`                    | Raw acceleration    |
| `in_accel_scale`                        | Multiplier to m/s²  |
| `in_anglvel_[xyz]_raw`                  | Raw angular rate    |
| `in_anglvel_scale`                      | Multiplier to rad/s |
| `sampling_frequency`                    | Output data rate    |
| `in_accel_sampling_frequency_available` | Supported rates     |

## Firmware

The BMI270 needs an 8 KB configuration array loaded at startup before it enters normal operation. The driver fetches it through `request_firmware("bmi270-init-data.fw")`.

```
ls -l /lib/firmware/bmi270-init-data.fw
dmesg | grep -i bmi270
```

## Troubleshooting

### The driver fails with -ETIMEDOUT

```
bmi270_i2c 0-0069: error -ETIMEDOUT: Failed to read chip id
```

The sensor bus has no external pull-ups on carrier revision R02, so the device tree has to enable the internal ones with `bias-pull-up` on `i2c0_pins`. With them disabled, SDA and SCL float and the controller cannot generate a valid START.

A useful distinguishing symptom: `i2cdetect` aborts partway through the scan rather than completing with no devices found. A dead bus looks like a missing part.

### Checking the supply

```
grep sensor /sys/kernel/debug/regulator/regulator_summary
```

`sensor_2v8` should be enabled with a use count of at least 1.

## Mount matrix

The device tree does not yet declare a `mount-matrix`, so the axes are reported in the sensor's own frame rather than the board's. Applications needing board-relative orientation have to apply the transform themselves, or the matrix can be added to the device tree once the orientation has been measured.
