OpenWrt Forum Archive

Topic: Relay Control - home automation project

The content of this topic has been archived on 2 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,
I have decided to let my creation be used by everyone who wanted it.
Idea is very simple - using device leds (gpio) to control relays. I'm not very good with hardware but manage to do a simple schema to be able using arduino low level triggered relays (can be ordered from aliexpress).
I have do that on TPLINK router 740N v4/5

http://urlstat.eu/rc8_bb.jpg

It is writen in my language, so here is the translation:
Screw terminals 2 are equal to 1, total of 12 (drawing software limitation)
GND and voltage + are taken directly from the power plug.

LTV 827 is used becаuse on 2 of the leds GND is used for breaking circus

As I said  - I'm not very good with hardware, but so far this schema work without any issue.
For me most challenging part is software behind all that, it makes possible to schedule relays ON/OFF in any way.
Also a simple proximity monitor, to do action when you come home and your phone connect to WIFI.
There is much more to be told about it, but first I need to prepare english version of the image and make it available for downloading.

Nice project. I look forward to seeing more details.

Any reason for using the WR740N instead of, for instance, the more gpio-friendly GL-iNet devices?

Well,  I point my attention on that device, becаuse it is cheap - 10-15$ and work very stable with openwrt.

English version of the image is available now for downloading, there is a option in menu to switch between English and Bulgarian.

You can download images and uboot from here:
http://urlstat.eu/RC

After routers is updated it gonna respond to 192.168.7.1
default login for SSH/MACTELNET/LUCI are root with password "88888888"
Luci can be accessed on port 88 - http://192.168.7.1:88
on port 80 is RC interface, default logins are "admin" "88888888"

After flashing with the proper image you need to update u-boot as well, that is neccessary to prevent routers leds from blinking during boot process (thanks to Pepe2k)

mtd write /tmp/uboot740v4_5.bin u-boot

The images above contains my home configuration. Documentation into RC interface may be useful (keep in mind I may be a little bit behind with it and need to translate in in English) Ask any quesitions I will answer them.

Also I need to make clear one more thing. I share my work for non profit purposes only, if anyone want to make bussiness with it, must deal with me.

(Last edited by nedoskiv on 22 Jun 2016, 10:53)

Thanks your uboot

my tplink 740n v4 control relay

http://lh3.googleusercontent.com/-9FArGfEPObw/V3CAFg2nB8I/AAAAAAAAPoA/d7wUwTHM5aUHK4jOVQQNEFpJLXsQ378BwCCo/s512/IMG_20160626_132626.jpg

http://lh3.googleusercontent.com/-nuFIJsWVM7U/V3CAJHOoZYI/AAAAAAAAPoA/GJxPmZ_MnTkn_FQUR1Z8CTCh9MKBmN8UwCCo/s512/IMG_20160626_132509.jpg

http://urlstat.eu/mine.jpg

On screw terminals you can use arduino low level triggered relays that can be placed far away from the router,  50-100m is not a problem.


I will try to upload better photo

In case you won't or can't reprogram a router, you might use a Netgear DGND3700V1 that 11 LEDs of wich 9 of them can be used to control 9 relays, fortunately these 9 LEDs do not turn on or do not start blinking during startup process smile

The downside of this router is that the internal PCI WiFi module is bad supported on OpenWRT, as a workaround you can use a different WiFI PCI board or connect an external USB WiFi dongle to the router (or use an ethernet cable).

This router is very powerful: it has 2x400 Mhz CPUs, 2xUSB2 ports, 2 integrated Switch buttons (plus reset) both usable directly by triggerhappy, 1 WAN and 4 LAN ethernet connectors, 128 Mbytes of RAM plus 64 Mbytes of Swap (NAND) and 32 Mbytes of Flash (NOR).

Here are the commands to switch ON the 9 LEDs (to switch them off use "echo 0 > ..."):

/bin/echo 1 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:blue:wifi5g/brightness
/bin/echo 1 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:green:dsl/brightness
/bin/echo 1 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:green:inet/brightness
/bin/echo 1 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:green:usb-back/brightness
/bin/echo 1 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:green:usb-front/brightness
/bin/echo 1 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:green:wifi2g/brightness
/bin/echo 1 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:green:wps/brightness
/bin/echo 1 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:red:inet/brightness
/bin/echo 1 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:green:lan/brightness

LED name, Color, GPIO, #note
power, red, 22, # it turns on at bootup
power, green, 24, # it turns on and starts blinking at bootup
lan, green, 23, # usable
usb-back, green, 14, # usable
wifi2g, green, 26, # usable
wifi5g, blue, 27, # usable
dsl, green, 2, # usable
inet, red, 4, # usable
inet, green, 5, # usable
usb-front, green, 13, # usable
wps, green, 11, # usable

Board switches as seen by triggerhappy:

root@OpenWrt:~# thd --dump /dev/input/event*
EV_KEY    KEY_WPS_BUTTON    1    /dev/input/event0
# KEY_WPS_BUTTON    1    command
EV_KEY    KEY_WPS_BUTTON    0    /dev/input/event0
# KEY_WPS_BUTTON    0    command
EV_KEY    KEY_WLAN    1    /dev/input/event0
# KEY_WLAN    1    command
EV_KEY    KEY_WLAN    0    /dev/input/event0
# KEY_WLAN    0    command

KEY_WLAN = gpio-10
KEY_WPS_BUTTON =  gpio-35

Usable GPIOs:

root@OpenWrt:~# cat /sys/kernel/debug/gpio
GPIOs 0-37, bcm63xx-gpio:
gpio-2   (DGND3700v1_3800B:gre) out hi
gpio-4   (DGND3700v1_3800B:red) out hi
gpio-5   (DGND3700v1_3800B:gre) out hi
gpio-10  (wlan                ) in  hi
gpio-11  (DGND3700v1_3800B:gre) out hi
gpio-12  (reset               ) in  hi
gpio-13  (DGND3700v1_3800B:gre) out hi
gpio-14  (DGND3700v1_3800B:gre) out hi
gpio-22  (DGND3700v1_3800B:red) out hi
gpio-23  (DGND3700v1_3800B:gre) out hi
gpio-24  (DGND3700v1_3800B:gre) out lo
gpio-26  (DGND3700v1_3800B:gre) out lo
gpio-27  (DGND3700v1_3800B:blu) out lo
gpio-35  (wps                 ) in  hi

(Last edited by pilovis on 6 Sep 2016, 21:34)

I like TP-LINK routers, they work very stable and are cheap. I hope to have time soon to adapt my software to works on Orange PI, they have a lot of GPIOs and price is about 15- 50$

http://www.lovisolo.com/asterisk/software/openwrt/netgear-DGND2700-home-automation/20160911_183045.jpg
http://www.lovisolo.com/asterisk/software/openwrt/netgear-DGND2700-home-automation/20160911_183100.jpg
http://www.lovisolo.com/asterisk/software/openwrt/netgear-DGND2700-home-automation/20160911_183320.jpg
http://www.lovisolo.com/asterisk/software/openwrt/netgear-DGND2700-home-automation/20160911_180049.jpg

The discussion might have continued from here.