Raspberry Pi with Matrix LED Display + Flask

Web Controlled LED RGB using Raspberry Pi and Flask. Plus a 3D printed enclosure designed in Fusion 360!

I added a few snipits of code but all the code for Flask and the html templates can be found on the Github repository: link

Every Raspberry Pi needs a cool SSH Splash MOTD:

image

Product List

  • 2x 16x32 RGB LED panels from Adafruit - link
  • 1x Adafruit RGB Matrix HAT + RTC for Raspberry Pi - Mini Kit - link
  • 2x 5V 4A (4000mA) switching power supply - link
  • 1x Raspberry Pi Model A+/B+/Pi 2 or Pi 3 - link
  • 1x Monoprice Select Plus 3D Printer - link
  • 1x Wifi USB dongle, (but not necessary on newer Raspberry Pi)

Info

Raspberry Pi panel is powered with two 2.4v power adapters plus a Raspberry Pi HAT that does the hard work for panel display graphics. No need to wire each GPIO pin to the LED panel, BUT some basic soldering is required. Panels are 32x16 and daisy chained together to make a 64x16 display.

image

Fusion 360 Design

I also designed an enclosure to fit the loose wires and panels inside of, so it looks cleaner. Used Autodesk Fusion 360 and got the dimensions of the panels off Adafruit’s website.

Sketched Imgur

3D Model Rendering Imgur

I also needed to print a riser for the LED panels to sit ontop of, the Pi and wires go underneath, riser is glued on the top half of the enclosure and seats the panels.

Imgur

Then I put everything into Cura, sent to my 3D printer, and printed.

Flask Controls

  • Flask HTML templates for form validation and rendering
  • Change the text/solid color of the RGB Screen
  • Controllable via any Web browser
  • Can set the color of the text by changing RGB values

Imgur

Flask Form

  • ‘message’ view & form input takes the raw data from the form to control the panel.
  • form.validate() ensures an RGB value is between 0-255
# mattpi.com/message/
@app.route("/message/", methods=['GET', 'POST'])
def message():
    form = TextEntryForm(request.form)

    if request.method == 'POST' and form.validate():

        # Text Display
        print 'success'
        word=request.form['word']

        # Color Display RGB
        r = int(request.form['r'])
        g = int(request.form['g'])
        b = int(request.form['b'])

        matrix.Clear()

        # init so it repaints on new post
        image = Image.new("1", (64, 16))
        image = image.convert("RGBA")
        draw = ImageDraw.Draw(image)
        
        # Set the image
        matrix.SetImage(image.im.id, 0, 0)
    else:
       print 'failure'
    # Return the same view
    return render_template('text.html', form=form)

Finished Product

Plug in the 2 power adapters, and it’s ready to go! Wifi dongle attached, no ethernet, only cables going out the back are for power.

With the lights off Imgur

With the LEDs lit up with text! Imgur

Just some slight modifications need to be applied to case and risers so it’s completely level!! Small piece of paper in there temporary so the panel doesn’t tilt

Written on May 22, 2018