Monitoring network and internet speeds can be a major concern, especially in the case of LAN parties or video streaming. Modern Operating Systems provide utilities to track all the bits and bytes that pass over a network connection, but typically these tools lack obvious visualization. That’s where the Internet Speedometer can help. Using a BeagleBone Black and the power of its two Programable Realtime Units (PRUs), the Internet Speedometer will not only test download times, but also output the speed results visually to the tricolor LED strip.

But what are PRUs and why use them? PRUs are quite possibly the coolest feature of the BeagleBone Black, and one that sets it apart from other single board computers. They function much like microcontrollers; however, the two PRU cores on the BeagleBone Black operate at 200mhz with instructions executing on them at a fixed time of 5NS. That’s fast! What’s more is this speed does not come at a cost to the main processor’s load. Applications run in Linux will not take a performance hit even if there is high PRU activity. The two cores are not completely isolated and can share data between themselves and the CPU making interoperation possible. Programming of the cores is done using assembler in Linux and the execution of code is started by the main CPU. And this sharing of data and signaling features enable clever developers to offload work from the main processor and parallelize their applications. The result is a BeagleBone Black can perform high speed I/O with no performance hit to user experience — other boards simply don’t have this combination.

M41_WP_Speed-7

NOTE: Recently the BeagleBone Black switched Linux distributions from Ångström to Debian, and to anticipate this the Internet Speedometer uses Debian. If your BeagleBone Black is not a Rev C. or is not running Debian, consult our guides for Installing Debian on the BeagleBone Black (for OSX and Windows users).

Steps

Step #1: Programable Real-time Units

PrevNext
Internet SpeedometerInternet SpeedometerInternet Speedometer
  • The tricolor LED strip from RadioShack comes with support files including example Arduino code and data sheets for the Integrated Circuit controlling the LED segments.
  • Though the example code is only for Arduino, the data sheets contain necessary timing waveform information for the tricolor LED strip and it was possible to write a custom BeagleBone PRU driver for an LED strip.
  • In order to run this custom driver, however, the PRUs need to be accessible to Linux. To do this it is necessary to install and configure a library called PyPRUSS, which handles access to the PRU on the BeagleBone Black and is not preinstalled.

Step #2: Connect the BeagleBone Black

PrevNext
Internet SpeedometerInternet SpeedometerInternet Speedometer
  • Plug an ethernet cable into the BeagleBone Black and then power the board on by connecting a Mini-USB cable to the BeagleBone Black and your laptop or computer.
  • Login using SSH to the BeagleBone Black as the root user. ssh [email protected]
  • At the password prompt enter: root
  • Note: Windows users can use an SSH program such as PuTTY.

Step #3: Install PyPRUSS

PrevNext
Internet SpeedometerInternet SpeedometerInternet SpeedometerInternet Speedometer
  • PyPRUSS is available prepackaged for Ångström, but not for Debian. This means downloading and configuration is necessary to get everything running smoothly.
  • Login to the BeagleBone Black either over SSH or by attaching a monitor and keyboard.
  • On the command line clone the git repository of PyPRUSS by typing the following and hitting return: git clone https://bitbucket.org/intelligentagent/pypruss.git
  • Change the working directory to the newly cloned PyPRUSS directory: cd pypruss
  • Execute the Python setup script, setup.py: python setup.py install
  • Then export the library path: export LD_LIBRARY_PATH=/usr/local/lib
  • And finally, load the module uio_pruss: modprobe uio_pruss
  • Note: If you're experiencing any issues with this step, consult Step 1 of PyPRUSS repository page.

Step #4: Install am335x_pru_package

PrevNext
Internet SpeedometerInternet SpeedometerInternet Speedometer
  • The assembler that is bundled with PyPRUSS does not work properly. Thankfully, the am335x_pru_package does contain a working assembler.
  • Change working directories back to home: cd
  • Clone the am33x_pru_package repository: git clone https://github.com/beagleboard/am335x_pru_package.git

Step #5: PASM Setup

PrevNext
Internet SpeedometerInternet SpeedometerInternet SpeedometerInternet Speedometer
  • Change directories to ~/am335x_pru_package: cd ~/am335x_pru_package
  • Compile the assembler: make
  • Copy the assembler to the PyPRUSS directory structure: cp pru_sw/utils/pasm ~/pypruss/PASM/pasm

Step #6: Device Tree Setup

PrevNext
Internet SpeedometerInternet SpeedometerInternet SpeedometerInternet Speedometer
  • In order to use the PRUs in Linux a device tree needs to be setup and loaded at boot up. In short, a device tree is a "data structure describing hardware."
  • Change directories to /lib/firmware: cd /lib/firmware
  • Run the text editor nano: nano BB-BONE-PRU-00A0.dts And copy in the lines of code below into nano: [protected-iframe id="f93bb3df679254b695c8dd27bdaa4241-30206320-52394698" info="https://gist.github.com/interested1/1058b425150226d17077.js" width="600" height="1000"]
  • Save the device tree file by holding control and pressing o. When prompted to write out the file, simply hit return.
  • Once saved, quit nano by holding control and pressing x.
  • Convert the device tree file just created into a .dtbo file using this command: dtc -@ -O dtb -o BB-BONE-PRU-00A0.dtbo BB-BONE-PRU-00A0.dts
  • Finally, shutdown the BeagleBone Black so the new device tree files will cleanly load and to allow for safe wiring. shutdown -h now

Step #7: Wiring the Tricolor LED Strip

PrevNext
Internet SpeedometerInternet SpeedometerInternet SpeedometerInternet Speedometer
  • While the power is off connect a jumper wire from pin 12 on the BeagleBone's P8 header rail to a breadboard. This wire controls the signal from the BeagleBone to the tricolor LED strip.
  • On the same P8 header rail, connect a jumper wire to pin 2 on the board and the other end to the breadboard. This wire is used for grounding the board and the LED strip. If this wire is not connected the time of the entire circuit will not be in sync and the LED strip will not work as expected.
  • The tricolor LED strips wires follow a standard color scheme: red for power, green for signal, and black for ground.
  • Connect the red wire in its own row on the breadboard.
  • Connect the green wire to the same row as the wire going to pin 12 on the BeagleBone Black.
  • Connect the black wire to the same row as the wire going to pin 2 on the BeagleBone Black.
  • With the wall wart unplugged, connect the adaptaplug so the stripes on the plug match the stripes on the wall wart.
  • Connect the striped wire of the adaptaplug to the same row as the red wire of the LED strip.
  • Connect the solid black wire of the adaptaplug to the same row as the black wire of the LED strip.
  • Warning: If the power and ground wires are improperly connected and power is applied, the BeagleBone Black will not function. Before plugging in the wall wart, double and triple check your wiring of the power and ground wires!
  • Finally, plug in the wall wart to a wall outlet and plug a USB cable between your BeagleBone and your computer.

Step #8: Capemgr Setup

PrevNext
Internet SpeedometerInternet SpeedometerInternet SpeedometerInternet Speedometer
  • Now that the wiring is complete and the BeagleBone has been booted up, login as root and load the module uio_pruss: modprobe uio_pruss
  • Change working directories to /lib/firmware: cd /lib/firmware Export the variables PINS and SLOTS with the following values: export PINS=/sys/kernel/debug/pinctrl/44e10800.pinmux/pins export SLOTS=/sys/devices/bone_capemgr.9/slots
  • Note: Rather than typing out the entire pathname at a command line, tapping the tab button autocompletes the path. Try typing in only the command below and after typing y, type tab: export PINS=/sy Autocomplete has its limitations, however, it can save a bit of typing.

Step #9: Capemgr Setup cont.

PrevNext
Internet Speedometer
  • Load the PRU by running: echo BB-BONE-PRU > $SLOTS Verify the PRU is loaded by checking the following command's output. It should match image one. cat $SLOTS
  • To test out the configuration, navigate back to ~/pypruss/examples/blinkled: cd ~/pypruss/examples/blinkled Run blinkled.py: python blinkled.py
  • The onboard LED should blink a few times, letting you know it is working.

Step #10: Install the Speedometer code

PrevNext
Internet SpeedometerInternet SpeedometerInternet Speedometer
  • Now that we have proper PRU access, we can setup the speedometer code.
  • Change directories to ~/pypruss/examples: ~/pypruss/examples
  • Clone the git repository: git clone https://github.com/Make-Magazine/bb-led-internet-speedometer.git
  • Change directory to bb-led-internet-speedometer: cd bb-led-internet-speedometer

Step #11: Run pyGet.py

PrevNext
Internet SpeedometerInternet SpeedometerInternet Speedometer
  • Run the Speedometer by running the python script pyGet.py: sudo python pyGet.py
  • The pyGet script is configured to download a test file on speedtest.net’s servers that is 10Mb. Under normal circumstances, a file this size will download quickly and the tricolor LED strip will be green. When the download is not as quick, the output color will be orange. And when the download speed is very slow, the output color will be red. (Image 1)
  • Each time a 10Mb file is downloaded, pyGet.py notes how long it took and stores the result in speed.txt.
  • Depending on the contents of speed.txt, one of three .bin files is invoked from the pyGet.py script: either red.bin, orange.bin, or green.bin. (Image 2)
  • NOTE: The speedometer code also contains a blue.bin and a other.bin. The blue.bin is simply an extra color that never gets used by pyGet.py, but is included. The other.bin is used as a failsafe in the conditional statements of pyGet.py.
  • NOTE: If you want to hack around the code — which is strongly encouraged — remember to run make in the bb-led-internet-speedometer directory or else the code changes will not be compiled into the .bin files.
Jon Karve

Jon Karve

I'm a developer and maker living in Philadelphia, PA. I love anything involving microcontrollers, home automation, and of course, flashing LEDs. I am currently working as an Application Specialist for CRF Health.


Tyler Worman

Tyler Worman

I'm a maker living in Ann Arbor, MI! I enjoy listening to music, playing disc golf, and experimenting with rapid prototyping tools.


  • J’Valkra Edronh

    Maybe I’m being delusional, but couldn’t this work on the raspberry pi as well?

  • Guest

    Very neat, I did a similar project based around a PIC microcontroller. It shows the last 16 seconds of network usage on a pair of LED matrices. More details here:
    https://www.bonafidegeek.com/Bandwidth/

  • Guest

    Very neat! I did a similar project based around a PIC microcontroller. It shows the last 16 seconds of network usage on a pair of LED matrices. More details here:
    https://www.bonafidegeek.com/Bandwidth/

    • guestito

      To be honest, it is ridiculous that these guys needed to use a $50 1GHz processor dev board with 80 inputs/outputs and to execute the same task a couple of $1 microcontrollers could do. It’s just depressing how lazy Mkezine editors have gotten.

      • ScottJL

        True, but when you’re done with that project you’re left sitting with a couple of $1 microcontrollers. The guy with the BBB can go do a lot of other things with his device, or even do them while doing this function.

  • Peter Buelow

    I love this. And it’s a good stepping stone to a christmas project I want to do. However, I have a question. If I set the .p files value of SEGMETS_TO_LIGHT to be 10 or 0, it simply fails to glow that color and the lights are done until I restart. I need to be able to light all the segments, but the most I can get is 9. I plan to dig into this a bit more later this week when I get some time, but I’m hoping there is a simple answer. Note, I can get between 1 and 9, but not 0 or 10, which doesn’t make sense with the very limited code in the .p files. Thanks though for a great hack.

  • Sonny Driscoll

    Can I use a normal LED Strip for this build, or does it need to be the RadioShack version with the embedded support files?

    I am outside of the US and can’t source the exact same part.

    Thanks in advance

    • http://www.novaslp.net/ Tyler Worman

      You could use a different type of strip. You may need to modify the PRU code (or maybe eliminate it entirely) depending on what controller your LED strips use. Get your LED strip working first. Next, alter the base script where it calls the PRU programs.

      • Sonny Driscoll

        Thanks for the reply Tyler! Theres one more thing you may be able to help me with..

        This is the first time I have used a BeagleBone Black and I am attempting to connect it to my MacBook.

        I have bought an Ethernet adapter to allow an Ethernet connection but, but I am unable to connect to the SSH with the session timing out.

        I installed the HoRNDIS and FTDI updates but this has not solved the issue.

        My question is can i complete this build accessing SSH using just the USB connection, and not the Ethernet connection?

        Thanks again

        • http://www.novaslp.net/ Tyler Worman

          You should be able to do the entire project using just the USB connection. We never disabled it that I can remember.

          Ethernet:
          Are you trying to connect the Beagle and the Mac directly together via Ethernet? If so, then configuration is most likely the issue. The easiest way to get this working is assigning both devices a static IP. See here: http://elinux.org/Beagleboard:Terminal_Shells#SSH:_Setting_up_a_Static_IP

          If you aren’t directly connecting them and have a different setup, let me know and I’ll see if I can give you a hand.

          • Sonny Driscoll

            Tyler thanks for the reply.

            Before your response I’d managed to get the SSH log in working, but now when I try to clone the git repository PyPRUSS it isn’t connecting. In fact, I can’t even ping google, so I know it is a networking issue but I cant figure out what I am doing wrong.

            I have allowed the internet connection to be shared on my network preferences, but I am not sure if I need to do something first to allow the Macbook to talk to the Beaglebone on the Ethernet, and share its internet connection.

            Any ideas?

            Your help is greatly appreciated.

            Thanks

            Sonny

          • http://www.novaslp.net/ Tyler Worman

            Hey Sonny – I’m glad you got SSH working. You have to do a few more steps to get internet sharing working across the connection though. Check out this video walkthrough to get it setup. https://www.youtube.com/watch?v=Cf9hnscbSK8

            Basically make the Beagle see the Mac as a gateway. Then force the Mac to share it’s internet connection with the Beagle over the USB interface.

          • Sonny Driscoll

            Thanks Tyler,

            Unfortunately I still can’t get it to work. I am unable to complete the first line of code in the terminal re:

            “screen /dev/tty.usb*B 115200″

            And when I try to skip this step and move to the next operation, I am given this result:

            BeagleBoard.org BeagleBone Debian Image 2014-04-23

            Support/FAQ: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

            Last login: Wed Apr 23 20:20:40 2014 from 192.168.7.1

            root@beaglebone:~# udhcpc -i usb0

            -bash: udhcpc: command not found

            root@beaglebone:~#

            Not sure if there is anything you can see here? I really can’t determine why I am unable to share the internet connection.

            Thanks

            Sonny

          • Sonny Driscoll

            Do you think it would be possible to just install Angstrom to the BeagleBone for the build as it already contains PyPRUSS (I believe)? Presumably though it needs the internet connection anyway to analyse and display output via the LED?

          • http://www.novaslp.net/ Tyler Worman

            I’d skip Angstrom as the direction forward for the beaglebone is Debian. It would need the internet connection to display and output via LED. See my other post about using dhclient on debian to get DHCP working for your internet sharing.

          • http://www.novaslp.net/ Tyler Worman

            You can either install udhcpc client on Debian (it comes with angstrom) or use Debian’s packaged dhclient.

            try substituting dhclient for that command or if that doesn’t work “dhclient usb0″

  • CrabbyPete

    Thanks for putting this up. I really helps learning to develop on the beaglebone PRU. Programming the beaglebone and the 2 PRU’s make the whole beaglebone one heck of board

  • Mike_Alport

    Hi,
    Please can you give me some suggestions?
    I got all the way to the end of your step #9 but then got a Segmentation fault:
    root@beaglebone:~/pypruss/examples/blinkled# modprobe uio_pruss
    root@beaglebone:~/pypruss/examples/blinkled# cat $SLOTS
    0: 54:PF—
    1: 55:PF—
    2: 56:PF—
    3: 57:PF—
    4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
    5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
    7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-BONE-PRU
    root@beaglebone:~/pypruss/examples/blinkled# python blinkled.py
    AM33XX
    File ./blinkled.bin open failed
    Segmentation fault

  • sora

    interesting project
    at the end of the steps why I’m getting this kind of error?

    1.86
    Traceback (most recent call last):
    File “pyGet.py”, line 23, in
    print speed[0]
    IndexError: list index out of range

    and this is what i get when trying to print out cmd and cmd.stdout

    <open file '’, mode ‘rb’ at 0xb67aa0d0>

    any explanation would be great since I’m green with this thing :)

  • Vince Li

    Where are the steps?????

  • Bryan Wilder

    Can someone help me with a pypruss.open(0) error? I’ve tried everything twice now but get the same “SystemError: error return without exception set”.

  • Caleb McGrath

    I have a Freetronics Arduino EtherTen and wanted to make this with either an analog gauge or a servo motor. I am unable to find code for an arduino to monitor my network traffic. Can I get the data from my routers inbuilt monitoring page somehow?

  • Clay Jackson

    OK – I’m hung up trying to create the DTC file, I copied the lines in the instructions into it,but keep getting Syntax errors when I try to compile it. Looks like it’s supposed to download a file from git?