[arm-allstar] RGB LED RPI

Sam Eichold seichold at gmail.com
Sun Oct 8 13:36:29 EST 2017


Found it on my phone.

Take a look at the attached scripts / directions. You can also add another
entry to trigger the second relay when the radio is tx.



On Oct 8, 2017 1:32 PM, "Sam Eichold" <seichold at gmail.com> wrote:

> I actually have built this using a relay board and the gpio pins.
>
> I use it mainly for fan control, but I have the second relay indicating
> tx.
>
> I've been meaning to submit the details to the wider group... Will send
> tonight.
>
>
> Sam
>
> K4SOF
>
> On Oct 8, 2017 1:27 PM, Doug Crompton via arm-allstar <
> arm-allstar at hamvoip.org> wrote:
>
>> Tom,
>>
>>  You did not say what you want the LED to indicate but I suspect that the
>> node is transmitting and receiving?  There are no pins on the RPI that
>> indicate TX/RX status. TXD and RXD are serial port pins that send digital
>> data. All pins on the Pi are 3.3V max also.
>>
>> The PTT indication is available on the USB FOB. Most FOBS have an LED
>> indicating this. If not the PTT line could be used as a pull down for an
>> LED wired to +5V through an appropriate resistor.
>>
>> For RX the COS signal can be programmed to raise or lower an unused bit on
>> the FOB - see the txctcss howto on the hamvoip web page. You also could do
>> this with hardware and build a little circuitry to use the COS line to
>> turn
>> on the LED. This could need to be inverted depending on how your radio
>> uses
>> the COS line.
>>
>>
>> *73 Doug*
>>
>> *WA3DSP*
>>
>> *http://www.crompton.com/hamradio <http://www.crompton.com/hamradio>*
>>
>>
>>
>>
>> On Sun, Oct 8, 2017 at 2:15 PM, "TomXtal via arm-allstar" <
>> arm-allstar at hamvoip.org> wrote:
>>
>> > I have build a Allstar node with RPI 3 which works just fine. What I
>> would
>> > like to do is have a status LED using a RBG LED, I would like to know
>> which
>> > GPIO pins to use. I know i can use pin 2 or 4 for power no but do not
>> know
>> > which pins for TX and RX maybe pin 8 (TXD) and pin 10 (RXD). So I need
>> some
>> > advice.
>> >
>> > Tom
>> > _______________________________________________
>> >
>> > arm-allstar mailing list
>> > arm-allstar at hamvoip.org
>> > http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar
>> >
>> > Visit the BBB and RPi2/3 web page - http://hamvoip.org
>> >
>> _______________________________________________
>>
>> arm-allstar mailing list
>> arm-allstar at hamvoip.org
>> http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar
>>
>> Visit the BBB and RPi2/3 web page - http://hamvoip.org
>>
>
-------------- next part --------------
#!/bin/bash

#########################################################################################
#
# filename: app_rpt_fan.sh
#
# description: This file controls a PC fan attached to a relay board attached to a PI 3 using GPIO. 
# It starts up when PTT is detected,
# and will stay on for the time period specified in
# the TIMEAFTER variable after the PTT drops.
# If the PTT is triggered in the countdown period, the timer resets.
#
# original authors: The majority of this script (the state manager) was taken from
# the ID scripts by KC6HUR and WW4M.
#
# history:
# 2005-02-16 kd6hwc Initial creation (with help from other scripts)
# 2007-07-29 k6jwn Added new variable PTTON, fan won't come on until this timer reaches it's limit.
# 2012-01-28 k0kn Adapted script for app_rpt system
# 2014-08-24 kp4tr Modified script for DMK Engineering URI FOB
# 2017-08-23 k4SOF Modified script for PI 3 GPIO board realy (using relay CH 1)
#########################################################################################
#
# Modified from http://www.qsl.net/k0kn/txfan script by Kyle K0KN
# Additionally modified to remove refrences to URI and customize for PI relay board by Sam K4SOF
# using the GPIO relay board via GPIO pin 25 (wPI numbering scheme)
# and the functions+events stanza in rpt.conf
#
# This script and related configuration will allow you to use the built in GPIO pins on a PI 3 along
# with a realy board to control a fan. The following directions and script were modified from the great
# directions found here: http://latinovoip.net/allstar-and-the-gpio-fan-script-for-dmk-engineering-uri/
#
# The basic function is controled by a temp file that is created when the tx is keyed and deleted when it 
# is unkeyed. 
#
# In rpt.conf define in functions and events stanza
# Change 1999 to your rpt.conf configuration node number.
#
# First, Add an event entry in the node stanza: (in a default config  add it the end of the stanza ~line 354
#  ;event manage temp file for fan control
#  events=events1999

# [functions1999]
# 90=cmd,/etc/asterisk/local/write_gpio.sh 25 1 ; Turn off GPIO 25
# 91=cmd,/etc/asterisk/local/write_gpio.sh 25 0 ; Turn on GPIO 25
#
# [events1999]
# touch /tmp/RPT_TXKEYED1999 = s|t|RPT_TXKEYED
# rm -f /tmp/RPT_TXKEYED1999 = s|f|RPT_TXKEYED
#
# We will be putting a few scripts in the /etc/asterisk/local folder.
#
# First, Script to take command and translate to gpio output 
# Script name:  /etc/asterisk/local/write_gpio.sh
# 
#  #!/bin/bash
#  script name - write_gpio
#  gpio mode $1 out
#  gpio write $1 $2
# 
# Make it executable with a:
#  chmod +x /etc/asterisk/local/write_gpio.sh

# Next, add the following line to end of existing /etc/rc.local:
#  /etc/asterisk/local/run_app_rpt_fan.sh
#
# Next, create a script to /etc/asterisk/local/run_app_rpt_fan.sh and add this, using your own node number:
#
#  #!/bin/bash
#  killall -e app_rpt_fan.sh > /dev/null
#  /etc/asterisk/local/app_rpt_fan.sh 1999 > /dev/null &
#
# Make it executable with a:
#  chmod +x /etc/asterisk/local/run_app_rpt_fan.sh
#
# Next, copy the main fan shell script (this file) into /etc/asterisk/local/app_rpt_fan.sh
# Make main script (this file) executable with a:
#  chmod +x /etc/asterisk/local/app_rpt_fan.sh
#
##################################################################

#set -xv

if [[ $# -eq 0 ]];then
echo "Need a valid local Allstar node number to run fan script"
exit
fi

#this is set from events stanza to create or destroy this file
PTTSTATE="/tmp/RPT_TXKEYED$1"

#Your custom function defined in rpt.conf to turn URI FOB GPIO pin 1 on and off
FANON="/usr/bin/asterisk -rx \"rpt fun $1 *91\""
FANOFF="/usr/bin/asterisk -rx \"rpt fun $1 *90\""

# Define the period of time after the PTT drops to shut off the fan
TIMEAFTER=600

# Define the max PTT time before the fan is activated
PTTON=5

#### No changes needed after this line

# define variables
declare -i IDLETIMER
declare -i PTTKEY

# Start with state set to "Initial"

STATE="Initial"

while [ TRUE ]
do

case "$STATE" in

"Initial") # Wait for first keyup, then proceed to Countdown

echo -en "\r"`date ` "STATE = Initial\n"
sleep 1;
PTTKEY=0

while [ TRUE ]
do
echo -en "\rPTT Timer: $PTTKEY "
sleep 1;

# while PTT is silent (PTT=T)
if [ -f $PTTSTATE ] ; then
PTTKEY=$PTTKEY+1
fi

if ! [ -f $PTTSTATE ] ; then
PTTKEY=0
fi

if [ $PTTKEY -gt $PTTON ] ; then
break
fi
done
echo -en "\nPTT timer expired, activating fan"
eval $FANON
STATE="Countdown"
;;

"Countdown") # Count down period, if PTT is triggered, reset the timer.

echo -en "\n\n"`date ` "STATE = Countdown\n"
sleep 1
IDLETIMER=$TIMEAFTER

while [ TRUE ]
do
echo -en "\rFan powerdown timer: $IDLETIMER "
IDLETIMER=$IDLETIMER-1
sleep 1

if [ -f $PTTSTATE ]
then
IDLETIMER=$TIMEAFTER
fi

if [ $IDLETIMER = 0 ]
then
break
fi
done

echo -en "\nTimer expired, deactivating fan"
eval $FANOFF
STATE=Initial
;;

esac
done

echo -e "\n\nOops! - Not supposed to get to here"


More information about the arm-allstar mailing list