Skip to main content

Adding new elements to OpenWrt's LuCI on GL-MiFi

If you are an IoT enthusiast who uses devices that run OpenWrt (routers from Goodlife, or MT7688), you would have considered creating a plugin for LuCI so that you can expose the functionality of any sensors/actuators that you may have connected to your OpenWrt box via OpenWrt's builtin web console.

This article on openwrt.org's wiki will tell you exactly how to do that.
As maybe obvious from the page, if you want to create dynamically generated web content, you will need to write lua scripts.

When trying out the steps from the wiki article for my GL-MiFi, I had to modify the file locations for placing various script like so:


  1. new_tab.lua had to be placed in:
    /usr/lib/lua/luci/controller/myapp
  2. cbi_tab.lua had to be placed in:
    /usr/lib/lua/luci/model/cbi/myapp-mymodule
  3. cbi_file can be put in the same place as mentioned:
    /etc/config
  4. view_tab.htm had to be placed in:
    /usr/lib/lua/luci/view/myapp-mymodule
Once I had the placed the files in the right location, I could see them in the web UI


My next step is to modify the lua scripts to run executables in C to query the various sensors that I have connected to my OpenWrt devices and display the latest values within a tab in WebUI.


I use the device specific SDK from OpenWrt to compile my C programs into executables.


Later on I will package my lua scripts and C programs into a simple .ipkg packages that one can install on any OpenWrt device

Comments