# Raspberry Pi3 GPIO tx/rx status led

**URL:** <https://community.allstarlink.org/t/raspberry-pi3-gpio-tx-rx-status-led/15625>\
**Category:** AllStarLink\
**Created:** [October 19, 2019, 1:48pm UTC](https://community.allstarlink.org/t/raspberry-pi3-gpio-tx-rx-status-led/15625 "2019-10-19T13:48:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bretteld74](https://community.allstarlink.org/letter_avatar_proxy/v4/letter/b/b5ac83/32.png) [@Bretteld74](https://community.allstarlink.org/u/Bretteld74)\
**Post date:** [October 19, 2019, 1:48pm UTC](https://community.allstarlink.org/t/raspberry-pi3-gpio-tx-rx-status-led/15625/1 "2019-10-19T13:48:25Z")

</div>

Hello All I have a AllStar node using a raspberry pi 3b and was looking at using the GPIO pins on the RPi to send a tx and rx status to an rgb led. Any help would be great i have tried several ways but no success.

---

<div class="post-metadata">

**Author:** ![WD6AWP](https://community.allstarlink.org/user_avatar/community.allstarlink.org/wd6awp/32/5_2.png) [@WD6AWP](https://community.allstarlink.org/u/WD6AWP)\
**Post date:** [October 20, 2019, 2:15pm UTC](https://community.allstarlink.org/t/raspberry-pi3-gpio-tx-rx-status-led/15625/2 "2019-10-20T14:15:36Z")

</div>

Hi Brett,

Welcome aboard our new community site.

> [@Bretteld74](#):
>
> looking at using the GPIO pins on the RPi to send a tx and rx status to an rgb led

Take a look at the [app\_rpt management system](https://wiki.allstarlink.org/wiki/Event_Management). Have it call a script that turns your LEDs on and off.

---

<div class="post-metadata">

**Author:** ![Bretteld74](https://community.allstarlink.org/letter_avatar_proxy/v4/letter/b/b5ac83/32.png) [@Bretteld74](https://community.allstarlink.org/u/Bretteld74)\
**Post date:** [October 24, 2019, 12:41pm UTC](https://community.allstarlink.org/t/raspberry-pi3-gpio-tx-rx-status-led/15625/3 "2019-10-24T12:41:31Z")

</div>

For anyone looking at using Raspberry pi Gpio pins for Led status this what i did to get it to work.

Go to and open using winSCP  
/etc/rc.local  
under /usr/local/etc/rc.allstar  
type in /etc/asterisk/local/write\_gpio.sh (makes gpio pins go to output upon startup)  
then save

then type nano /etc/asterisk/local/write\_gpio.sh  
then type the following script

#!/bin/bash  
#script name - write\_gpio  
gpio mode 7 out ; makes gpio 7 pin 7 an output  
gpio mode 2 out ; makes gpio 2 pin 13 an output

save  
make executable by chmod +x write\_gpio.sh  
open rpt.conf in asterisk folder and under events ad the following  
sudo /usr/local/sbin/7high.sh = s|t|RPT\_TXKEYED  
sudo /usr/local/sbin/7low.sh = s|f|RPT\_TXKEYED  
sudo /usr/local/sbin/2high.sh = s|t|RPT\_RXKEYED  
sudo /usr/local/sbin/2low.sh = s|f|RPT\_RXKEYED

save  
under /usr/local/sbin/  
create 4 scripts  
7high.sh inside each script put #!/bin/bash next line put gpio write 7 1  
7low.sh inside each script put #!/bin/bash next line put gpio write 7 0  
2high.sh inside each script put #!/bin/bash next line put gpio write 2 1  
2low.sh inside each script put #!/bin/bash next line put gpio write 2 0

save each one and make them executable using the chmod +x command

then reboot  
and enjoy.

---

<div class="post-metadata">

**Author:** ![WD6AWP](https://community.allstarlink.org/user_avatar/community.allstarlink.org/wd6awp/32/5_2.png) [@WD6AWP](https://community.allstarlink.org/u/WD6AWP)\
**Post date:** [October 26, 2019, 4:37am UTC](https://community.allstarlink.org/t/raspberry-pi3-gpio-tx-rx-status-led/15625/4 "2019-10-26T04:37:39Z")

</div>

Woohoo! 👏 🎉 🎊 Congratulations on using the app\_rpt Event Management system. As far as I know, you are the first. That’s awesome!

---

<div class="post-metadata">

**Author:** ![Chuck\_Henderson](https://community.allstarlink.org/letter_avatar_proxy/v4/letter/c/ba9def/32.png) [@Chuck\_Henderson](https://community.allstarlink.org/u/Chuck_Henderson)\
**Post date:** [October 26, 2019, 7:33am UTC](https://community.allstarlink.org/t/raspberry-pi3-gpio-tx-rx-status-led/15625/5 "2019-10-26T07:33:35Z")

</div>

I for many years have been using what seems like a complex event system, but it is really simple and works great and does exactly what I wanted it to do.

It lets the person who timedout the repeater and others, know when a timed out repeater has reset from a local timeout and it also prevents weather announcements from interrupting a QSO. We, 27383, are almost always permalinked with 27426. If the permalink is down the events script does cause error messages in the log, but everything still works fine. YMMV. If someone knows how to avoid the link down errorlog messages, please let me know.

Chuck

> **···**
>
> * * *
> 
> In the weather script, /usr/local/sbin/wx\_condition.sh, just before “function round ()” I add a few lines like this
> 
> if [[-f /tmp/key27383]]  
> then {  
> exit  
> } fi  
> if [[-f /tmp/key27426]]  
> then {  
> exit  
> } fi  
> if [[-f /tmp/qsoactive]]  
> then {  
> exit  
> } fi
> 
> * * *
> 
> Then I create or edit all of the following files with the content just below the filename added to the appropriate place in the file.
> 
> * * *
> 
> /etc/asterisk/rpt.conf
> 
> [events]
> 
> TEMPVARAA = v|e|${RPT\_ALINKS} =~ “”,27426[TRC]K""  
> /usr/local/bin/ericunkey.sh = s|f|TEMPVARAA  
> /usr/local/bin/erickey.sh = s|t|TEMPVARAA  
> /usr/local/bin/weunkey.sh = s|f|RPT\_RXKEYED  
> /usr/local/bin/wekey.sh = s|t|RPT\_RXKEYED  
> /usr/local/bin/wetxunkey.sh = s|f|RPT\_TXKEYED  
> /usr/local/bin/wetxkey.sh = s|t|RPT\_TXKEYED
> 
> * * *
> 
> I put all of my scripts in /usr/local/bin/
> 
> * * *
> 
> ericunkey.sh
> 
> #!/bin/sh  
> rm -f /tmp/key27426
> 
> * * *
> 
> erickey.sh
> 
> #!/bin/sh  
> touch /tmp/key27426
> 
> * * *
> 
> wekey.sh
> 
> #!/bin/sh  
> touch /tmp/key27383  
> /usr/local/bin/[qsoactive.pl](http://qsoactive.pl)
> 
> * * *
> 
> weunkey.sh
> 
> #!/bin/sh  
> rm -f /tmp/key27383  
> if [! -f /tmp/txkey27383]  
> then {  
> /usr/bin/asterisk -rx “rpt localplay 27383 ha/reset”  
> } fi
> 
> * * *
> 
> wetxkey.sh
> 
> #!/bin/sh  
> touch /tmp/txkey27383
> 
> * * *
> 
> wetxunkey.sh
> 
> #!/bin/sh  
> rm -f /tmp/txkey27383
> 
> * * *
> 
> /usr/local/bin/[qsoactive.pl](http://qsoactive.pl)
> 
> #!/usr/bin/perl  
> $now = time();  
> open($fh, “\>”, “/tmp/qsoactive”)  
> or die “Can’t open \> /tmp/qsoactive: $!”;  
> print $fh “$now\n”;  
> close($fh);  
> $then = $now + 180;  
> open($fh, “\>”, “/tmp/qsoexpire”)  
> or die “Can’t open \> /tmp/qsoexpire: $!”;  
> print $fh “$then\n”;  
> close($fh);
> 
> * * *
> 
> crontab -e
> 
> \*/2 \* \* \* \* /usr/local/bin/[qsoexpired.pl](http://qsoexpired.pl)
> 
> 0 6-22/2 \* \* \* /usr/local/sbin/wx\_condition.sh KBMI 27383
> 
> * * *
> 
> /usr/local/bin/[qsoexpired.pl](http://qsoexpired.pl)
> 
> #!/usr/bin/perl  
> use PortLocker;  
> my $port = 47262;  
> my $locker = new PortLocker;  
> if(! $locker-\>lock())  
> {  
> exit;  
> #— failed, port already locked  
> }  
> $now = time();  
> $then = $now + 10;  
> $qsoexpired = $then;  
> while($qsoexpired \>= $now) {  
> sleep 17;  
> $qsoexpired = 0;  
> open($fh, “\<”, “/tmp/qsoexpire”)  
> or die “Can’t open \< /tmp/qsoexpire: $!”;  
> $qsoexpired = readline($fh);  
> close($fh);  
> $now = time();  
> }  
> unlink “/tmp/qsoactive”;
> 
> $locker-\>unlock();

---

<div class="post-metadata">

**Author:** ![WD6AWP](https://community.allstarlink.org/user_avatar/community.allstarlink.org/wd6awp/32/5_2.png) [@WD6AWP](https://community.allstarlink.org/u/WD6AWP)\
**Post date:** [October 18, 2022, 5:59pm UTC](https://community.allstarlink.org/t/raspberry-pi3-gpio-tx-rx-status-led/15625/6 "2022-10-18T17:59:48Z")

</div>

Split this topic on October 18, 2022, 5:59pm UTC

2 posts were split to a new topic: [Winscp as root user](https://community.allstarlink.org/t/winscp-as-root-user/19652)
