Home automation project with led gpio - Relay controled from web ui

I am not going to answer your question, but...

The "normal" procedure for controlling LEDs is not by changing the default configuration using "uci". All controllable LEDs should be accessible at "/sys/class/leds"; you can just read and write from those "files".

If you share your code others can have a look at it, and point where could be the issue.

If you are willing to enter the rabbit hole, search for these terms, and keep yourself entertained for an evening or two: HomeAssistan, Domoticz, Tasmota, ESPHome, OpenHAB, Arduino, ESP8266, ESP32, firmata, ...

1 Like

Thanyou :smile:

In my google search i saw that everybody does this way (/sys/class/leds), but in my tests when the router reboot it always back to defaults set in the config files. I was thinking about that. if the router reboots, it returns in last state

From the list I only know 2 terms: arduino and Domoticz. I'll do my homework :smile:

I only have a static html page :frowning_face: I tried to make it dynamic.. I did like the LuCI index.html
and called a script in /www/cgi-bin ... in what language should this script be? is it lua? everything I tryed I have failed. I've even copy/paste a Hello World and it didn't run (permissions 755)
I miss something like

display_errors = on

<form action="/cgi-bin/out1>
 	<input onChange="this.form.submit()" type="checkbox" checked>
</form>

In this case I don't have the out1 file anymore but the idea was

  • Check state
  • if 0, set to 1
    else, set to 0
  • commit
  • restart service

theese all are device specic Home automation software. The ideia is to recycle this old and unsuported router, giving it some extra-life

Because of your resource constraints, best to have static HTML only.
LUA should also be possible to be used.
In case, you can drop LuCI completely, streamline your 18.06 (?) by removal of non-required stuff (PPP etc.), debug file system etc. and you are willing to build custom image, you might be able to install PHP.

1 Like

I just found this Example of web interface using uHTTPd and Lua
but it didn't worked too :weary:

actually... crelay supports raw gpio outputs... ( depending on your release... you may need to unload/uninstall a module or edit your dts to free up the gpio's )

Sorry, I have no expirience in using LUA on openwrt to serve and process web pages.
But I used PHP rather extensively on openwrt-devices having more resources.
However, the 4/32 might be sufficient enough for some old openwrt, which you need to use, anyway, and some streamlined PHP. Assuming, you give up LUCI, and some more.
Frankly speaking, interesting question, whether it will fit. Which version of openwrt do you use ?

1 Like

now: 18.06.9
but with the 17.01.5 I have more free space.

thats much easyer to me. but the device can't even do a 'opkg update' > "Only have 0kb available on filesystem"

OK, I will try to build a minimal image for your device, without LuCI, and some more streamlining. But having PHP. Lockdown is boring, anyway :slight_smile: Will let you know, whether it is possible. 17.01.5 should be best, because of PHP5 (I hope).

1 Like

that would be perfect!! anyway, I don't use PPP, neither ipv6 (my isp dont provide)

I tried to remove the packages after instalation to free some space, but without success

Package removal does not release the space in flash.
Either to use imagebuilder, or, even better, build from src. Which I will do.
Should be ready tomorrow, latest.

1 Like

I'll be waiting :star_struck:
Thank you! I'll start coding my php page :smiley:

Yes, that is expected behaviour. Bear in mind that each time you reconfigure the defaults, you are writing to your device's flash memory, which has a limited lifespan.

Wait, until confirmation, that PHP fits into flash, at least. You will still check, whether is can run in 32MB, as I have no test device.

1 Like

:hushed: I didn't knew that

but anyway. it is an old device, it is slow, 4/32, not suported anymore. its lifespan was over when I got it

I can't wait still. If this COVID situation doesn't end soon I'll get crazy
I need to keep my mind busy

Having ubuntu 18 or 20 only, I need to build openwrt 18.06, because 17.01 does not compile. Would need ubuntu 16 for compilation, obviously.

1 Like

with opkg I can only find php7 and php7-cgi is very big. I think that there is no way php7 will fit in this device

You are correct. I tried to build 18.06 image, but that is still too large.
But: I succeeded to build image for 15.05, incl. php5 and php5-cgi.
U R a brave man, and give it a try ?
I can also provide the build environment, ubuntu 16.04 in a Virtual-Box VM. So you can modify image yourself, as the PHP5 is without quite a few configurable/optional modules, which you might add, in case you need some.
No LuCI, of course. You need to SSH into the router.

1 Like