Important Links and Shoutouts
- Adafruit RGB Matrix + Real Time Clock HAT for Raspberry Pi - This is an essential guide for this project. It shows you how to build your LED based display platform.
- rpi-rgb-led-matrix - This is the core matrix driver software which gets installed when you setup your LED Matrix with the Adafruit guide.Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi
- ledticker-pi - Led ticker is a python based AWS cloud serverless application that sends data to your thing. It could easily be used as an example on how to build any messaging backend that could send data to your matrix.
- Getting Started With RGB Matrix Panel - Tutorial on can how to create animations, games or all sorts of other fun displays with them.
- ledticker-backend - To send messages to your thing a backend will run an application that will get data off the internet and send it to your thing to be displayed.
Required Hardware
The LED Thing
- Adafruit 32x32 RGB LED HUB75 Matrix Panel - 6mm pitch
- Adafruit RGB Matrix HAT + RTC for Raspberry Pi - Mini Kit
- Raspberry Pi 3 - Model B+ - 1.4GHz Cortex-A53 with 1GB RAM
- 5V 2.5A Switching Power Supply with 20AWG MicroUSB Cable
Your Backend
The Cookbook
This cookbook assumes that you have started up a Raspberry Pi and know how to build and install bonnets and hats. There are things that you will need to know how to do and some things that this guide will show you how to do.
What we don't cover in this guide: These steps are either referenced above or you can find a howto or guide easily on the internet.
- Building the Raspian Flash an Startup your Raspberry Pi 3B+ - Installing Images on a Raspberry PI - Using Etcher
- Getting your Raspberry Pi updated and running Python 3 - Installing Python 3 on a Raspberry Pi
- Assembling the Adafruit RGB Matrix HAT + RTC for Raspberry Pi - Adafruit RGB Matrix + Real Time Clock HAT for Raspberry Pi
- Assembling and Adding the LED Matrix - Getting Started With RGB Matrix Panel - rpi-rgb-led-matrix
What this guide shows you how to do:
This is what the guide is intended to show you how to do.
- Provision your thing on FlashLex
- Download, Install and Test the FlashLex SDK Distribution on your LED Thing Raspberry Pi
- Installing and Testing the the LedTicker runtime on your LED Thing Raspberry Pi
- Setting up your messaging application on your Backend Raspberry Pi
Provisioning Your Thing on FlashLex
Start by using FlashLex to provision a new thing. The docs have a complete guide on how to provision new things for FlashLex. This will build the secure cloud infrastructure for your thing.
Working With the FlashLex SDK Distribution
You will need to download, install and test the SDK distribution for your thing to receive the messages that will be displayed on the LED. The distribution is open source software that you that allows you to communicate with the FlashLex API using an Software Development Kit when used in conjunction with your FlashLex certificates.
You can see all the source code used for this distribution on github.com, and we welcome involvement from the IOT community.
Be sure to read the entire guide on using the FlashLex distribution to understand how to use it. Follow the guide in our help docs for complete instructions
Installing and Testing the the LedTicker Runtime
Allows a raspberry pi to drive an LED display as an IOT divide in AWS. The idea is to make a IOT thing that is basically just a slave to the messages sent to a queue. This allows the device to be dumb and multiple suppliers to be as sophisticated as needed.
The ledticker-pi
project allows your thing to use FlashLex to load messages from the local database as a cache and display them as they arrive. You can see the ledticker-pi project page on github.com
These are the guides that accelerated building this project extensively.
- Adafruit RGB Matrix Hat for RPI - https://learn.adafruit.com/adafruit-rgb-matrix-plus-real-time-clock-hat-for-raspberry-pi
- Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO - https://github.com/hzeller/rpi-rgb-led-matrix
- Getting Started With RGB Matrix Panel - https://www.hackster.io/idreams/getting-started-with-rgb-matrix-panel-adaa49
First install flashlex. You will need to install FlashLex in the virtualenv of the Led Ticker app.
This is a flashlex project. That is it uses the flashlex cloud IOT framework to send messages to the Raspberry Pi. You can get more info on flashlex at flashlex.com
source venv/bin/activate #activate your virtual env
cd .. # goto the parent of the ledticker project
git clone https://github.com/claytantor/flashlex-iot-python.git
cd flashlex-iot-python # go into the flashlex distribution
sudo python setup.py install # install the sdk
How to Display a Message To the LED using GPIO and Python
You will want to extend your class from SampleBase
which contains the RGBMatrix
bindings that will let you map a display buffer to the LED Matrix.
The implemented display class would then implement a run
that would let you manage sending data to the display buffer:
class LedDisplay(SampleBase):
def __init__(self, *args, **kwargs):
super(LedDisplay, self).__init__(*args, **kwargs)
self.parser.add_argument('--log', type=str, default="INFO", required=False,
help='which log level. DEBUG, INFO, WARNING, CRITICAL')
self.parser.add_argument('--config', type=str, required=True, default='config.yml',
help='the name of the configuration section to use.')
def get_messages(self, config):
print("getting messages")
sdk = FlashlexSDK(config)
messages = sdk.getSubscribedMessages()
for message in messages:
yield message
sdk.removeMessageFromStore(message)
An example of displaying fixed text using this pattern:
class FixedText(LedText):
def __init__(self, runner, message):
super(FixedText, self).__init__(runner, message)
self.name = "Fixed Text"
@staticmethod
def matches(message):
if 'body' in message and 'behavior' in message and message['behavior'] == 'fixed' and message['type'].startswith('text'):
return True
else:
return False
def display(self):
offscreen_canvas = self.runner.matrix.CreateFrameCanvas()
font = graphics.Font()
font.LoadFont(self.get_font_path(self.message))
textColor = self.get_text_color(self.message)
len = graphics.DrawText(offscreen_canvas, font, 0, 10, textColor, '{0}'.format(self.message['body']))
pos = math.ceil((offscreen_canvas.width-len)/2.0)
height = math.ceil(offscreen_canvas.width/2.0)+math.ceil((font.height-2)/2.0)
# print("height: {0} font.height: {1}".format(height, font.height))
start_time = time.time()
elapsed_time = time.time() - start_time
elapsed_time_boundry = 10.0
if 'elapsed' in self.message:
elapsed_time_boundry = self.message['elapsed']
while elapsed_time < elapsed_time_boundry:
#print time.time(),start_time
offscreen_canvas.Clear()
len = graphics.DrawText(offscreen_canvas, font, pos, height, textColor, '{0}'.format(self.message['body']))
time.sleep(1)
elapsed_time = time.time() - start_time
offscreen_canvas = self.runner.matrix.SwapOnVSync(offscreen_canvas)
offscreen_canvas.Clear()
offscreen_canvas = self.runner.matrix.SwapOnVSync(offscreen_canvas)
The next step is to run the program on the command line. To run the LED Hat the system requires that to run as sudo.
sudo /home/pi/projects/ledticker-pi/venv/bin/python -u \
/home/pi/projects/ledticker-pi/ledticker.py \
--led-no-hardware-pulse true -m adafruit-hat -r 32 --led-cols 32 \
--log DEBUG --config /home/pi/projects/ledticker-pi/config.yml
Your thing should now be ready to recieve messages.
Sending a test message to the display
There are two ways to send a message to your thing.
- Use the FlashLex message test form for your thing
- Use the FlashLex Cloud API.
curl -X POST \
https://apis.flashlex.com/dev/v1/things/48338542-9866-4046-9ecc-ad74e1807cc5/publish \
-H 'Authorization: Bearer eyJraWQiOiJQTytrSGI5RXB2QjVRSFlka2duWWtRUmtjazhQSVhkakNaUGtFMnJGUFdRPSIsImFsZyI6IlJTMjU2In0' \
-H 'Content-Type: application/json' \
-d '{"body": "Clouds|55|F", "color": "#3366ff", "type": "weather", "behavior": "current", "elapsed": 20.0}'
You are now sending custom messages to your LED ticker thing!