We equip Mikrotik RBM33G on a budget for “long-range combat”

Mikrotik OEM RouterBoard RBM33G is far from new and is well known among Mikrotik specialists and users. It was created by the manufacturer in order to give everyone the opportunity to “design” their own router. Currently, this board is not at all outdated, it is actively used and is full of interesting “surprises” for those who do not know all its capabilities.

This small-sized, very productive board (on board is a dual-core MediaTek MT7621 880 MHz processor with 16 MB of flash memory and 256 MB of DDR3 RAM), has a number of hardware expansion options – two mini PCI-e slots for installing modem and/or wifi modules -radio cards), a microSD slot for an additional memory card (located on the back of the board), an M.2 slot for installing an SSD, which allows you to more than compensate for the lack of flash memory on the board itself.



Rice. 1 RBM33G Board appearance. Top left to right connectors: 2 miniPCI-e, M.2, USB.


I was interested in making the most of the expansion capabilities of the board, including installing a “non-native” modem and wifi module on it.
I got the RBM33G used used for half the price of a new one (5000 rubles). I also purchased the “original” Mikrotik CA433U case for full price (3,900 rubles), since I couldn’t find a used case like this, and I didn’t want to use others. After Googling the Internet a little more, I bought for pennies what I needed on Avito: Huawey ME909s-120 LTE modem (for 2000 rubles) – not very fast by modern standards (Cat4), but very reliable and quite sufficient to reserve an Internet channel outside the city (I still don’t understand why modern modems with aggregation are used in Russia – in order to use up all the traffic on the SIM card in 3 minutes?).
With the wifi module it turned out to be a little more complicated, since I also did not want to install the “native” Mikrotikov module, which now, under the conditions of sanctions, is heavily priced, and little is specifically known about compatible modules (except that there is compatibility with the Atheros families AR93xx, AR94xx, AR95xx, and Qulcomm QCA95xx, QCA98xx, QCA6300). I had to think and search. Taking into account the commitment of Mikrotik developers to Atheros chips, as a result, for only 50 rubles. (yes, yes, fifty!) I bought an old, half-sized Qualcomm Atheros AR5B95 with wifi 2.4 MHz b/g/n, which fit perfectly and worked immediately with the RBM33G. I haven’t tried 5 MHz wifi modules, nor have I tried dual-band modules, probably for me this is a matter of the future.
Obviously, I also had to purchase antennas for lte modems and wifi and pigtails for them (for the LTE test, I took ordinary whip antennas with a low gain, designed to work in “urban” conditions). All together it amounted to about 2500 rubles.
We also purchased an industrial-type Metorage SD card with a capacity of 32GB (RUB 1,600) to install the Mikrotik Dude server. For such tasks, it is always better to take the industrial (“industrial”) SD standard, designed for the appropriate operating conditions.



Fig 2. Industrial SD card 32 GB.

As an SSD, I purchased an M.2 disk GUDGA GVX-2242 with a capacity of 512 GB with an M key of 2242. In choosing an SSD, I was guided only by the physical length of the disk (42 mm) and the price (3000 rubles). As stated by the manufacturer of the RBM33G, the system only supports SSDs in the M.2 form factor with an M key, and no matter how fast the drive is, only the “first” speed – PCI-x1 – is supported.



Fig 3. SSD GUDGA M.2 512 GB M key.

SSDs made specifically in size 2442 are perfect for mounting on the RBM33G, since there is a mounting hole under it into which you need to insert a rivet from the K-25 RBM33G kit. The SSD was planned for storing script libraries, various necessary programs and files, available in shared folders via the SMB protocol and FTP. It’s difficult to say how long the disk will last. For better cooling, it is better to glue an aluminum radiator to it.
The system immediately “saw” both disks, SD and SDD, in /system disk without any problems. Of course, they had to be repartitioned into ext3 format and network folders configured in /ip smb. For those who will follow in my footsteps, advice – do not take high-speed SSDs, the work will still be slow, because… The board only supports PCI1 x. Mikrotik is not designed to be a NAS at all; the official manual recommends using its SSD for IP databases, /user manager, web proxy cache and data backup or log storage. (https://wiki.mikrotik.com/wiki/Manual:System/Disks).
The RBM33G has a nice feature: most Mikrotik boards disable the USB port when both mini PCI-e slots are used. You can install one mini PCI-e modem and a wifi radio card in the RBM33G without disconnecting the USB port (without removing the corresponding jumper). If you need to install two modems, the jumper must be removed, but then only the USB2 interface is disabled, and USB3 still remains connected. So, even with a “full load”, you can use the USB3 port to connect an additional drive or, for example, a super-fast modem with frequency aggregation (I have not done this yet).
A separate, very interesting expansion possibility from my point of view is the presence of a GPIO (input/output interface) in the RBM33G, the connector of which is present on the board in the form of 26 “pins” (pins). Some of the PIN contacts of the connector are accessible programmatically from the console or the RouterOS scripting language and can be configured for both input and output. The GPIO RBM33G pinout is described in the official documentation
help.mikrotik.com/docs/display/UM/RBM33G



Figure 4. RBM33G GPIO pinout (26 pins).

Interestingly, the Mikrotik GPIO pinout corresponds exactly to the 26-pin GPIN connector of the Raspberry Pi B. I don’t know if this is a standard or a deliberate borrowing for the compatibility of Mikrotik developers.



Fig 5. The GPIO circuit of the RBM33G exactly matches the GPIO connector of the Raspberry Pi B (it is available on the Internet and its colorful version is convenient to use).

RBM33G has only digital GPIOs. Pins 3, 5, 12, 13, 15 and 16 are available in software. By default, only Pin3 and Pin5 are available under GPIO on RBM33G:

/iot gpio digital print  

# NAME DIRECTION OUTPUT INPUT SCRIPT
0 pin3 input 0 1
1 pin5 input 0 1

Also, by default, Pin 12-16 are used for the serial port (also, by the way, a separate topic that we haven’t gotten around to yet). To use them under GPIO you need to run the command:

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

,

Disabling GPIO from the serial port. For the changes to take effect, the board must be rebooted:

/system reboot

Now as many as six digital I/O lines will be available under the GPIO:

/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
5 pin16 output 0

RBM33G has only digital input/output lines, no analog lines. All lines can be configured programmatically for both input and output:

/iot gpio digital set pin15 direction=input
/iot gpio digital set pin16 direction=output

On lines configured for output, you can programmatically set the value of a logical one or zero (in this case, a voltage appears on the line from 0 to +1.4V and from +1.41 to +3.63V, respectively).

/iot gpio digital set pin16 output=1
/iot gpio digital set pin16 output=0

You can attach repository scripts or directly executable code to lines:

 /iot gpio digital set pin12 script=io_test
 /iot gpio digital set pin13 script=":log warning \"Reverse line\""
 /iot gpio digital set pin15 script=":global myFunc; [$myFunc]"

Then, when the line state changes, the attached script or instruction will be executed. For some reason, the global function “attached to GPIO” was executed only if it was created directly from the CLI (possibly an error by the Mikrotik developers).
Accordingly, using GPIO, you can connect any equipment capable of receiving and transmitting digital signals to the RBM33G. That is, you can control the operation of this equipment or receive data from it, or control the operation of Mikrotik from it.
I decided to connect my favorite environment monitoring and load management module Laurent-5G from KernelChip (https://kernelchip.ru/Laurent-5G.php) to the Mikrotik GPIO. This module has similar, easy-to-connect, programmable general purpose I/O lines (8 IO lines), with the same logic and control voltage as the RBM33G GPIO, that is, it is perfectly suited for this task.
To experiment, I connected pin3 and pin5 of the RBM33G, configured as output, with bidirectional discrete general purpose IO 1 and 2 pins, configured as input.


Rice. 6 Connection of GPIO RBM33G Pin3 and Pin5 and Laurent-5G IO1 and IO2 lines

When sending a command to Mikrotik RouterOS:

/iot gpio digital set pin3 output=1 

IO1 Laurent-5G is supplied with a voltage of +3V within the permissible deviation limits (logical unit). At


/iot gpio digital set pin3 output=0

The voltage on IO1 will not exceed +1.41 (logical zero)
The appearance of a particular phenomenon on the input line can be detected on the Laurent-5G using a specially “programmed” task of the CAT system (see Laurent-5G manual kernelchip.ru/download/Laurent-5_5G/Laurent-5_Manual_v.1.15.pdf) and upon achieving this fact, perform one or another action.

I also connected a block of 4 relays 220V with low control voltage (1.5-5V) KIT MP701 (https://masterkit.ru/shop/1327359) to the GPIO RBM33G lines configured to output and directly controlled the operation of its relays through scripts RouterOS.



Rice. 7 Relay module 220V 4 channels MP701 with control voltage 1.4-5V.

The connection diagram is simple: take +5V, for example, from PIN 4, and GND from PIN 6 GPIO RBM33G. Control signals will come from PINs 12, 13, 15 and 16, configured as output and physically connected respectively to PINs 2-4 (IN1-4 in the diagram) of the MP701 block.



Rice. 8 Trial connection of MP701 to RBM33G “on the knee” “on the table”. The photo also shows the installed Huawey modem and half-size wifi Atheros.



Fig.9 Connecting the MP701 relay module to the GPIO RBM33G housed in the original Mikrotik CA433U housing.

After installing the compact RBM33G into the extended CA433U chassis, there is just enough free space for internal installation of the MP701 module. Please also note: in the photo there is another SSD installed, a longer one (size 2280), which does not interfere with the installation of the MP701. Also installed are two mini-PCI-e Mikrotik R11e-LTE 4 Cat modems.
We configure lines 12, 13, 15, 16 of Mikrotik RBM33G for output:

/iot gpio digital set pin12 direction=output
/iot gpio digital set pin13 direction=output
/iot gpio digital set pin15 direction=output
/iot gpio digital set pin16 direction=output

Now you can switch the 220V relay of the MP701 unit:

# включаем реле 2; /iot gpio digital set pin13 output=1
# выключаем реле 4; /iot gpio digital set pin16 output=1

Since we are using mechanical relays and not optocouplers, they will “click” when switching; to check operation, you don’t have to connect the load.
As you can see, relay numbers 1, 2, 3, 4 correspond to lines 12, 13, 15, 16, respectively. To avoid confusion with these numbers, you can put them in an array, where the line number will correspond to the serial number of the array element. Then you can call the array elements using the expression ($Array->X), where $Array is the name of the array, X is the element number. Don’t forget that array elements are numbered starting from zero.

:local arrayPin {12; 13; 15; 16}
:local on 1; local off 2

# работаем сразу со всеми реле массива

# - > включение
:local count 0
:foreach Xpin in=$arrayPin do={
          :set count ($count+1)
          :put «Включаем реле $count»
          /iot gpio digital set "pin$Xpin" output=$on
   }
}

# - > выключение
:set count 0
:foreach Xpin in=$arrayPin do={
          :set count ($count+1)
          :put «Выключаем реле $count»
          /iot gpio digital set "pin$Xpin" output=$off
   }
}

# или отдельно с выбранным реле
:set count 2
     /iot gpio digital set "pin$($arrayPin->2)" output=$on

Or you can work a little harder and write a more convenient, universal function:

# Функция работы с реле 4-х канального модуля MP701; by Sertik 03/10/2023

# $1 - действие (on/off/status/direction/info), при info всегда выдается информация по всем реле
# $2 - номер реле (если не указан действие выполняется над всеми)
# $3 - input/output, используется при $1 direction, если не задан, действие производится над всеми линиями


:global iotRele do={
:local arrayPin {12; 13; 15; 16}
:local act;

:if ($1="help") do={
         /terminal style varname
         :put ""
         :put "Function works with GPIO RBM33G"
         :put "version 1.0"
         :put "by Sertik 03/10/2023"
         :put ""
         :put "\$1-action: on/off/status/direction/info/help"
         :put "\$2-rele number, if not define - all"
         :put "\$3-input/output for direction"
         :put ""
         /terminal style none}

:do {
    :foreach Xpin in=$arrayPin do={
            /iot gpio digital set "pin$Xpin" direction=output}
             } on-error={:local gpioanswer "GPIO pin 12-16 is set on serial-port"
                              :put ("ERROR $0"."\r\n"."$gpioanswer")
                              :log error ("ERROR $0"."\r\n"."$gpioanswer")
                              :return $gpioanswer       
                   }

     if ($1="info") do={
:local gio [/iot gpio digital print as-value]
:local count 0; local name; :local dir; :local state;
:foreach i in=$gio do={
                            :set name ($gio->$count->"name")
                            :set dir ($gio->$count->"direction")
                            :set state ($gio->$count->"output")
                            :set count ($count+1)
         :put ("$count "."$name "."$dir "."$state")
         :log info ("$count "."$name "."$dir "."$state")
  }
:return $gio}

:if (($1="status") and ([:len $2]=1)) do={
do {
                  :return [/iot gpio digital get "pin$($arrayPin->([:tonum $2]-1))"]
} on-error={:return Error}
}

:if (($1="direction") and ([:len $3]=0)) do={
    :if (($2="input") or ($2="output")) do={
        do {
                  :foreach Xpin in=$arrayPin do={
                  /iot gpio digital set "pin$Xpin" direction=$2
                   }
        } on-error={:return Error}
  } else={:return Error}
:return Done}

:if (($1="direction") and ([:len $2]=1) and ([:len $3]>0)) do={
     :if (($3="input") or ($3="output")) do={
            :do {
                  /iot gpio digital set "pin$($arrayPin->[:tonum $2])" direction=$3
                } on-error={:return Error}
     } else={:return Error}
:return Done}

     :if ($1="on") do={:set act 1}
     :if ($1="off") do={:set act 0}

:if ([:len $act]>0) do={

   :if ([:len $2]>0) do={
           :do {
                  :if (([:tonum $2]<=0) or ([:tonum $2]>4)) do={:return Error}
                  /iot gpio digital set "pin$($arrayPin->([:tonum $2]-1))" output=$act
                  } on-error={:return Error}
     } else={
                  :foreach Xpin in=$arrayPin do={
                  /iot gpio digital set "pin$Xpin" output=$act
                   }
                } 

 :return "Done"} else={:return "Error"}
}


# Примеры вызова

# вывести состояние всех реле в терминал и лог
# [$iotRele info]

# запросить состояние реле 3
# :local R3 [$iotRele status 3]

# установить направление ввода/вывода линии 4
# [$iotRele direction 3 output]

# установить направление ввода/вывода всех 4-х линий на ввод:
# [$iotRele direction input]

# :log error ("Включаем реле 3 "."$[$iotRele off 3]")
# :delay 2s
# :log warning ("Выключаем реле 3 "."$[$iotRele off 3]")

# Включаем все реле
# [$iotRele on]

# Выключаем все реле
# [$iotRele off]

You can, of course, instead of MP701 use other control current-compatible relay modules, including solid-state ones.
You can also install small, nice “momentary” buttons on the case with Mikrotik RBM33G, connecting them to the +5V GPIO PIN and one of the input/output lines configured to input. Then, when you press the button, “logical 1” will appear on the line, and when released, “logical zero” will appear. This fact can be recorded with a quickly executed Router Scheduler script (/system scheduler). Well, you really have to hold the button for at least a second and call the script with the same frequency. Then it depends on your imagination and goals – reboot the router, switch the relay, switch to another wan channel, etc…
At this point, the RBM33G package can be considered complete.



Rice. 10 Photo of the “finished product” in the CA433U case.

For versatility, you can install one LTE modem and a dual-band wifi module in mini PCI-e slots (then we will have wifi 2.4 and 5 MHz), or two modems (one mini PCI-e, the other USB), if you need to reserve LTE – Internet channels. An additional high-speed M.2 modem with a USB3 adapter, by the way, can be installed directly into the CA433U case; there is enough space. You can install DUDE-server on an SD card for network monitoring (I have already done this successfully several times before and I can say that industrial-grade SDs are more suitable for this purpose than SSDs), use the SSD as a storage for script libraries and not frequently used files . By the way, in RouterOS v7 you can use containers opened on an SSD.
It remains to connect the connector to the MP701 power contacts to the RBM33G housing, from which you can remove the phase of the 4-pin relay module. Mikrotik RBM33G with MP701 or other compatible relay module can be used to turn on/off additional network equipment, physically connect NAS when VPN users log in, control cooling/heating elements of a network cabinet, etc…
In general, the combine we assembled is quite capable of coping with the loads and “wants” of the network of a medium office or country residence.
Write your options for extended use of RBM33G in the comments.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *