Template:Networking trb141 manual input output status: Difference between revisions

From Teltonika Networks Wiki
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<pre>
ioman.acl.acl0    - Analog Current loop
ioman.adc.adc0    - Analog input
ioman.dwi.dwi0    - Passive/Active input (PIN1)
ioman.dwi.dwi1    - Passive/Active input (PIN2)
ioman.gpio.dio0    - Configurable input/output (PIN3)
ioman.gpio.dio1    - Configurable input/output (PIN4)
ioman.gpio.iio    - Isolated input
ioman.gpio.onewire - One wire
ioman.relay.relay0 - Relay
ioman.relay.relay1 - Latching relay
</pre>


ioman.acl.acl0
In order to read values, use the <b><i>status</i></b> command:
ioman.adc.adc0
ioman.dwi.dwi0
ioman.dwi.dwi1
ioman.gpio.dio0
ioman.gpio.dio1
ioman.gpio.iio
ioman.gpio.onewire
ioman.relay.relay0
ioman.relay.relay1
 
In order to read value use '''''status''''' command.


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


To change input settings use '''''update''''' command and write the value.
To change input settings, use the <i><b>update</i></b> command and specify a value:


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


To change relay settings use '''''update''''' command and write state.
To change relay settings, use the <i><b>update</i></b> command and specify a state:


  ubus call ioman.relay.relay0 update '{"state":"open"}'
  ubus call ioman.relay.relay0 update '{"state":"open"}'
Line 42: Line 43:
  iio (isolated input) input 1021 (to read value refer to gpio1021)
  iio (isolated input) input 1021 (to read value refer to gpio1021)


In order to read digital input value use <i>cat</i> command.
In order to read digital input values, use the <b><i>cat</i></b> command:


  cat /sys/class/gpio/gpio14/value
  cat /sys/class/gpio/gpio14/value
Line 48: Line 49:
  cat /sys/class/gpio/gpio1021/value
  cat /sys/class/gpio/gpio1021/value


To change input state use <b><i>echo</i></b> command where "1" is "dry" state and "0" is "wet" state.
To change an input state, use the  <b><i>echo</i></b> command (where "1" is "dry" state and "0" is "wet" state):


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


When one Relay output is open, the other one is closed, so turning on/off the output you will have to change value on both pins. For that <i><b>echo</i></b> command is used. Same principle applies to Latching Relay output.
When one Relay output is open, the other one is closed; so to turn an output on or off, you will have to change the value on both pins:


  echo 1 > /sys/class/gpio/gpio20/value & echo 0 > /sys/class/gpio/gpio22/value
  echo 1 > /sys/class/gpio/gpio20/value & echo 0 > /sys/class/gpio/gpio22/value
Line 60: Line 61:
====ADC (Analog Input)====
====ADC (Analog Input)====
----
----
The ADC (Analog Input) value can be read from a different directory:


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  


cat /sys/devices/qpnp-vadc-8/mpp4_vadc
<b>Divide the result by 126582</b> in order to convert the number into volts (V).
 
<b>Note:</b> ADC can have tolerance of 0.5%.


====One-wire====
====One-wire====
----
----
In order to read one-wire sensor data you will need to follow these steps:


To read one-wire sensor data you will need to follow these steps:
<ol>
 
    <li>Set one-wire sensor value to "1' using the <i>ubus</i> command: <pre>ubus call ioman.gpio.onewire update '{"value":"1"}'</pre></li>
Set one-wire sensor '''''value''''' to '''''1''''' using '''''ubus''''' command.
    <li>List the connected one-wire devices from the <i>/sys/bus/w1/devices</i> directory using the <b><i>ls</i></b> command: <pre>ls /sys/bus/w1/devices</pre></li>
 
    <li>Choose a sensor to read and obtain its state from the <i>/sys/bus/w1/devices/&#60;device_name&#62;/w1_slave</i> directory: <pre>cat /sys/bus/w1/devices/&#60;device_name&#62;/w1_slave</pre></li>
  ubus call ioman.gpio.onewire update '{"value":"1"}'
</ol>
 
After that list out connected one-wire devices in directory '''''/sys/bus/w1/devices''''' with '''''ls''''' command.
 
  ls /sys/bus/w1/devices
 
Choose sensor that you want to know values off and using '''''cat''''' command read them from '''''/sys/bus/w1/devices/&#60;device_name&#62;/w1_slave''''' directory.
 
  cat /sys/bus/w1/devices/&#60;device_name&#62;/w1_slave

Latest revision as of 09:08, 7 March 2023

ioman.acl.acl0     - Analog Current loop
ioman.adc.adc0     - Analog input
ioman.dwi.dwi0     - Passive/Active input (PIN1)
ioman.dwi.dwi1     - Passive/Active input (PIN2)
ioman.gpio.dio0    - Configurable input/output (PIN3) 
ioman.gpio.dio1    - Configurable input/output (PIN4) 
ioman.gpio.iio     - Isolated input
ioman.gpio.onewire - One wire
ioman.relay.relay0 - Relay
ioman.relay.relay1 - Latching relay

In order to read values, use the status command:

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

To change input settings, use the update command and specify a value:

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

To change relay settings, use the update command and specify a 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 your device.

Digital inputs, Relay outputs


The 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 values, use the cat command:

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

To change an input state, use the 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, the other one is closed; so to turn an output on or off, you will have to change the value on both pins:

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)


The ADC (Analog Input) value can be read from a different directory:

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

Divide the result by 126582 in order to convert the number into volts (V).

Note: ADC can have tolerance of 0.5%.

One-wire


In order to read one-wire sensor data you will need to follow these steps:

  1. Set one-wire sensor value to "1' using the ubus command:
    ubus call ioman.gpio.onewire update '{"value":"1"}'
  2. List the connected one-wire devices from the /sys/bus/w1/devices directory using the ls command:
    ls /sys/bus/w1/devices
  3. Choose a sensor to read and obtain its state from the /sys/bus/w1/devices/<device_name>/w1_slave directory:
    cat /sys/bus/w1/devices/<device_name>/w1_slave