Contact Us
Language

How to Build a Scrolling-Text Face Mask with Raspberry Pi | Tom's Hardware

tagsHdmi Optical Splitter

after

Express yourself by scrolling text on the mask with Flex NeoPixel matrix and Raspberry Pi.

When wearing a mask, is it difficult for people to understand what you are talking about? Now you can make a fashion statement and express yourself in words while still wearing a mask. This tutorial brings a new meaning to the way of expression, "It's written on your face."

,

with

It is recommended to wear masks in public places where you may encounter other people to help slow the spread of COVID-19. The mask should completely cover the person's nose and mouth.

For most of us, facial coverings also hinder our ability to communicate verbally. I have seen many people put down their masks when talking, but unfortunately, this weakens their ability to use masks. How can we express ourselves clearly while keeping our nose and mouth covered?

In this article, we will show you how to use

And 8x8 NeoPixel flexible matrix. For this project, we will also provide 2 versions for 16-pixel and 32-pixel wide matrices. The cloth mask should have a translucent top layer and completely cover your mouth and nose. Before cleaning your mask, remove all electronic equipment. 

Put on a mask, cover your nose and mouth, turn on the power, navigate to the front end of the local web page, and enter text to scroll through your mask. 

In this step, we will perform basic wiring and run the sample code provided by

. The NeoPixel matrix requires a separate 5 volt power supply. In order to make the project portable, I am using a 5V power bank charger.

1.

power input

. (M to M line)

2.

To the ground wire on the breadboard. NeoPixel Matrix actually needs to connect 2 GND wires, one is next to the 5V red wire, and the other GND wire is next to the DIN. Please connect both to GND.

3.

On a breadboard.

4.

Your breadboard.

5.

(power input)

(There are stripes next to it)

6.

(The side without stripes).

7

matrix. (M to F line)

In order to use the 5V mobile power charger to power the NeoPixel matrix, I used an old microUSB cable and cut off one end of the microUSB (retaining the USB), stripped the wire, and exposed the red (power) and black (ground) wires . 

If you are not ready to cut off the USB cable, please use the following power sources to power the NeoPixel:

For the wiring in this step, I used a test wire with an alligator clip to connect the stripped USB cable to the power input on the NeoPixel matrix. I finally plugged the USB into the mobile power charger.

After completing the wiring connections, let's test the matrix using Adafruit's test code.

If you don’t have a microSD card, please refer to the following article: 

Or how to do

.

You can do this by pressing CTRL+T.

4.

6.  

If your NeoPixel matrix lights up, it means red, green, blue, rainbow, congratulations, your NeoPixel matrix is ​​working, you can proceed to the next step. Otherwise, please go back and troubleshoot the connection.

in case

pin

Does not work properly on your Raspberry Pi, you can change

Output to

, Or

. turn on

From

With folder

or

(Click the right mouse button in the file manager), and then update the GPIO output. Don't press Geany or Thonny's Run button. Remember, if you choose to change the GPIO output

, You will need to make the same changes to other files as you complete this tutorial.

7  

Stop the script. 

At the end of this step, you should have a basic NeoPixel matrix that can be fully lit. 

In this section, we will test the scrolling text function of the NeoPixel matrix.

1. If you have

Open from

And still in

Directory, run

You should scroll on the matrix to see the text "Welcome to Tom's Hardware".

Stop the python code. 

From the same terminal and the same directory.

4. The code should automatically prompt you to enter your own text.

Or a phrase of your choice. 

You may notice that the letters (fonts) on the matrix are slightly different from those seen in the example video of this tutorial. The sample code uses the default font included in Raspberry Pi OS, while the video uses

Font. You can

Then install it into your Raspberry Pi.

2. Open a new terminal, then

with

 3.

With Geany

By increasing

Before "Font = ImageFont.truetype("LiberationMono-Regular.ttf", 8)"

Set the font to

By deleting

7

once again

Enter the word or phrase of your choice.

In this step, we will make our solution mobile by creating a convenient front end

Enter the scrolling matrix text on the website.

1. If you have completed the optional steps to change the font (in the previous step), please make the same changes in the file

2. On the terminal, navigate to

Directory, and then run

Use the command (sudo python3 app.py).

Browser.

(Assuming "raspberrypi" is your hostname) or

You can choose to scroll on the matrix.

If you see two scrolling entries on the matrix, please go to another computer or phone (on the same WiFi network) and enter

Once again, let's assume raspberrypi is your hostname.

. If you see the text scrolling twice on the matrix again, you can set the script to start on startup.

In this step, we will set up Pi to always run

The code that runs at startup.

2. Enter

3.  

.bashrc 

4. Hit

In this step, we make the solution truly mobile. In the case of turning off the Pi and completely exiting the previous step, we will first write down the wiring and take a picture if necessary. 

Correctly connect between the power input of the matrix and the USB cable. 

. Use a hair dryer or heat gun to seal the heat shrink tube.

. You may need to add a small piece of wire between the ground wires to make the + wire flat. Cover the exposed wires with heat shrink tubing. Use a hair dryer or heat gun to seal the heat shrink tube.

After soldering, your NeoPixel matrix power input should have a USB connection. 

There are 2 female to male wires. Connect DIN to GPIO 21 (or if you changed the GPIO pin in the previous step). Connect GND to any GND pin on the Raspberry Pi.

The front is a translucent fabric, so be careful not to disconnect any wires.

. If you have 2 USB outputs, you can use a mobile power charger to power Pi and NeoPixel. Raspberry Pi 4 can be powered by a mobile power charger with USB Type-C output.

8. After the pi starts, go to any computer or mobile device on the same WiFi network, and then

And enter a word or phrase.

If the text you entered scrolls on your mask, congratulations! You have completed this project!

For a real

, If you have a mobile plan and a smart phone with hotspot function, you can get rid of the shackles of home WiFi. 

1. On your smartphone,

2. On your Raspberry Pi desktop

And enter the hotspot password of the phone. 

3. In the browser on the smartphone,

And visit your front-end web page. 

I provided 2 other versions of Python files for this project for 16-pixel and 32-pixel wide configurations.

To make a 16x8 NeoPixel matrix for the Raspberry Pi scrolling text mask, you will need 2 flexible 8x8 NeoPixel matrices. The second NeoPixel matrix will be powered by the first matrix and does not require a second power source.

1.

Your primary NeoPixel to

The second NeoPixel matrix.

2.

Place the matrices side by side and secure them in place with electrical tape. 

With a translucent top layer. Keep in mind that you will need a cloth mask that ends 3.1 inches high to fit NeoPixels.

From your terminal:

6. If any changes are made to the code of the 8x8 matrix (font, text color, scroll speed), then

To the files in the 16Matrix folder.

Just like you did for the 8x8 matrix. 

This

It can be purchased immediately and can be connected in the same configuration as the 8x8 matrix. The 32x8 NeoPixel Matrix is ​​too wide to fit in the mask, but it can fit well above the mask.

Follow the steps in Part 1.

From your terminal:

3. If any changes are made to the code of the 8x8 matrix (font, text color, scroll speed), you need

To the files in the 32Matrix folder.

Just like you did for the 8x8 matrix.

Then glue the hot glue to your mask.

In addition, if you want to display a static image of the crown, you can use the file 32-crown.py. Run the code:

We hope you found this tutorial interesting and useful. This project brings new meaning to "it is written on your face". 

Get immediate news, in-depth reviews and useful tips.

Thank you for registering Tom's hardware. You will receive a verification email shortly.

There is a problem. Please refresh the page and try again.

Tom's Hardware is part of an international media group and leading digital publisher Future US Inc.

©Future US, Inc. 15th Floor, 11 West 42nd Street, New York City, New York, New York 10036.