RBM33G GPIO used

RBM33G has a GPIO, which can be used, in particular, by connecting script execution to them. Could respected gurus explain in detail how best to use this? Or is it related only to KNOT ?

As far as I understand, you can connect analog outputs of equipment to PIN 2,3 and use a script to read the voltage value on them
But it’s not clear how to get the voltage value other than the print command
/iot gpio analog print

is there a get command ?
Does get exist here ?

/iot gpio analog get pin2 value

?
Yes, that seems right.

PIN 4-6 are digital, open collector type. Moreover, they seem to be customizable for both input and output.

/iot gpio digital set pin4 direction=output ?
/iot gpio digital set pin4 output=0

You can also assign script execution to the corresponding PIN:

/iot gpio digital set pin5 script=script1



/iot gpio digital set pin5 script="/system .."

And accordingly, the state of logical 1 or logical zero can be read from PINs configured for input:

/iot gpio digital get pin5 input

Accordingly, you can build script logic on this:

if ([/iot gpio digital get pin5 input] = "0") do={}

Note: In POS 6 /system gpio is used, in POS 7 /iot gpio submenu

I would ask respected gurus to correct my mistakes and put the mess in my head in order…

I won’t answer you only because I don’t have the apparatus and therefore I can’t test anything.
I am sorry.

It’s okay Rex. Maybe Amm0 has RBM33G?

After rereading the documentation, I realized that for RBM33G, you can use GPIO lines 12,13,15,16 of its connector. At the same time, you must first disconnect them from serial1:

/system/routerboard/settings/set gpio-function=""
/system/reboot

RBM33G has no analog lines. These four lines are available as digital.

After that, teams should work for them:

/iot gpio digital set pin12 direction=output
/iot gpio digital set pin12 output=0
/iot gpio digital set pin13 script=script1
/iot gpio digital set pin13 script="/system .."

/iot gpio digital set pin15 direction=input
/iot gpio digital get pin15 input


if ([/iot gpio digital get pin15 input] = "0") do={}

Naturally, you need to install the iot package. I 'll have to try …

I tried it ! Yes, it works!

As it turned out, the RBM33G does not really have analog lines, but it has as many as 6 digital ones, each of which can be configured for both input and output:

/iot gpio digital print

NAME DIRECTION OUTPUT INPUT SCRIPT

0 pin3 input 0 1
1 pin5 input 0 1
2 pin15 input 0 0
3 pin13 input 0 0
4 pin12 output 1 io_test
5 pin16 output 0

As you can see above, I set up line 12 for ai output and connected a script named "io_test" to it. Now, when changing the state of the line, a test script is run every time.

/iot gpio digital set pin12 output=1

... run /system script run io_test

/iot gpio digital set pin12 output=0

... run /system script run io_test

You can attach the execution of a direct instruction:

/iot gpio digital set pin13 script=":log warning \"Reverse line\""

I tried to hook a call to a global function:

 /iot gpio digital set pin13 script=":global myFunc; $myFunc"

But, the function was executed for me, for some reason only if it was directly created from the CLI

Now you can connect equipment to the lines and control it or receive data from it - that is, control the Mikrotik. I will connect my favorite Laurent-5G module to it https://www.kernelchip.ru/Product.php#LAURENT-5G