Tag Archives: environmental

Mikrotik Voltage Alarm/Beeper

I recently needed to make my routerboard generate an audible alarm based on voltage thresholds on the 12v battery wired directly to the RB2011.

This script was a modification of something i found when perusing the Mikrotik forums.
Change lowvoltage and highvoltage to suite your requirements.

#set lowvoltalarm to desired alarm voltage in tenths of a volt. 125 = 12.5v
:global lowvoltalarm 116
:global highvoltalarm 129
:global highvolt
:global lowvolt
:global starttime
:global hivolttime
:global lovolttime
:global vh
:local thisbox [/system identity get name]
:global voltage [/system health get voltage]
:local thistime [/system clock get time]
:local thisdate [/system clock get date]
:local thishour [:pick $thistime 0 2]
:local emessage ($thisbox . " voltage is: " . [:pick $voltage 0 2] . "." . [:pick $voltage 2 3])
:if ([:len $lowvolt] < 1) do={:set lowvolt 999; :set highvolt 0}
# set your email address in the next line
:if ($voltage <= $lowvoltalarm) do={
:for i from=1 to=20 step=1 do={
:beep as-value frequency=4000;
:delay 1
:put "Low voltage"
if ($voltage > $lowvoltalarm) do={
:put "Normal"