RX and TX indicator LEDs -- ASL and HamVoIP

Here lies some useful information about how to add LEDs to your Pi AllStar node so that it can indicate things. I wired mine up to indicate Transmit and Receive. But you can indicate just about anything. Additionally, if you are building a node radio setup, you can use this method to trigger PTT on your node radio.

How are Pi GPIO pins labelled?

The Pi GPIO naming scheme is needlessly confusing and very user-unfriendly.

There are fully three different ways to numerically address each GPIO pin. It's madness but this is where we are and you have pay careful attention how the pins are being referenced. Here are some diagrams that I stole from the internets that illustrate the madness.

So depending on what languages, libraries, etc. you are using (e.g. python, shell commands, C, and so forth), you should be mindul of which system is being used to address the pins.

Mini rant over.

Setup

  1. Install wiringPi

               sudo apt-get update
               sudo apt-get install wiringpi
            


  2. Hook up some LEDs!

    You want to use a resistor on one of the legs, either positive lead or ground lead, to limit the current going through your diode circuit. Otherwise you stand a chance of blowing out the circuitry.

    I've seen some pages claim 100 ohm is enough... I've seen others tell you 470 ohms... I've observed the general consensus seems to be 330 ohm. I used 220 ohm only because those were the first resistors I grabbed; nothing has thus far blown up. The LEDs through 220 ohm seem a little brighter than they should be so perhpasI should have used 330 ohm. In any case, the absolutely prudent thing to do would be to find the specs for your LEDs and do the calculations -- although there is all sorts of conflicting information on the interwebs about that.

  3. Write some code

    Anything that runs from a command line will work. You like Python? Write in Python? Bash? Perl? Compile something in C? Command line gpio utility? Yes.

    I wrote and compiled some very quick and dirty C code. The following is code blink.c that blinks two LEDs ON, waits half a second, and turns them OFF for power-on test purposes. This code has everything so one can easily adapt it to turn either LED pin on or off.

              #include <wiringPi.h>
    
              /* compile with gcc -Wall -o blink blink.c -lwiringPi */
              
              int main (void)
              {
                wiringPiSetup () ;
                pinMode (4, OUTPUT) ;
                pinMode (5, OUTPUT) ;
                for (;;)
                {
                  digitalWrite (4, HIGH);
                  digitalWrite (5, HIGH);
                  delay (500);
                  digitalWrite (4,  LOW);
                  digitalWrite (5,  LOW);
                  delay (500);
                }
                return 0 ;
              }
            


  4. Permissions check

    You might have to add yourself -- your username or the username of whoever is running asterisk -- to the gpio group in /etc/group

  5. Add configuration to rpt.conf

    Create an [events] stanza or add it to an existing [events] stanza.

            [events]
            
            /var/local/sbin/gpio-wpi4-high = s|t|RPT_TXKEYED
            /var/local/sbin/gpio-wpi4-low = s|f|RPT_TXKEYED
            /var/local/sbin/gpio-wpi5-high = s|t|RPT_RXKEYED
            /var/local/sbin/gpio-wpi5-low = s|f|RPT_RXKEYED
    
            ; this is the last line in my rpt.conf
            #includeifexists custom/rpt.conf
            

Moral Relativism

A word about what is meant by TX and RX. In this Allstar paradigm, TX means that audio is coming in from the internet and then being transmitted by your node radio. For example, given the code above, when there is activity on the internet link, the TXKEYED on GPIO (WiringPi) pin 4 goes high and lights up, and your node radio transmits. When you talk into your radio, the node radio receives the audio, RXKEYED on GPIO (WiringPi) 5 goes high and lights up, and your node sends that through the internet.

Therefore, in my writeup, I have reversed the logic because I am operating largely RFless nodes and thus no node radio. My node, for all intents and purposes functions like the radio, so this makes more sense to me.

More the LEDs

Instead of or in addition to operating LEDs this way, you can add duplicate lines to your rpt.conf to have the TX event trigger a relay or transistor circuit to assert PTT on an actual radio if you are using a typical node radio setup.

Fun stuff

video

References