🛠 Advanced GPIO on KNOT HL9
Objectives
This advanced tutorial explains how to configure the GPIO pins of the MikroTik KNOT Gateway HL9 to read sensor data or control actuators. Although the HL9 is optimized for wireless connectivity (Wi-Fi HaLow, LTE), its Qualcomm IPQ-5010 processor offers local flexibility via RouterOS v7. We will demonstrate how to identify available pins, configure them in input or output mode, and read their state via the terminal.
Required Hardware
- A KNOT Gateway HL9 board running RouterOS v7.
- A computer with SSH or Winbox access.
- A simple sensor (e.g., push button or motion detector) or an LED.
- Connecting wires and resistors (if required by the sensor).
- Multimeter (optional for verification).
Steps
Connect to the board via SSH or Winbox. Open a terminal session.
- Access the Terminal
In RouterOS, GPIOs are often exposed via the /interface menu. Type the following command to list available interfaces: `` /interface print ` Look for interfaces named ether, wlan, or specifically gpio`. On some HL9 models, GPIOs may be mapped to specific physical pins documented in the manufacturer's datasheet. Note that the HL9 is primarily designed for network I/O; physical GPIOs may be limited or require extensions.
- Identify GPIO Interfaces
Assuming gpio1 is available. To configure it as output: `` /interface gpio set [find name=gpio1] mode=output ` To turn on an LED connected to this pin: ` /interface gpio set [find name=gpio1] value=on ``
- Configure a Pin as Output
To read a push button on gpio2: `` /interface gpio set [find name=gpio2] mode=input pull-up=yes ` To read the state: ` /interface gpio print stats ` Or via a direct read command if supported: ` /interface gpio get [find name=gpio2] value ``
- Configure a Pin as Input
Create a script to monitor the input and send an MQTT alert if the state changes. Use /system script to define the logic.
- Automate with a Script
Verification
Verify that the LED turns on/off according to the value=on/off command. For inputs, press the button and check that the read value changes in the terminal. Use log print to see events if you have configured logging.
To Go Further
Explore integration with MQTT to transmit GPIO states to a remote server. Consult the RouterOS documentation for advanced GPIO commands and specific limitations of the Qualcomm IPQ-5010 chipset.
Other tutorials for this board
Code examples for this board
gnss-position-tracking.pyPython-Bashble-advertising-sensor.inoRouterOS-Scriptlte-failover-monitor.pyPython-Bashnand-storage-cleanup.pyPython-Bashpoe-power-status.inoRouterOS-Scriptrouteros-mqtt-telemetry.inoRouterOS Script