Eventually you might use a Triac instead of the relay, it's more reliable, needs less drive current and its lifespan is higher than the relay
...if the load is resistive. If the load is inductive, he might run into problems.
The content of this topic has been archived between 17 Apr 2018 and 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.
Eventually you might use a Triac instead of the relay, it's more reliable, needs less drive current and its lifespan is higher than the relay
...if the load is resistive. If the load is inductive, he might run into problems.
pilovis wrote:Just connect in series the N.C. of the first relay to the N.O of the second one.
thanks but i have to use 2 relays for 1 output, not very ecologic / econmic.
I'm searching for a software solution
You only need one NC relay to disable all the other ones during boot-up. Wire the relay to deny power to the coils of all the other ones while it is energized (during boot-up).
I've just added this Infrared USB Remote Controller to my OpenWRT Home Automation Server.
I paid it 10 Euro.
No drivers are needed, just plug in and use it (with Triggerhappy).
By using this device you can remote control your OpenWRT Server with a lot of functions, simply use Triggerhappy and configure some or all buttons of this remote controller with different functions of your choice , just check event names and values of buttons with "thd --dump /dev/input/event*" command.
NOTE: do not press the red POWER button, if you do it, the event code names will change and a restart of the router is needed to go back to default.
I would suggest you to remove or cut this button.
(Last edited by pilovis on 1 May 2015, 21:21)
the finished job:
Hello,
Would I be right assuming that your HG533 has bene running on BB flavor of OpenWrt?
If so, has the support of the status LEDs Ben handled there with the module like kmod-leds-gpio beong unloadable with opkg?
I have been struggling with CC of Openwrt, the support of LEDs has been buried in kernel there. I am unable to regain the control over these GPIOs unfortunately.
Any hints of how to reuse LEDs GPIOs of HG553 driven by OpenWrt CC would be very welcome!
Cheers
rymki.pl
(Last edited by rymki.pl on 13 May 2015, 17:10)
I've just added another feature to this Home Automation Server:
Auto-restore of previous channels status after a reboot/crash/power outageYou'll find all my "ready-to-use" configuration files and script, for Vodafone Station Huawei EchoLife HG553 + OpenWRT Attitude Adjustment, here:
http://www.lovisolo.com/asterisk/softwa … on-Server/If you want to use a different router, you'll just need to change the "/sys/devices/platform/leds-gpio..." trigger lines, with the ones suitable for your board.
Complete list of the board functionalities (using my files above):
- Three (or six) indipendent channels output (via simple relays board)
- Multiple input control (USB keyboard/USB keypad/USB mouse keys) with triggerhappy
- Full local control via keyboard/keypad/mouse
- Full local monitoring via red/blue leds on the router
- Full remote/local control/monitoring via internet webpage
- Full remote control/monitoring via SMS (internet connection not needed)
- Email and/or SMS notification for any channel status change
- Automatic restore of the previous channels status after a reboot/crash
- Realtime video remote/local control via USB webcam (mjpg-streamer)
- Realtime audio remote/local control via USB webcam's microphone (ssh arecord | aplay - alsa)Web Control/Monitoring Page (including Luci & Webcam):
http://IP_Address/index.html
List of remote SMS commands:
On1 = Activate Channel 1
On2 = Activate Channel 2
On3 = Activate Channel 3
Off1 = Deactivate Channel 1
Off2 = Deactivate Channel 2
Off3 = Deactivate Channel 3
Status = Send all channels status by SMSList of local USB Keyboard control keys
F1 = Activate Channel 1
F2 = Activate Channel 2
F3 = Activate Channel 3
F4 = Deactivate Channel 1
F5 = Deactivate Channel 2
F6 = Deactivate Channel 3
F9 = Activate All Channels
F10 = Deactivate All ChannelsEnjoy
Final notes: with Vodafone Station Huawei EchoLife HG553, you can have up to six indipendent output channels if you control and use both, red and blue leds, to drive the relays.
Hello Pilovis, How to Auto-restore of previous channels status after a reboot/crash/power outage ?
Hello Pilovis, How to Auto-restore of previous channels status after a reboot/crash/power outage ?
Example for Huawei EchoLife HG553 Barrier Breaker
----------------------------
- Save channels status
-----------------------------
file /root/status.sh: (chmod 777)
####################################
# by pilovis - parknat12@yahoo.com
#
# Write channel status to a file
####################################
# Area variabili
#
folder=/root # Cartella di lavoro
dbstato1=$folder/stato1 # File Stato Canale 1 per ripristino
dbstato2=$folder/stato2 # File Stato Canale 2 per ripristino
dbstato3=$folder/stato3 # File Stato Canale 3 per ripristino
# Aggiorna lo status di tutti i canali
#
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:adsl/brightness >> $dbstatus # stato canale 1
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:hspa/brightness >> $dbstatus # stato canale 2
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:lan/brightness >> $dbstatus # stato canale 3
# Cancella files /root/stato1-2-3 con dati precedenti (la sezione dopo li riscrive)
#
rm /root/stato1
rm /root/stato2
rm /root/stato3
# Inserisce lo stato puro di ogni canale in /root/stato1-2-3 per il ripristino dopo un reboot/crash
#
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:adsl/brightness >> $dbstato1 # canale 1
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:hspa/brightness >> $dbstato2 # canale 2
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:lan/brightness >> $dbstato3 # canale 3
exit 0
-------------------------------
- Restore channels status
-------------------------------
file /root/extract-status1.sh: (chmod 777)
while IFS=: read canale1
do
echo ${canale1} > /sys/devices/platform/leds-gpio.0/leds/HW553:blue:adsl/brightness
done < /root/stato1
file /root/extract-status2.sh: (chmod 777)
while IFS=: read canale2
do
echo ${canale2} > /sys/devices/platform/leds-gpio.0/leds/HW553:blue:hspa/brightness
done < /root/stato2
file /root/extract-status3.sh: (chmod 777)
while IFS=: read canale3
do
echo ${canale3} > /sys/devices/platform/leds-gpio.0/leds/HW553:blue:lan/brightness
done < /root/stato3
file /root/restore-status.sh: (chmod 777)
/bin/sh /root/extract-status1.sh
/bin/sh /root/extract-status2.sh
/bin/sh /root/extract-status3.sh
---------------------------
- Autostart at bootup
---------------------------
Insert this line in /etc/rc.local before 'exit 0':
/bin/sh /root/restore-status.sh
(Last edited by pilovis on 22 Jun 2015, 21:46)
eethon wrote:Hello Pilovis, How to Auto-restore of previous channels status after a reboot/crash/power outage ?
Example for Huawei EchoLife HG553 Barrier Breaker
----------------------------
- Save channels status
-----------------------------file /root/status.sh: (chmod 777)
####################################
# by pilovis - parknat12@yahoo.com
#
# Write channel status to a file
##################################### Area variabili
#
folder=/root # Cartella di lavoro
dbstato1=$folder/stato1 # File Stato Canale 1 per ripristino
dbstato2=$folder/stato2 # File Stato Canale 2 per ripristino
dbstato3=$folder/stato3 # File Stato Canale 3 per ripristino# Aggiorna lo status di tutti i canali
#
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:adsl/brightness >> $dbstatus # stato canale 1
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:hspa/brightness >> $dbstatus # stato canale 2
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:lan/brightness >> $dbstatus # stato canale 3# Cancella files /root/stato1-2-3 con dati precedenti (la sezione dopo li riscrive)
#
rm /root/stato1
rm /root/stato2
rm /root/stato3# Inserisce lo stato puro di ogni canale in /root/stato1-2-3 per il ripristino dopo un reboot/crash
#
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:adsl/brightness >> $dbstato1 # canale 1
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:hspa/brightness >> $dbstato2 # canale 2
cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:lan/brightness >> $dbstato3 # canale 3exit 0
-------------------------------
- Restore channels status
-------------------------------file /root/extract-status1.sh: (chmod 777)
while IFS=: read canale1
do
echo ${canale1} > /sys/devices/platform/leds-gpio.0/leds/HW553:blue:adsl/brightness
done < /root/stato1file /root/extract-status2.sh: (chmod 777)
while IFS=: read canale2
do
echo ${canale2} > /sys/devices/platform/leds-gpio.0/leds/HW553:blue:hspa/brightness
done < /root/stato2file /root/extract-status3.sh: (chmod 777)
while IFS=: read canale3
do
echo ${canale3} > /sys/devices/platform/leds-gpio.0/leds/HW553:blue:lan/brightness
done < /root/stato3file /root/restore-status.sh: (chmod 777)
/bin/sh /root/extract-status1.sh
/bin/sh /root/extract-status2.sh
/bin/sh /root/extract-status3.sh---------------------------
- Autostart at bootup
---------------------------Insert this line in /etc/rc.local before 'exit 0':
/bin/sh /root/restore-status.sh
eethon wrote:thanks pilovis above explanation, good luck always, sorry my English is not good
very nice thanks dude..
(Last edited by najeebsalmaa on 8 Jul 2015, 11:28)
Hello!
I would like to ask, what is it on the second plan of this photography? Looks closely to womens underwear, pareo?
... or maybe is it your socks?
(Last edited by apuk2 on 18 Sep 2015, 21:47)
pilovis wrote:Instructions how to transform a cheap 110/220Vac Home PIR Motion Sensor in a "USB PIR motion sensor" for OpenWRT/Raspberry/Arduino
... if you have a router that supports GPIO inputs (Vodafone Station does NOT) you can connect the PIR sensor directly to GPIO without using USB, simply connect the collector of the Optocoupler output transistor to a GPIO input pin (button active low image).
thank for all your works!
i have read this guides: https://wiki.openwrt.org/doc/howto/hard … ugbuttons, https://wiki.openwrt.org/doc/hardware/port.gpio
i want to check another gpio port (etc Lan1,2,3. led) to connect pir sensor. I could check status of them by uci command. how to excute a event when it change status without loop checking!
p/s: sorry my bad english
(Last edited by phantnang on 17 Dec 2015, 09:26)
Bluetooth Presence Detection
In OpenWRT Attitude Adjustement, Barrier Breaker and Chaos Calmer, bluetooth does not work, there is no way to pair anything, so it is useless
Anyway, I found a way to use the bluetooth to do something without the need to pair a device: "bluetooth presence detection",
this could be usefull to enable or disable services when a specific bluetooth device is (or isn't) present in the nearby area.
First of all you need to install bluetooth service and USB support:
opkg update
opkg install kmod-bluetooth bluez-libs bluez-utils kmod-usb-core kmod-usb-uhci kmod-usb2 usbutils
then enable it with the following commands:
/etc/init.d/dbus enable
/etc/init.d/bluez-utils enable
/etc/init.d/dbus start
/etc/init.d/bluez-utils start
Then reboot the router.
To check if your USB bluetooth device is properly detected and is working, run this command:
hciconfig
you should get something similar to this:
hci0: Type: USB
BD Address: 00:15:83:C9:17:96 ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING
RX bytes:22331 acl:0 sco:0 events:1428 errors:0
TX bytes:1482 acl:0 sco:0 commands:176 errors:0
now you can scan for you bluetooth device mac address with the following command:
/usr/bin/hcitool scan
then create the 'check_presence_bt.sh' script:
vi /root/check_presence_bt.sh
and add the following lines to it:
#!/bin/sh
# Bluetooth Presence Detection
# By Lovisolo P.M. - parknat12@yahoo.com
#
# scan for bluetooth devices and put the result into a variable:
c=$(/usr/bin/hcitool scan)
#
# check for a specific MAC ADDRESS presence:
if [ `echo $c | grep -c "38:2D:E8:49:C1:87" ` -gt 0 ]
then
checkbt=$'Device available';
# you may add here a command or script to be executed when the device is available
else
checkbt=$'Device is OFF or unavailable';
# you may add here a command or script to be executed when the device is unavailable
fi
# write scan results to a file into the ramdisk:
/bin/echo $checkbt > /tmp/checkbt.txt
# eof
note: 38:2D:E8:49:C1:87 is the mac address of the device to be discovered, change it to the desired mac addres.
then give the right permissions to the script:
chmod 755 /root/check_presence_bt.sh
Now you need to create a cron job to execute the above script every minute by inserting the following line in '/etc/crontabs/root' (if the file does not exist, create it):
*/1 * * * * /bin/sh /root/check_presence_bt.sh
To display the 'Bluetooth Presence Detection' current results, run the following command:
/bin/cat /tmp/checkbt.txt
*** IMPORTANT NOTE: the bluetooth target device must be set to "discoverable" ***
(Last edited by pilovis on 19 May 2016, 18:49)
just a little note:
to check the GPIO configuration of your router, simply use this command:
cat /sys/kernel/debug/gpio
you should get something like this (example taken from TP-Link TL-WDR 3600):
GPIOs 0-22, ath79:
gpio-11 (tp-link:green:usb1 ) out hi
gpio-12 (tp-link:green:usb2 ) out hi
gpio-13 (tp-link:blue:wlan2g ) out lo
gpio-14 (tp-link:blue:system ) out hi
gpio-15 (tp-link:blue:qss ) out hi
gpio-16 (QSS button ) in hi
gpio-17 (RFKILL switch ) in hi
gpio-18 (external LNA0 ) out hi
gpio-19 (external LNA1 ) out hi
gpio-21 (USB2 power ) out hi
gpio-22 (USB1 power ) out hi
(Last edited by pilovis on 3 Feb 2016, 10:25)
After more than two years of intensive testing about Openwrt with many routers, I can say that (in my opinion) Openwrt is very unreliable: too many crashes, bad USB support, fake bluetooth support, very unstable usb "overlay".
This the end word at my Openwrt story, from now on I will move to Raspberry devices.
Sorry to hear that you are leaving openWrt. I have appreciated your contributions.
With a dozen or more openWrt devices running for years, I have not experienced the unreliability that you report, even with power outages (though my applications have been much more simple than yours).
I appreciate your reporting (by implication) on high reliability for the Raspberry Pi family, since I'm now looking at a system which has 13 temperature readings and controls 14 relays and needs to be quite reliable since failure could be expensive (though I'll try to mitigate that in the design and make it fail safely).
Can you elaborate further on the types of failures you have experienced?
(Last edited by lizby on 15 Feb 2016, 16:33)
I performed many tests on Raspberry PI Wheezy and changed my idea, I found it extremely slow compared to a router with OpenWRT and very instable too.
Also I tested Rasperry PI with OpenWRT Barrier Breaker, worst than before, too many packages missing!
I think I will go back to my TP-link TL-WRD3600 with OpenWRT Barrier Breaker, the best solution I've found up to now.
I will soon post a new project
I performed many tests on Raspberry PI Wheezy and changed my idea, I found it extremely slow compared to a router with OpenWRT and very instable too.
Also I tested Rasperry PI with OpenWRT Barrier Breaker, worst than before, too many packages missing!I think I will go back to my TP-link TL-WRD3600 with OpenWRT Barrier Breaker, the best solution I've found up to now.
I will soon post a new project
i think it's better with QCA soc such as: WRD7500, WR1043...
how to config gpio led port for input and read status it on Barrier Breaker.
(i found the reason: rmmod leds_gpio ------------>echo "leds-gpio" > /sys/bus/platform/drivers/leds-gpio/unbind)
sr, my bad english
(Last edited by phantnang on 4 May 2016, 19:08)
Use USB drive for more storage. My router dlink dir615c2 400mhz,4MB flash, i use usb drive for more storage to install php and lighttpd. My web control run php with display status of relay.
Here my index.phpdefault user/pass is admin/admin
Very nice job!
I just modified it a little bit to adapt it to my Huawei EchoLife HG553 (Barrier Breaker)
prerequisites:
opkg update
opkg install php5 php5-cgi php5-mod-session
PHP code modifications (just the modified sections):
$arrMode = array(
'status0' => 'cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:lan/brightness',
'on rele' => "echo '0' > /sys/devices/platform/leds-gpio.0/leds/HW553:blue:lan/brightness",
'off rele' => "echo '1' > /sys/devices/platform/leds-gpio.0/leds/HW553:blue:lan/brightness",
'status2' => 'cat /sys/devices/platform/leds-gpio.0/leds/HW553:blue:adsl/brightness',
'on luce' => "echo '0' > /sys/devices/platform/leds-gpio.0/leds/HW553:blue:adsl/brightness",
'off luce' => "echo '1' > /sys/devices/platform/leds-gpio.0/leds/HW553:blue:adsl/brightness",
);
if(isset($_POST['router'])) {
// $contents = file_get_contents("{$_SERVER['DOCUMENT_ROOT']}./{$_POST['router']}.sh");
echo shell_exec($arrMode[$_POST['router']]);
}
$status0 = shell_exec($arrMode['status0']);
$status2 = shell_exec($arrMode['status2']);
?>
<meta http-equiv="refresh" content="10" >
note: I have just two channels
also the page refreshes every 10 seconds to update the status of the channels (buttons change colors and labels when status change) since I can control the channels status also by SMS or by a phone call (I installed asterisk on the router )
....
}
input.on{
background-color: #E40606;
border-color: #398439;
}
input.off{
background-color: #449d44;
border-color: #E40606;
}
note: I swapped red and green color of the buttons to better understand when the channel is on or off (red=on, green=off)
....
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input class="<?php if((int)($status0)==0) echo 'on'; else echo 'off';?>" type="submit" name="router" value="<?php if((int)($status0)==1) echo 'on'; else echo 'off';?> rele"><br>
<p>
<hr>
<p>
<input class="<?php if((int)($status2)==0) echo 'on'; else echo 'off';?>" type="submit" name="router" value="<?php if((int)($status2)==1) echo 'on'; else echo 'off';?> luce"><br>
<hr>
</form>
Note:
Luce (italian) = Light = LED spotlight for Motion
rele (italian) = relay = output channel
addendum:
change USER (u) and PASSWORD (p) to access the control page:
'u' => "d033e22ae348aeb5660fc2140aec35850c4da997",
'p' => "d033e22ae348aeb5660fc2140aec35850c4da997"
u= admin, p=admin
both need to be "sha1" encoded, you can find the online tools here:
(Last edited by pilovis on 12 May 2016, 13:27)
Netgear DGND3700V1 has 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
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:36)
just a note:
if you want to stream video from the remote location with you OpenWRT box, do not use mjpg-streamer.
I mean, if you want to check the remote location for just a few seconds, it's OK,
but when you start a realtime video streaming, after a few minutes that you are connected to see, mjpg-streamer crashes and the device "/dev/video0" disappears, the only way to recover it, it is to reboot the router or unplug and plug again the USB webcam.
Use Motion instead, it uses more CPU resources but it is stable and never crashes!
(Last edited by pilovis on 15 Sep 2016, 12:56)
this is my last (mad) creation:
OpenWRT Home Automation BOX
Features:
- 2 digital input channels (to get feedback from remote devices)
- 7 power output channels 1500 W max each (to switch ON and OFF remote devices)
- PBX Voip/GSM server (Asterisk 11 + GSM_dongle)
- remote control by phone by using DTMF tones (I created an IVR that says: "press 1 to switch on relay 1, etc")
- HD video streaming to monitor remote location (Motion)
- 2 ways SMS server (receive commands and/or send back alerts/notifications) (Gnokii)
- remote/local control by web page (PHP + uhttpd)
- local control by USB keypad (Triggerhappy)
- restore the channels status after a power failure/reboot (restore the last status ON/OFF just before the power loss)
Maximum power consumption = 15W, one single power supply 12v/2.5A (I keept the original netgear PS)
This BOX can be powered by solar cells and/or by a 12V rechargeable lead battery
To save some electrical power and heating, I removed the (useless) WiFi PCI internal card because it is not supported by Barrier Breaker sad , maybe Chaos Calmer supports it, but C.C. sucks, it is almost useless since there are to many packages missing, included most of the packages I used for this BOX mad
Notes: by having a GSM dongle (GSM calls and SMS), this box can work anywere, even in a place without any internet connection.
I used (cost):
my brain (free) smile
many sleepless nights (almost free)
Openwrt Barrier Breaker (free)
Netgear DGND3700V1 router (Ebay @ 50 Euro)
USB HD webcam (local store @ 30 Euro)
8 channels Relay Board (Ebay @ 10 Euro)
USB GSM dongle Huawei E169 (Ebay @ 15 Euro)
USB Keypad (local store @ 5 Euro)
USB Hub (local store @ 5 Euro)
Important note on Netgear DGND3700V1 and Barrier Breaker.
This router with its custom OpenWRT Barrier Breaker firmware has a very bad problem: during a reboot, invoked by a program or by the reboot command, the router may hangs forever, unfortunately it happens quite often and the only way to recover it, it is to do a power cycle.
The problem occurs during the shutdown process, just before the reboot, it seems that some process cannot be stopped correctly.
To avoid this problem during reboot cycle, you might use the following command to do an hard_reboot of the router:
/bin/echo b > /proc/sysrq-trigger
this is pretty much the same as pressing the reset button on a PC, no daemons will be shut down gracefully, no filesystem sync will occur (but we don't need it).
So, don't use anymore the "reboot" command (busybox) on this router, also disable watchcat and zram:
/etc/init.d/watchcat disable
/etc/init.d/zram disable
(Last edited by pilovis on 15 Sep 2016, 20:02)
see https://forum.openwrt.org/viewtopic.php … 70#p338370 for the instructions.
(Last edited by pilovis on 15 Sep 2016, 20:57)
just a note:
if you want to stream video from the remote location with you OpenWRT box, do not use mjpg-streamer.
I mean, if you want to check the remote location for just a few seconds, it's OK,
but when you start a realtime video streaming, after a few minutes that you are connected to see, mjpg-streamer crashes and the device "/dev/video0" disappears, the only way to recover it, it is to reboot the router or unplug and plug again the USB webcam.
Use Motion instead, it uses more CPU resources but it is stable and never crashes!
In case you want to use mjpg-streamer anyway, this is the script to check if the process is active, if it is not, the script restart mjpg-streamer:
#!/bin/sh
# check if the process "mjpg-streamer" is active
#
if ps w | grep -v grep | grep '/usr/bin/mjpg_streamer --input input_uvc.so --device /dev/video0 --fps 1 --resolution 1280x720 --output o' > /dev/null
then
# echo "OK"
/bin/sleep 1
else
# echo "KO"
/init.d/mjpg-streamer restart
fi
Notes:
change "--fps 1" with the frame per seconds value you are using, eg: --fps 8,
the same for "--resolution 1280x720"
then put the following line in "/etc/crontabs/root" to check the mjpg-streamer process every minute:
*/1 * * * * /bin/sh /root/mjpg-streamer_check.sh
(Last edited by pilovis on 20 Sep 2016, 14:30)
How to control values of the cam in mjpg-streamer and motion
The opkg version of mjpg-streamer has no control options for the camera. If you want to control exposure, brightness and other options you'll need to install uvcdynctrl.
By editing the cam values with this program I got big improvements in terms of sharpness and color fidelity
quick instructions:
install control program:
opkg install uvcdynctrl
test the program and check the list of webcam available commands:
/usr/bin/uvcdynctrl -c
copy cam internal values to a file:
/usr/bin/uvcdynctrl -W /etc/config/uvcdynctrl
edit file with cam values:
vi /etc/config/uvcdynctrl
example:
#V4L2/CTRL/0.0.2
APP{"libwebcam"}
# control data
#Brightness
ID{0x00980900};CHK{30:255:1:133}=VAL{133}
#Contrast
ID{0x00980901};CHK{0:10:1:5}=VAL{8}
#Saturation
ID{0x00980902};CHK{0:200:1:83}=VAL{120}
#White Balance Temperature, Auto
ID{0x0098090c};CHK{0:1:1:1}=VAL{1}
#Power Line Frequency
ID{0x00980918};CHK{0:2:1:2}=VAL{2}
#White Balance Temperature
ID{0x0098091a};CHK{2800:10000:1:4500}=VAL{4500}
#Sharpness
ID{0x0098091b};CHK{0:50:1:25}=VAL{45}
#Backlight Compensation
ID{0x0098091c};CHK{0:10:1:0}=VAL{0}
#Exposure, Auto
ID{0x009a0901};CHK{0:1:1:1}=VAL{3}
#Exposure (Absolute)
ID{0x009a0902};CHK{5:20000:1:156}=VAL{156}
#Pan (Absolute)
ID{0x009a0908};CHK{-201600:201600:3600:0}=VAL{201600}
#Tilt (Absolute)
ID{0x009a0909};CHK{-201600:201600:3600:0}=VAL{201600}
#Focus (absolute)
ID{0x009a090a};CHK{0:40:1:0}=VAL{3}
#Focus, Auto
ID{0x009a090c};CHK{0:1:1:0}=VAL{1}
#Zoom, Absolute
ID{0x009a090d};CHK{0:10:1:0}=VAL{1}
note: you need to change the value under braces {*}
the first two numbers in CHK{x:x:x:x} are in order the minimum and the maximum acceptable value you can use for each parameter
then to apply 'on-the-fly' the new values (no need to restart mjpg-streamer):
/usr/bin/uvcdynctrl -L /etc/config/uvcdynctrl
note: ignore errors!
add the above command to /etc/rc.local to load and apply the new cam values at reboot:
vi /etc/rc.local
#...
/usr/bin/uvcdynctrl -L /etc/config/uvcdynctrl
exit 0
(Last edited by pilovis on 14 Nov 2016, 17:31)
Just a quick update how to create a DDNS (Dynamic DNS) with Bind (server) and OpenWRT (client).
First of all you need to configure BIND on your server to accept dynamic updates from a remote client.
To configure BIND follow this guide:
http://www.foell.org/justin/diy-dynamic … nwrt-bind/
Important note:
your BIND server must be the authoritative DNS for the domain you want to manage,
see here: https://www.dnsknowledge.com/whatis/aut … me-server/
On your OpenWRT Router:
-- install bind-client package
opkg update
opkg install bind-client
-- copy the two generated files from BIND server (file.key and file.private) to your OpenWRT router (/root directory)
-- create the script to check for public IP changes and update your zone if IP has changed:
vi /root/check-ip.sh
#!/bin/bash
NOWIPADDR="/tmp/nowipaddr"
GETIPADDR="curl http://icanhazip.com"
IP=$(curl http://icanhazip.com)
if [ -f $NOWIPADDR ]
then
if [ `cat $NOWIPADDR` = `$GETIPADDR` ]
then
echo "IP NOT changed"
else
$GETIPADDR > $NOWIPADDR
echo "IP changed"
echo "server 222.222.222.222
zone domain.com.
update delete sub.domain.com. A
update add sub.domain.com. 86400 A $IP
show
send" | nsupdate -k /root/Ksub.domain.com.+157+30338.key -v
fi
else
curl $GETIPADDR >> $NOWIPADDR
fi
Notes:
change "222.222.222.222" with your BIND server static IP public address
change "domain.com" and "sub.domain.com" with your domain and your third
level domain name you want to update
change "/root/Ksub.domain.com.+157+30338.key" with the file name (.key) generated by your BIND server
-- give the right permissions to the script:
chmod 755 /root/check-ip.sh
-- generate a crontab with crontab -e command to launch the script every 5 minutes:
*/5 * * * * /bin/sh /root/check-ip.sh
-- insert the following two lines to "/etc/rc.local" file, right before the "exit 0" line:
/bin/touch /tmp/nowipaddr
/bin/sh /root/check-ip.sh
reboot the router ...
(Last edited by pilovis on 23 Oct 2017, 13:43)
Ciao Pilovis,secondo te con una alix 3d2 (audio e mic integrato) posso trasformarla in un client per Mumble?magari con cuffie/mic bluetooth
Posso scriverti in mail?
Grazie
The discussion might have continued from here.