Hotplug toggle WiFi using GPIO

Hello everyone,

I am using an Onion Omega 2S+ module which runs on OpenWrt from what I can gather. My request is pretty simple. I want to use a GPIO on the Onion(GPIO19) to toggle WiFi On and Off. I have set GPIO19 to be an input, pulled it high to 3.3VDC and have a button to pull it down(Active-Low). It appears that Hotplug has the capabilities I'm looking for as documented here:

My only problem is that this example assumes a button called "ses" which I do not have access to. My question is how can I register GPIO19 as a button on the system so hotplug can monitor it? Is this even possible? I've been looking most of the day and cannot find the answer I'm looking for.

I tried the preliminary steps here to try to identify GPIO19 as a button using the logging script but I never got anything when pressing the button:

It appears the image does not currently attach GPIO19 as a button so is it possible for me to do so?

Thank you very much for reading.

If you're running OEM firmware, while it is close to OpenWrt, it is a "fork" of OpenWrt and not everything in OpenWrt will apply all the time.

The best OpenWrt information is at the new site -- the link for that page that is maintained is

Setting up a GPIO line as an input "key" generally requires a change to the kernel. Otherwise it is a "tree falling in the forest" that nobody is there to hear.

If you've successfully set up your device running Onion firmware to be able to read the GPIO line, then I'd suggest polling that line with a script. The wifi command can be used in that script to enable or disable the 802.11 wireless.

If you wanted to use the built-in "key handler", then you'd probably need to set up that GPIO as a "key" in the DTS and build from source. I'm not very familiar with their code, but I'd start by looking at

Thanks Jeff,

I was afraid it wouldn't be all that simple. I wanted to avoid running another script if possible, it's always been my opinion that the less things you have running the less there is to go wrong. This is not a hobby application, it's a product that end users will need to be able to interact with so reliability is key.

I'll look into initializing a script to monitor the input on boot and turn wifi on/off accordingly. I'm certainly in no position to be rebuilding the Kernal, I'm way to green with the Onion module at this point. Perhaps I'll investigate that later down the line.

Thank you for your input Jeff,

If a “product”, I’d definitely recommend modifying the DTS to link the GPIO line into the kernel and its key-event framework. Check the status of the line at boot, as you may “miss” its initial state.