Almost all countries have Covid – 19 coronavirus. This project describes a 64x32 RGB matrix tableau that displays real-time statistical information about cases and deaths from COVID-19 coronavirus in the 20 countries with the highest cases of infection. Data is taken from the site https://www.worldometers.info/coronavirus/.
2048 RGB LEDs are assembled in a panel with a diagonal of 11 inches. The panel's LEDs Shine with a brightness of up to 1200 CD / m2, which allows you to see the image in detail on the matrix even in bright lighting. On the reverse side, the control circuit is soldered and screw fasteners are provided.
The matrix itself does not have a microcontroller or memory chips. The LEDs are connected via shift registers and drivers. The LED matrix is powered from 5 V and consumes up to 4 A.
A 16-wire loop is used to connect the matrix:
As a microcontroller, we will use the Raspberry pi, which allows you to control 12 32x64 matrices.
Raspberry pi zero WThe Raspberry Pi Zero W is the second model of a miniature single-Board computer from the Raspberry Pi line. Compared to the Raspberry Pi Zero Version 1.3, Zero W has not undergone any other changes, other than the addition of a Cypress CYW43438 wireless communication chip that supports Wi-Fi networks of the standard 802.11 n and Bluetooth 4.1 (Bluetooth Classic and LE)
You can install the operating system and connect to a local network without using a monitor and keyboards, in headless mode.Download a fresh image of Raspbian from the official site from the page https://www.raspberrypi.org/downloads/raspbian. Recording the downloaded image to a microSD card. You can use, for example, the Win32DiskImager program. Before installing the microSD card in the slot of the raspberry Pi Zero W microcomputer and feeding power to it, configure the network connection. After recording the image, open the microSD card and create two files in the root folder: ssh (without extension) and wpa_supplicant.conf. We leave the ssh file empty (it is necessary to activate SSH access, which is disabled by default in Raspbian). In the wpa_supplicant.conf file, we add the following content, changing the values of the ssid and psk parameters to our own.
ctrl_interface=DIR=/var/run/wpa_supplicant
GROUP=netdev
update_config=1
country=RU
network={
ssid="my_DLink"
psk="********"
key_mgmt=WPA-PSK
}
Install the microSD card in the slot of the raspberry Pi Zero W microcomputer and supply power to it. If the name of the Wi-Fi access point and its password are specified correctly, the Raspberry Pi Zero W should automatically connect to the local network and get a local IP address, which can be viewed on the router.
Knowing the IP address, we can connect to the microcomputer via ssh (from Windows by the putty program). Login pi, password raspberry
RGB matrix driver for Raspberry piUsed to connect the matrix to the Raspberry pi
It is installed on top of the Raspberry Pi by the sandwich method.
Connect the signal lines between the driver and the led matrix via a loop. One loop pin to the output connector on the controller, and the other to the input data connector on the DATA IN matrix. Connect the power supply from the driver to the led matrix with a power wire. One end of the wire to the PWR OUT terminal on the controller, and the other end to the POWER connector on the matrix. Connect power to the module via an external "DC Barrel jack" connector. We use a 5V power supply. Current consumption is up to 5A, but this is when all the LEDs are turned on to the maximum (white). When connecting several led panels, the current margin increases by T-times, and the project will display text information on a black background, so you can limit the power supply to 2A.
Connecting to the Raspberry pi zero W via ssh.
Download and run the script to configure the software for working with raspberry LED panels.
wget https://raw.githubusercontent.com/amperka/scriptsRPI/master/amperka-rpi-rgb-matrix.sh
sudo bash amperka-rpi-rgb-matrix.sh
The program will offer you a choice of image output:
1-High Quality-the matrix displays an image without flickering or glare. But then you need to disable the audio driver on the Raspberry pi zero W.
2 - Convenience-flickering may occur when displaying images. But the sound will remain on.
(For mode 1, you must install the jumper on the driver).
Select mode 2 (don't set the jumper).
The installation and compilation process will start, then the dpi-rgb-led-matrix folder should appear in the root folder after restarting.
Examples of working with a matrix in python are located in the folder./home/pi/pi-rgb-led-matrix/bindings/python/samples.
ProgrammingThe program is written in the python 3 programming language. Create a file covid19.py in the folder /home/pi/pi-rgb-led-matrix/bindings/python/samples
Data is taken from the site https://www.worldometers.info/coronavirus/
When displaying data for a country, we will output its name and flag. We will need 16 px flag icons.
Create in the folder /home/pi/pi-rgb-led-matrix/bindings/python/samples/flags and load the flag icons.
Connecting the necessary libraries
import requests
import time
import lxml.etree
import lxml.html
from rgbmatrix import RGBMatrix, RGBMatrixOptions
from rgbmatrix import graphics
from PIL import Image
You must set the settings for the matrix
# Configuration for the matrix
options = RGBMatrixOptions()
options.rows = 32
options.cols = 64
options.chain_length = 1
options.parallel = 1
options.row_address_type = 0
options.multiplexing = 0
options.pwm_bits = 11
options.brightness = 100
options.pwm_lsb_nanoseconds = 130
options.led_rgb_sequence = "RGB"
options.pixel_mapper_config = ""
Making queries to the site table data https://www.worldometers.info/coronavirus/ and get the necessary data
for pos in range(9,29):
r = requests.get("https://www.worldometers.info/coronavirus/")
root = lxml.html.fromstring(r.content)
totalcases=root.xpath('//*[@id="main_table_countries_today"]/tbody[1]/tr['+str(pos)+']/td[3]')
newcases=root.xpath('//*[@id="main_table_countries_today"]/tbody[1]/tr['+str(pos)+']/td[4]')
newdeaths=root.xpath('//*[@id="main_table_countries_today"]/tbody[1]/tr['+str(pos)+']/td[6]')
country=root.xpath('//*[@id="main_table_countries_today"]/tbody[1]/tr['+str(pos)+']/td[2]/a/text()')
For verification, we output data to the terminal
print("pos=",pos)
print("country=",country[0])
if countries.get(country[0])!=None:
print("countries=",countries[country[0]])
print("totalcases=",totalcases[0].text)
print("newcases=",newcases[0].text)
print("newdeaths=",newdeaths[0].text)
print("----------------")
And then to the matrix
matrix.Clear()
#
if countries.get(country[0])!=None:
image = Image.open("flags/"+countries[country[0]])
image.thumbnail((16, 16), Image.ANTIALIAS)
matrix.SetImage(image.convert('RGB'))
#
graphics.DrawText(canvas, font2, 20, 8, textColor1, country[0])
#
if(newcases[0].text==None):
graphics.DrawText(canvas, font3, 2, 20, textColor2, "+0")
else:
graphics.DrawText(canvas, font3, 2, 20, textColor2, newcases[0].text)
#
if(newdeaths[0].text==None):
graphics.DrawText(canvas, font3, 35, 20, textColor5, "+0")
else:
graphics.DrawText(canvas, font3, 35, 20, textColor5, newdeaths[0].text)
graphics.DrawText(canvas, font2, 10, 30, textColor2, totalcases[0].text) print("newdeaths=",newdeaths[0].text)
Starting a filecd /home/pi/rpi-rgb-led-matrix/bindings/python/samples
sudo python3 covid19.py
Comments