I’m setting up my first Volumio project based on Raspberry Pi 5 and have a question: my goal is to add a few LEDs to the front panel for signaling purposes. Power is straightforward, and I was also able to map the Raspberry Pi’s Act LED to an external one (using dtparam in userconfig.txt), and it works fine.
However, I also need something to signal whether I have a connection to Wi-Fi or even to the network. Here’s my question: How can I achieve this?
I reviewed plugins and found some for controlling GPIO, but they seem to be for switches, not outputs. Is there something ready to work for my needs?
I also found similar topics with solutions based on bash scripts. For example, this one: https://forums.raspberrypi.com/viewtopic.php?t=96453
However, it seems that my Volumio setup is unable to configure GPIO from the script level. When I try:
with the rPi5 addressing GPIO has completely changed.
There is one plugin to control leds called GPIO Control, however it doesn’t have Network functionality.
I found GPIO Control (only buttons, no outputs) and smaller GPIO Buttons (only few buttons, also no outputs).Script based idea seems to be ok, but how to make gpio working from bash level.
I have tried to install wiringpi, but it also doesn’t work.
Ok, my fault, I was too fast with checking. But as you wrote, it doesn’t support such functionality like network availability [quite obvious anyway, should be added]
Maybe I’ll write it different: it should be obvious. Clear visual indication if there is a network available or not. Should be useful, isn’t it? Ok, I’ll write in that topic.
Uuuupsss… So maybe any “free” output port that can be operated via a script? I’m asking because I’m currently polishing my first Volumio device, and my idea was to add some LED indicators to show simple things like power or RPi activity. These were simple to set up, but then I tried to add a “WiFi on” LED and got stuck here. I have no idea how to control GPIO output via a script in Volumio.
Moved your last posting back to here, to keep pollution out of the GPIO Control plugin.
In bash you could try this:
sudo apt-get update && sudo apt-get install gpiod
cd ~
mkdir scripts && cd scripts
nano network.sh
This example uses gpio9 on a rpi5. Copy and paste content.
#!/bin/bash
GPIO=9
while true;
do
ping -c 2 www.google.com > /dev/null
if [ $? != 0 ]
then
echo "Your site seems to be down"
gpioset gpiochip0 ${GPIO}=0
else
echo "Your Site is up"
gpioset gpiochip0 ${GPIO}=1
fi
sleep 5
done
CTRL+0 => Enter => CTRL+x chmod 777 network.sh
Check it:
volumio@rpi5-ws1280:~/scripts$ gpioget gpiochip0 9
0
volumio@rpi5-ws1280:~/scripts$ bash network.sh
Your Site is up
volumio@rpi5-ws1280:~/scripts$ gpioget gpiochip0 9
1
volumio@rpi5-ws1280:~/scripts$
First of all - thanks, it gives a hope. Nevertheless, it doesn’t work in my case. Script as such is ok, gives answer, but GPIO state is still down:
volumio@volumio:~$ cat network_status.sh
GPIO=16
while true;
do
ping -c 2 www.google.com > /dev/null
if [ $? != 0 ]
then
echo "Your site seems to be down"
gpioset gpiochip0 ${GPIO}=0
else
echo "Your Site is up"
gpioset gpiochip0 ${GPIO}=1
fi
sleep 5
done
volumio@volumio:~$ gpioget gpiochip0 16
0
volumio@volumio:~$ bash network_status.sh
Your Site is up
Your Site is up
Your Site is up
^C
volumio@volumio:~$ gpioget gpiochip0 16
0
I tested 23, your 9 and situation looks the same. Additionally I tried to read status of GPIO26, where I have mapped Act LED, so this GPIO is really busy: in this case I have clear answer:
And you have also Rpi 5, right? I found in several places warning that RPi has different chipset for GPIO and it works different than RPi 4, maybe here is a difference? Other hw revision or maybe any software update?
[edit] It seems I reached daily limit of post for new user as me and can’t add next today, so here: problem solved, issue was connected to previous tris with raspi-gpio. After removing both, cleaning atp and installing again gpiod, everything started to work fine.
Thanks for help!
Not sure what the ask is, but you could run something like this to detect a link beat.
In this case you don’t need to rely on a host. And you can check both wlan as eth.
#!/bin/bash
GPIOA=13
GPIOB=19
GPIOC=26
gpioset gpiochip0 ${GPIOA}=0
gpioset gpiochip0 ${GPIOB}=0
gpioset gpiochip0 ${GPIOC}=0
while true;
do
eth0=$(/usr/sbin/ifplugstatus | grep "eth0: link beat detected")
wlan0=$(/usr/sbin/ifplugstatus | grep "wlan0: link beat detected")
if [ "$eth0" ] ; then
echo "eth0 yes"
gpioset gpiochip0 ${GPIOA}=1
else
echo "eth0 no"
gpioset gpiochip0 ${GPIOA}=0
fi
if [ "$wlan0" ] ; then
echo "wlan0 yes"
gpioset gpiochip0 ${GPIOB}=1
else
echo "wlan0 no"
gpioset gpiochip0 ${GPIOB}=0
fi
sleep 5
done