RUT241 - how to check if a client is connected on wifi?

Hello, I need some help.
I have a RUT241 running on a remote place. The RUT241 connects to the Internet via 4G with a private APN. I have 4 “Smart WIfI relays” connected to the RUT241. All I want to do is to check if these “Smart WIfI relays” are connected to the RUT241, and if possible create some type of alarm in case any connection is lost (via MQTT, POST, GET, whatever would do).
Does anyone have any idea how to do this?


I assume the WiFi relays are connected via WiFi?

If thats the case, you can use the following command to see connected stations:
iwinfo wlan0 assoclist

You can write a script and run it periodically via crontabs (crontabs information here) to check for connected devices. Something like:


# Smart wifis MAC address


# Check if the MAC is in the assoclist

iwinfo wlan0 assoclist | grep -q "$MAC"

# Check the exit status of grep

if [ $? -ne 0 ]; then

    echo "$MAC has disconnected" >> /etc/wifis.txt


Dont forget to give execution rights to the script:

chmod +x /etc/

In this example the script simply writes to the file, thus you would need to change the action in the script to send some kind of an alarm.

For example:

  • To send SMS via ‘gsmctl -S -s’ command (‘gsmctl -h’ for help).

  • Publish MQTT message from CLI using mosquitto (information here).

  • Send an HTTP POST using curl (information here).

There are many options, including the usage of custom modbus registers (here) (though this method is more complicated than it needs to be).

For example, writing to a register from CLI:

ubus call modbus_master tcp.test '{"ip":"","port":502,"id":1,"timeout":1,"function":3,"first_reg":1025,"reg_count":"1","data_type":"16bit_int_hi_first","no_brackets":1}'

Then, you can send this as a part of Modbus data or check those registers using Modbus Alarms to trigger actions (Modbus information here).

Kind Regards,

Thank you very much for this detailed answer. This is what I was looking for!

1 Like

This topic was automatically closed after 15 days. New replies are no longer allowed.