> 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/digital-io/digital-io-iot-800n-g420.md).

# Digital IO - IOT-800N-G420

## Overview

Three isolated inputs and three isolated outputs on a 10-pin terminal block, using K10104A opto-couplers. The isolated side is powered externally through `DI_VDD`.

| Signal | GPIO | Line name |
| ------ | ---- | --------- |
| DI\_0  | 108  | `DI_0`    |
| DI\_1  | 110  | `DI_1`    |
| DI\_2  | 80   | `DI_2`    |
| DO\_0  | 106  | `DO_0`    |
| DO\_1  | 107  | `DO_1`    |
| DO\_2  | 109  | `DO_2`    |

CANH and CANL share the same terminal block.

{% hint style="warning" %}
`DI_VDD` has to be supplied externally. Without it the outputs have no pull-up and the inputs have no current path, so nothing works in either direction.
{% endhint %}

## Reading the inputs

```
gpioget DI_0 DI_1 DI_2
```

```
"DI_0"=inactive "DI_1"=inactive "DI_2"=active
```

To watch for changes:

```
gpiomon DI_0
```

## Driving the outputs

```
gpioset DO_0=1 &
```

{% hint style="info" %}
`gpioset` in libgpiod v2 blocks while it holds the line, so it has to be backgrounded. Letting it exit releases the line.

To set a value and return immediately:

```
gpioset --toggle 0 DO_0=1
```

The MediaTek output register retains the value, but `gpioinfo` will show the line as unused afterwards.
{% endhint %}

## Listing every named line

```
gpioinfo | grep -E "DI_|DO_"
```

## Signal path

Each output passes through an N-MOSFET and then the opto-coupler, so there are two inversions. The opto-coupler output is open collector with its pull-up to `DI_VDD`, which means an external load or pull-up is required to see a level.

Each input has a 2.05K series resistor feeding the opto-coupler LED, so the drive current follows from the supply voltage:

| `DI_VDD` | Approximate LED current |
| -------- | ----------------------- |
| 5 V      | 1.85 mA                 |
| 12 V     | 5.3 mA                  |
| 24 V     | 11 mA                   |

## Loopback test

Wiring an output back to an input verifies both directions:

```
gpioset DO_0=1 &
gpioget DI_0
kill %1
gpioset DO_0=0 &
gpioget DI_0
```

The input should follow the output.
