RPi Busy Visualizer
This instructables show how to use NeoPixel LED ring visualize RPi busy level.
Supplies
How Does It Works?
Long Time ago, computer have 2 LED indicators on the computer case. In most case these 2 LEDs are reside near the power button, they are power LED and HDD LED. Power LED represent the computer is it turned on; HDD LED represent the hard disk IO activity. Form the name of the OS name at that time, DOS (Disk Operating System), we know the OS activity mainly related to disk operation. So the HDD LED blinking frequency and interval can represent the computer busy level.
One LED indicator is a little bit boring. The above "VIA" case is designed at 2005, the "Saturn ring" hide 24 blue LED behind. The light rotate base on the HDD LED as a clock signal. So when the computer busy, the ring light will turn much faster.
Nowadays, the computer RAM become much bigger and many OS cached commonly use files in memory. And also SSD substantially reduce the time of disk IO, so the HDD LED may not represent the computer busy status now. Many computer case even removed the HDD LED.
CPU loading should more representable as computer busy status. Raspberry Pi is a hackable computer, it can be configured to output CPU activity signal to GPIO. We can utilize this signal and an LED ring to visualize the CPU loading.
Ref.:
Hardware Preparation
Tiny MCU / Arduino Dev Board
Any FastLED supported MCU or Arduino dev board is ok. I have some Digispark in hand so I use it. If you have ATTINY45-20SUR in hand, it can fit to hide behind the NeoPixel ring board.
NeoPixel LED Ring Board
The ring Board have various numbers of NeoPixel LED, any numbers is ok. I have a 12 LEDs ring board in hand so I use it.
Others
Some wires, 3 female pin headers and the RPi you are using.
Soldering Work
Here are the connection summary:
DigiSpark ========= 5V -> RPi Pin Header 5V, LED Ring VCC GND -> RPi Pin Header GND, LED Ring GND PB0 -> RPi Pin Header ACT Signal (will connect to RPi GPIO 4) PB5 -> LED Ring Data In
Software Preparation
Arduino IDE
Please download and install Arduino IDE if not yet:
https://www.arduino.cc/en/software
Digispark
If using Digispark, please following the getting started steps to install the software if not yet:
http://digistump.com/wiki/digispark
FastLED Library
Search "FastLED" in Arduino IDE Library Manager and install it if not yet.
Program
Copy and paste below program to Arduino IDE new project, save and press upload:
#include <FastLED.h> #define SIGNAL_PIN 0 #define LED_PIN 5 #define NUM_LEDS 12 // size of LED ring #define BRIGHTNESS 8 // max is 255 but it will draw too much current #define LED_TYPE WS2812 #define COLOR_ORDER GRB #define SIGNAL_CONSUME_SIZE 512 // smaller will faster CRGB leds[NUM_LEDS]; void setup() { FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.setBrightness( BRIGHTNESS ); pinMode(SIGNAL_PIN, INPUT_PULLUP); } static uint8_t colorIndex = 0; static uint16_t signalCount = 0; void loop() { // accumulate ACT signal if(digitalRead(SIGNAL_PIN) == LOW) { signalCount++; } // rotate colors if (signalCount > SIGNAL_CONSUME_SIZE) { signalCount -= SIGNAL_CONSUME_SIZE; for( int i = 0; i < NUM_LEDS; ++i) { leds[i] = ColorFromPalette( RainbowColors_p, colorIndex++, 255, LINEARBLEND); colorIndex += (256 / NUM_LEDS); } FastLED.show(); } }
Connect to RPi
Here are the connection summary:
Pin Header 5V -> RPi 5V Pin Header GND -> RPi GND Pin Header ACT Signal -> RPi GPIO 4
Note: ACT Signal can map to any GPIO. GPIO 4 is the nearest GPIO that not yet assign any default purpose, so I selected GPIO 4.
Edit RPi Boot File
In RPi, run: (or replace vi to nano if your are more familiar with nano)
sudo vi /boot/config.txt
Append follow 2 lines:
dtoverlay=pi3-act-led,gpio=4 dtparam=act_led_trigger=cpu
Ref.:
https://www.raspberrypi.org/forums/viewtopic.php?t...
Enjoy!
Now you have a fancy way to visualize the busy level of your RPi.