TRB141 Input/Output

From Wiki Knowledge Base | Teltonika Networks
Main Page > TRBxxx Gateways > TRB141 > TRB141 Manual > TRB141 WebUI > TRB141 Input/Output


Inputs and outputs are used for monitoring and controlling a connected device or receiving signals from that device in order to trigger certain events. This chapter is an overview of the Input/Output section for TRB141 routers.

The information in this page is updated in accordance with the TRB1410_R_00.01.06.1 firmware version.


TRB141 has eighteen input/output pins, two of them can be found inside the power socket and the rest sixteen are on the side of the device. A list of Input/Output electric characteristics inherent in TRB141 routers can be found bellow.

Power Socket Pins

Networking trb141 manual I-O power v1.png

  • Power pin: +9 ... +30 VDC positive power input.
  • Ground pin: negative/ground connection from power supply.
  • I/0 pins: programmable Input/Output pins (Open Collector output, max 30V or Digital input where 0-7.3 V is detected as logical "0", 7.3-30 V is detected as logical "1").

Connector Pins

Networking trb141 manual I-O socket v1.png

  • DI1 and DI2 are DRY/WET configurable inputs. WET: 0-1.9 V is detected as logical "0", 1.9-3.8 V is detected as logical "1". DRY: Logical "0" is detected when input is shorted to GND, otherwise input is detected as logical "1".
  • NC1 C1 and NO1 are respectively Normally Closed, Common and Normally Open contacts of internal Non-Latching Relay. Maximum relay ratings: 0.5A at 60 VDC/70 VAC, 1A at 30 VDC/VAC.
  • NC2 C2 and NO2 are respectively Normally Closed, Common and Normally Open contacts of internal Latching Relay. Maximum relay ratings: 0.8A at 70 VDC, 0.9A at 70 VAC, 2A at 30 VDC/VAC.
  • A is ADC input. Analog voltage range 0 - 30 V. Input can be configured for 4-20mA sensor protocol as current measurement of 0 - 30 mA.
  • l and are isolated input contacts. 0-7.3 V is detected as logical "0", 7.3-71 V is detected as logical "1".
  • + is power output connected directly to gateway's power supply input pin. This Output can be used for powering external 4-20 mA current sensor.
  • 3.8 is 3.8V power output which can be used to power 1-Wire sensors when needed.
  • 1W 1-Wire protocol input/output.
  • is GND contact.

Input/Output Status

Bellow is an example of I/O settings window: Networking trb141 manual I-O v1.png
Here you can change settings like type Dry/Wet, Input/Output and state Open/Closed, OFF/ON. Also you can find all the details about the pins.

Status And Control From Command Line

You can control and monitor input and output values via a command line interface (CLI) with the ubus call command.

In order to find the list of I/O port names use ubus list | grep ioman command.

root@TRB141:~# ubus list | grep ioman

In order to read value use status command.

ubus call ioman.gpio.dio0 status
ubus call ioman.relay.relay0 status

To change input settings use update command and write the value.

ubus call ioman.gpio.dio0 update '{"value":"0"}'
ubus call ioman.gpio.dio0 update '{"value":"1"}'

To change relay settings use update command and write state.

ubus call ioman.relay.relay0 update '{"state":"open"}'
ubus call ioman.relay.relay0 update '{"state":"closed"}'

Reading I/O values from directory

You can also collect I/O values straight from directories in yours router.

Digital inputs, Relay outputs

Following is a list of I/O directories in /sys/class/gpio/:

dwi1(dry wet) input 14; toggle 12 (to read value refer to gpio14, to change state dry/wet refer to gpio12)
dwi2(dry wet) input 15; toggle 38 (to read value refer to gpio15, to change state dry/wet refer to gpio38)
relay open 20; closed 22; (turn off gpio20 set to 0, turn on gpio22 set value to 1; and visa versa)
latching relay open 23; close 21 (turn off gpio23 set to 0, turn on gpio21 set value to 1; and visa versa)
dio0 (power socket) input 13; output 16 (direction can be changed, to read input use gpio13, to control output use gpio16)
dio1 (power socket) input 17; output 78 (direction can be changed, to read input use gpio17, to control output use gpio78)
iio (isolated input) input 1021 (to read value refer to gpio1021)

In order to read digital input value use cat command.

cat /sys/class/gpio/gpio14/value
cat /sys/class/gpio/gpio15/value
cat /sys/class/gpio/gpio1021/value

To change input state use echo command where "1" is "dry" state and "0" is "wet" state.

echo 0 > /sys/class/gpio/gpio12/value
echo 1 > /sys/class/gpio/gpio38/value

When one Relay output is open, other one is closed, so turning on/off the output you will have to change value on both pins. For that echo command is used. Same principle applies to Latching Relay output.

echo 1 > /sys/class/gpio/gpio20/value & echo 0 > /sys/class/gpio/gpio22/value
echo 1 > /sys/class/gpio/gpio23/value & echo 0 > /sys/class/gpio/gpio21/value

ADC (Analog Input)

ADC (Analog input) can be read from different directory, /sys/devices/qpnp-vadc-8/mpp4_vadc also using cat command, but received Result value has to be divided by 126582 to get number in volts.

cat /sys/devices/qpnp-vadc-8/mpp4_vadc 

One Wire

To read one wire input values It will require few steps. First go to /sys/bus/w1/devices/ directory.

cd /sys/bus/w1/devices/

List out device names with ls command. There you should see all I/O devices with different names like 10-1000xxxx or 28-3c01a etc. One of them should be "w1-slave" device. Go to that directory, and read value with cat command. Example:

cd /10-1000xxxx
cat /w1_slave