3 ms·
If possible, I'd recommend getting an OpenWRT wireless router where the GPIO (general purpose input/output) and UART pins are broken out. You can use that to co
by minhmeoke 4y ago
If possible, I'd recommend getting an OpenWRT wireless router where the GPIO (general purpose input/output) and UART pins are broken out. You can use that to control a relay and turn devices on/off from just the shell (eg: deploy the routers in pairs, and if one of them goes down, you can power cycle it using the other device). The UART port lets you access serial data devices (possibly through a 3.3V to 12V level converter) using Picocom.
For example:
1 Channel Relay Module with Optocoupler Isolation ~$4
https://www.aliexpress.com/item/2251832713449142.html https://www.aliexpress.com/item/2251832713449142.html
GL-MT300N-V2 OpenWRT router ~$27
https://store.gl-inet.com/products/usa-only-mango-gl-mt300n-v2 https://store.gl-inet.com/products/usa-only-mango-gl-mt300n-...
GL-MT300N-V2 OpenWRT Specs
https://openwrt.org/toh/gl.inet/gl-mt300n_v2 https://openwrt.org/toh/gl.inet/gl-mt300n_v2
- UART pins
- GPIO pins available (requires soldering)
- 1x USB 2.0
Example of toggling GPIO44 10 times, then leaving it on:
let GPIO_STATE=0
for i in $(seq 10)
do
echo $GPIO_STATE > /sys/devices/virtual/gpio/gpio44/value
# Toggle GPIO_STATE variable between 0 and 1 via XOR
((GPIO_STATE ^= 1))
sleep 5 # sleep for 5 seconds
done
# Enable GPIO44 at the end
echo 1 > /sys/devices/virtual/gpio/gpio44/value
https://openwrt.org/docs/techref/initscripts https://openwrt.org/docs/techref/initscripts
- is_true 4y agoThanks, unfortunately I have to work with a couple of old routers