An RGB LED for your RSPro
As I mentioned in my review, the Routerstation Pro only has a single user-programmable LED. However, it has 7 GPIO lines that can easily be attached to more LEDs. Read on for instructions and pictures.
I decided I wanted more LEDs so that I could have an easy notification of when there is a problem with my internet connection or tunnels. I did this on a WRT54GL using the white and orange LEDs behind the Linksys logo. You can easily script a blinking action that stops or changes color when your connection is down. However, the RSPro has only one user-programmable LED compared to the WRT’s 5 or so. However, there is a 7-pin GPIO header with a jumper block to select active low or high mode.
I already had an RGB LED, so once I figured out how to manually toggle the GPIO outputs, all I had to do was figure out how to wire it up. Use the RSPro page on either the OpenWRT wiki or the UBNT wiki for reference on the GPIO lines. I figured that the GPIO lines would act as a 3.3v source while the UART header could act as a ground. However, I learned that the LED in question used a common anode rather than a common cathode, which meant I would have to get creative. I instead used the 3.3v off the UART header and used some of the GPIO lines as the ground after setting them to “active low” mode. After that, it was simply a matter of tweaking resistances in order to get good color balance, since the different elements of the LED had different characteristics. This is difficult because you have to not only make each channel the same brightness when one of them is lit exclusively, but you also have to make the combination of the three look convincingly white.
Lastly, there was still the issue of fitting it in the box. I use the newer Netgate enclosure for the RSPro, which has quite a bit of room. However, there wasn’t a whole lot of room above the board, so the breadboard I used for the project would have to sit below the Routerstation. The breadboard was then covered in electrical tape to prevent contact with the board, and I had lines go to the LED, which stuck out of one of the SMA holes on the case.
Software
To be honest, I don’t remember all of what I had to install to get manual control over GPIO lines. This does not use the OpenWRT LED configuration. I think that ‘gpioctl’ had something to do with it, and maybe ‘kmod-leds-gpio’, although I doubt the latter since this bypasses the LED system. You can do something like this to set up the GPIO lines.
#!/bin/bash #Path to GPIO folder GPIOPATH="/sys/class/gpio" #Expose GPIO lines echo 0 > $GPIOPATH/export echo 1 > $GPIOPATH/export echo 3 > $GPIOPATH/export #Set lines to output mode echo out > $GPIOPATH/gpio0/direction echo out > $GPIOPATH/gpio1/direction echo out > $GPIOPATH/gpio3/direction #Set them to 0 initially echo 0 > $GPIOPATH/gpio0/value echo 0 > $GPIOPATH/gpio1/value echo 0 > $GPIOPATH/gpio3/value
A few things to note:
- Remember, GPIO 2 is the RF LED.
- Invert the values if you are using an active low line and 3.3v from elsewhere.
After this, you just have to ‘echo 0’ or ‘echo 1’ into the ‘value’ of the GPIO line to turn it on or off.
As shown in the videos, my script does two things: It flashes the LED blue-cyan under normal circumstances, with the speed dependent on system load average, and it flashes red if a connection problem is detected. Right now, the scripts are a hacked-together mess, so I’ll post them if I get them cleaned up.
Pictures and Videos
Videos coming soon, enjoy the pictures for now.