Raspberry Pi 2 DIY LED LAN device counter

Do you know how many devices are on your local network? That is what we where wondering at our hackerspace HackBergen.

Yes, there are available programs and Apps to scan your network, but we can also scan with the Raspberry Pi (RPi) and show the result on a set of 7-segment displays.

These look cool, retro, are cheap and can be seen from a distance for you to have a general idea of how many devices are currently operating on your local network in these IoT times.

This build uses 3 modules of 7-segment common Anode LED displays that are controlled by an Atmega328. We use 3 because normal home LANs are C nets with a maximum of 256 devices and I had 3 of these nice 7-segment displays lying around. 🙂

The (AVR Atmega) 328 is loaded with the Arduino bootloader on an Arduino Uno 28pin AVR and then programmed with the Arduino 1.0.1 IDE through the Raspberry Pi on board serial port. The software is the firmware that Sparkfun uses on their serial backpack, but we have to modify a couple of lines since they use a 32 pin SMD 328 instead of the normal 28pin DIP version from the UNO.

By using an 328 for this, we do not need more than the serial port's 2 pins to control the display, and all multiplexing and buffering is done by the 328. No need for a program to do the multiplexing of the 7-seg displays and be problematic with irregular timing. We can also use the built in i2c bus to control it if we want to.

Using the serial port makes it very easy to display 7-seg chars on the display, remaining there until we update it again. This is great for piping information from scripts, and we do not need a program running constantly as a daemon.

You could of course buy a single 4 digit display from SparkFun ready-made and connect it to your Linux box or your RPi, losing all the DIY fun. That is totally up to you. 🙂Raspberry Pi 2 DIY LED LAN device counter

Step 1: What hardware do we need?

  • Soldering Iron with de-soldering gadgets
  • Multimeter with continuity tester
  • Wire
  • Perfboard
  • Lupe or magnifying glass to check the soldering
  • Sharp or X-acto knife
  • Arduino Uno
  • 3 pcs common Anode 7-segment display
  • Atmega AVR 328 DIP 28pin IC
  • Sockets
    • These are optional, but makes it easier to sneak wires behind the ICs
  • Resistors.
    • I used a 8 DIP 180ohm network for the segments as I find these convenient for things like this.
    • 220 ohm for driving the base of the transistors
  • NPN transistors. We used the 2n2222.
  • Raspberry Pi B, B+ or 2.
  • Ribbon cable – 40 pins or 26. We could use 10pin but that might ruin the RPis header.
  • Header connector
  • Breadboards. Optional as you can just reflash the bootloader on the UNO, but we did use the UNO to program the 328 on a breadboard. It is only done once.


Step 2:

What is connected to the 328 on our build:

  1. 10K resistor +3.3V / Switch GND
  2. RPi TXD pin 8
  3. RPi RXD pin 10
  4. LED dp -> pin 8 DIP resistor
  5. LED seg 3 transistor base resistor
  6. NC
  7. +3.3V
  8. GND
  9. NC
  10. NC
  11. LED g -> pin 7 DIP resistor
  12. LED c -> pin 3 DIP resistor
  13. LED f -> pin 6 DIP resistor
  14. LED a -> pin 1 DIP resistor
  15. LED e -> pin 5 DIP resistor
  16. NC
  17. NC
  18. NC
  19. NC
  20. +3.3V
  21. +3.3V
  22. GND
  23. LED b -> pin 2 DIP resistor
  24. LED d -> pin 4 DIP resistor
  25. LED seg 1 transistor base resistor
  26. LED seg 2 transistor base resistor
  27. RPi SCL pin 5 (optional)
  28. RPi SDA pin 3 (optional)

Original Schematics this is based on: Original 32 pin AVR schematics

Step 3: Cut out a piece of perfboard and start soldering

Decide on a size you want by placing your components on the perfboard and cut it out with a knife or saw.

I have a Olfa plastic cutter I really love for things like this, but a normal sharp knife works fine.

Step 4: Install 328 bootloade

There are a lot of great guides on how to program your Atmega 328 for simple use without external crystal 8Mhz use:


Install Arduino IDE on the RPi so we can burn bootloader with the UNO:

  • sudo apt-get install arduino (This installs arduino 1.0.1)

Install 8Mhz breadboard arduino ref: http://www.arduino.cc/en/Tutorial/ArduinoToBreadb…

  • mkdir -p sketchbook/hardware
  • cd sketchbook/hardware
  • unzip /home/pi/Breadboard1-0-x.zip
  • arduino
    • check for and select tools->board-> ATmega328 on a breadboard (8 MHz internal clock)
  • Make Link to serialport for arduino to discover after reboot
    • sudo nano /etc/init.d/link_serial
      • #!/bin/bash
      • ln -s /dev/ttyAMA0 /dev/ttyS1
  • sudo chmod 755 /etc/init.d/link_serial
  • sudo update-rc.d link_serial defaults
  • sudo service link_serial start
  • check serial port link, to see if it exists
    • ls -l /dev/ttyS1Raspberry Pi 2 DIY LED LAN device counter schematic
  • run arduino IDE
    • select tools->board->ATmega328 on a breadboard (8 MHz internal clock)
    • Select tools->serial port->/dev/ttyS1
    • Select tools->Burn Bootloader
    • remember to push the reset button on your new board when compiling, right before upload
    • You get “Done uploading” when OK or “problem uploading to board” if you wait too long. Just try again until you get it.

Step 5: Download and install firmware for Arduino IDE to be able to compile

We downloaded the firmware onto Rpi using git, but use your personal favorite:

Sparkfun firmware

This software relies on the 7-segment software, that we also must download:


I did not get the sketchbook/hardware directory to work with sevseg, so I unpacked it into

/usr/share/arduino/libraries as root.


For more detail: Raspberry Pi 2 DIY LED LAN device counter

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation and engineering. My writing style is clear and simple, and I am skilled in using infographics and diagrams. I am a great researcher and am able to present information in a well-organized and logical manner.

Follow Us:
Scroll to Top