Huge 1st Project: 150 LED Traffic Flow visualiser

Hello everyone, greetings from the Netherlands!
At our recent annual LAN party, the idea arose to visualize the internet data flow with an LED strip attached to the UTP cable bundle.
While looking for possible solutions, I came across BlinkStick, and ordered one.

I’m not an electrical expert, but I know my way around software and scripting, and I generally get a lot done by reading and trying.

This BlinkStick project may be too ambitious, but if you don’t try, you won’t know.

What I want to do in a few steps:

  • get the download bandwidth usage from pfSense (probably using SNMP)

  • Connect WS2812B LED strip of 50 LEDs to BlinkStick (without additional power supply, because as a test I want to switch on a few LEDs at the same time at low brightness)

  • Make a program that:

    1. Gets the bandwidth usage value of PFsense at an interval, probably with SNMP get.
    2. Can handle variable number of LEDs across the 3 control channels
    3. Sending a flow effect onto the LEDstrip (something like this: )
    4. the flow crosses the strip more often/faster if the input value is higher (based on maximum in a variable)

If this is successful, I want to expand further by adding a power supply and a total of 150 LEDs (3x 50).

And then maybe also add upload bandwidth with a flow the other way.

I am very curious what you think of this Project, and think it is feasible.
I don’t know yet in which language I want to make the program, what do you suggest? I have some experience with VBA, AutoIT, batch, SAS, SQL.

By the way, help is welcome!

Got my BlinkStick Pro in the mail today :slight_smile:
Thanks for the handwritten heads up Arvy!

Another few weeks for my Ebay ordered LED-strip will arrive.

In the meanwhile I’ve started experimenting in Visual Studio with vb forms.
No real experience doing this, so please help me make my code better.

The SNMP readout is working.

Imports System Imports SnmpSharpNet

Public Class Form1
Dim LedCount As Long = 64
Dim RevolutionsCount As Long = 1
Dim downloadspeed As Long = 0
Dim uploadspeed As Long = 0

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    Timer1_Tick(Nothing, Nothing)
    Timer1.Interval = 5000 '5 seconds
    Timer1.Enabled = True
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    Timer1.Enabled = False
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    Dim host As String = ""
    Dim community As String = "**********"

    Dim requestOiddwn() As String
    Dim dwnresult1 As Dictionary(Of Oid, AsnType)
    Dim dwnresult2 As Dictionary(Of Oid, AsnType)
    requestOiddwn = New String() {"."}

    Dim requestOidup() As String
    Dim upresult1 As Dictionary(Of Oid, AsnType)
    Dim upresult2 As Dictionary(Of Oid, AsnType)
    requestOidup = New String() {"."}

    Dim snmp As SimpleSnmp = New SimpleSnmp(host, community)
    If Not snmp.Valid Then
        Console.WriteLine("Invalid hostname/community.")
        Exit Sub
    End If
    dwnresult1 = snmp.Get(SnmpVersion.Ver1, requestOiddwn)
    upresult1 = snmp.Get(SnmpVersion.Ver1, requestOidup)
    dwnresult2 = snmp.Get(SnmpVersion.Ver1, requestOiddwn)
    upresult2 = snmp.Get(SnmpVersion.Ver1, requestOidup)

    Dim kvp As KeyValuePair(Of Oid, AsnType)

    If dwnresult1 IsNot Nothing And dwnresult2 IsNot Nothing Then
        Dim download1 As Long
        For Each kvp In dwnresult1
            download1 = kvp.Value.ToString
        Dim download2 As Long
        For Each kvp In dwnresult2
            download2 = kvp.Value.ToString
        downloadspeed = (download2 - download1) / 2 / 1024 / 1024 * 8
        Console.WriteLine("No complete download results received")
    End If
    Console.WriteLine(downloadspeed.ToString & " mbit/s down")
    Label1.Text = downloadspeed & " mbit/s down"

    If upresult1 IsNot Nothing And upresult2 IsNot Nothing Then
        Dim upload1 As Long
        For Each kvp In upresult1
            upload1 = kvp.Value.ToString
        Dim upload2 As Long
        For Each kvp In upresult2
            upload2 = kvp.Value.ToString
        uploadspeed = (upload2 - upload1) / 2 / 1024 / 1024 * 8
        Console.WriteLine("No complete upload results received")
    End If
    Console.WriteLine(uploadspeed.ToString & " mbit/s up")
    Label2.Text = uploadspeed & " mbit/s up"
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
    Dim bsFinder As New BlinkStickInterop.BlinkStickFinder
    Dim bsLedstrip As BlinkStickInterop.BlinkStick = bsFinder.FindFirst()

    ' To hold the three primary colors as Bytes
    Dim R As Byte, G As Byte, B As Byte

    ' For the For loop
    Dim n As Long, i As Long

    If bsLedstrip Is Nothing Then
        MsgBox("BlinkStick not found!")
        MsgBox("BlinkSick found: " & bsLedstrip.GetSerial)
        MsgBox("down: " & downloadspeed & vbCrLf & "up: " & uploadspeed)
        Dim vbaColor As Long

        With bsLedstrip
            ' Strip out the three primary colors
            R = vbaColor Mod 256
            G = vbaColor \ 256 Mod 256
            B = vbaColor \ 65536 Mod 256

            ' Animation
            i = RevolutionsCount * LedCount
            For n = 0 To i
                .BlinkIndexed(0, (n Mod LedCount), R, G, B)
            Next n

        End With

    End If
End Sub

End Class