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.

How are Pi GPIO pins labelled? (and, rhetorically, whhyyyyyyyyyyy?)

The Pi GPIO naming scheme is very confusing and 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 attentiong. 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; I'm hoping nothing blows up. The LEDs through 220 ohm seem a little brighter than they should be so I should have used 330 ohm. In any case, the prudent thing to do would be to find the specs for your LEDs and do the calculations ( how much current can the Pi pins supply safely??)

  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-4-high = s|t|RPT_TXKEYED
            /var/local/sbin/gpio-4-low = s|f|RPT_TXKEYED
            /var/local/sbin/gpio-5-high = s|t|RPT_RXKEYED
            /var/local/sbin/gpio-5-low = s|f|RPT_RXKEYED
    
            ; this is the last line in my rpt.conf
            #includeifexists custom/rpt.conf
            


    A word about what is meant by TX and RX. In this context, 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 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 5 goes high and lights up, and your node sends that through the internet.

Fun stuff

video

References