In the coming months, we are planning to launch our new nRF52840 based development board named Blip. I thought it would be interesting to do something visually and use Web Bluetooth in the process.
For peoples who are curious about what blip is, It is a development board for Bluetooth Low Energy (BLE) and 802.15.4 based wireless applications, based on the Nordic Semiconductor nRF52840 SoC. It has a Black Magic Probe compatible programmer and debugger built in, along with temperature/humidity sensor, ambient light intensity sensor, and a 3-axis accelerometer. It can be used to prototype very low power devices. It also has provision for an SD card slot, which makes it a complete and versatile development board.
In this project, I will interface led matrix with our blip board, show some color patterns and change that pattern over BLE using Web Bluetooth. I will use Arduino IDE for programming the board. We recently added Arduino support for our board which is based on Adafruit’s nRF52 Core so you can leverage all Arduino libraries and get started with the board quickly.
- Blip board
- 8×8 RGB Led Matrix (CILE 2088RGB-8)
- Shift registers (74HC595)
Interfacing LED Matrix with Blip
The LED matrix we are using, has 32 pins, 8 pins for anode lines and other 24 for Red, Green, Blue LEDs as shown in the image below. To flash a led, respective anode pin should be high and LED row pin should be low.
Shift register takes data serially and outputs it in parallel. We are using 8-bit wide 74HC595 shift registers which means you can control 8 output pins (QA-QH) by sending data into SER (SERial) pin in sync with SRCLK (SeRial CLocK), so 4 shift registers are needed. In Blip board 28 pins are exposed as GPIOs, so It’s not possible to drive led matrix directly through Blip’s GPIOs. We soldered led matrix and four shift registers in the cascaded configuration on separate perf board.
Perf Board Schematic :
|Blip||Cascaded Shift registers|
Here is the code which displays smiley face on the Led Matrix
DisplaySmileyFace() function fills smiley emoji data into 8×8 Screen buffer and in the loop, sendDataToDisplay() is being called which send that buffer data to shift registers. This function turns on one row at a time because VDD pin on perf board is connected to Blip 5V pin and that pin can’t drive all LEDs at an instance.
Adding BLE functionally
Now, it’s time to add BLE functionally so we can change LED colors dynamically without hardcoding, I am using BLE UART Service to transfer LED matrix buffer. Every time the data in the format mentioned below is written to BLE UART Rx Characteristic, it will be filled into the buffer and displayed onto the LED matrix.
|STARTBYTE||64 Bytes of Data||ENDBYTE|
STARTBYTE = 8
ENDBYTE = ‘\n’
Refer to Resources and links section for full firmware code.
Web Bluetooth App
To send LED matrix pattern to blip, we write 2d array with start and end byte to the RX Characteristic (UUID: 6E400002-B5A3-F393-E0A9-E50E24DCCA9E).
Refer to Resources and links section for full web-app code.
Here is the video that explains the whole flow like connecting to blip and drawing pattern on canvas and sending it to led matrix.
Here you have our blip board talking to the web browser through BLE. You can draw some cool patterns, emoji etc. on 8×8 led matrix from the browser. As always there is room for improvements, I could have used a separate power supply for driving led matrix but that is only possible if we put MOSFETs on Anode lines.
You can find all the code including web-bluetooth demo and firmware used in this article at the link below:
I would like to thank Siva for soldering the led matrix on perf board and Arun for helping me with Web Bluetooth app especially UI part.