Use API to control GPIO?

I just found API documention here: https://dev.gl-inet.com/router-api/

Does this apply to GL-inet MIFI? If so, is it possible to use the API to control GPIO?

The API is still not yet finished. There is no GPIO API. So if you want to do this need to develop the API.

Do you have example code on how to interact with gpio?

You should ssh to the router. Here is an example.

root@GL-MIFI:/# echo 28 > /sys/class/gpio/export 
root@GL-MIFI:/# echo out > /sys/class/gpio/gpio28/direction 
root@GL-MIFI:/# echo 1 > /sys/class/gpio/gpio28/value
root@GL-MIFI:/# echo 0 > /sys/class/gpio/gpio28/value

You can check the PINOUT to see all available gpios.

Thank you, I have tested this but am seeing an issue with GPIO28. When I set it to LOW, it goes to 2.3v instead of 0v. When I go high, it goes to 5v which is correct. I’m trying to use this with this relay: Amazon.com

In LOW trigger mode. In high trigger mode it works, but not in LOW mode. Any thoughts?

Set it to low, it goes to 0V, and set it to high, it goes to 2.6V.

How do we get an authentication key for the API? I cant’ find any information on how to do that.

Also, I’m having another issue. I’m using GPIO28 with a Sainsmart 1 channel relay. If the relay is connected before the MIFI boots up, the MIFI will not boot. If I unplug the relay, the MIFI will boot up properly, and then I can plug the relay in and it works fine. This is a problem if I cannot keep the relay plugged in during reboots!

Here is the relay I’m using: https://www.amazon.com/gp/product/B0151F3A9Q/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1

You have to call the login at first. http://192.168.8.1/api/router/login?pwd=**YOUR PASSWORD**

For those that stumble onto this thread, it appears that having a relay plugged into GPIO28 will cause the MIFI to not boot. I have tested other GPIO’s, and the following are tested to work as expected with relays:

GPIO22
GPIO0

Thanks.

You might want to use a relay that has an opto for the signal if you aren’t already and don’t use power from the Mifi too.

I’m integrating the relay into the MIFI so I need to use the MIFI power. I will check and see if I can source an opto relay, I think that makes a lot of sense.

The GPIO is low 0 and 2.6V high. If you have 5V that may mean there is pull up.

Is your relay 5V?

My relay is 5v, but I have read that it works with 3.3v without any issue.

GPIO28 is used for bootstrap, so don’t use it when booting. It needs to be high at booting.

Also don’t connect 5V to the board which may damage the board.