It’s hard time for everyone, covid-19 is spreading the world, even though you can easily getting the news on your finger tips, it still helpful to setup a dedicated dashboard to show the statistics and relating news of covid-19. The following gives step by step guide to customize your covid-19 dashboard using Raspberry Pi.
The setup the dashboard, you need Raspberry Pi and a HDMI monitor, you can either use big screen in the living room, or use smaller one on the desk. Notes: This won’t work for Raspberry Pi zero/one, there is no NodeJS support for “armv6l” any more.
It’s using MagicMirror and covid-19 module.
MagicMirror is an open source modular smart mirror platform, but it doesn’t have to be a mirror, it can be used to setup customized dashboard. MagicMirror is using Nodejs for both client and server, the server provides http service for the dashboard and client is using Electron and run it in Kiosk mode, which is actually running a browser in fullscreen mode, actually you can just one the “server only mode” and open the dashboard in browser on another machine which can access the network.
MagicMirror defines layout below, and you can put dashboard provided by the modules at specific locations.
The modules can define how to fetch the data and how to present it.
That is it!
If you are using lite image, you need install desktop first to run MagicMirror.
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get install raspberrypi-ui-mods -y
sudo apt-get install libgdk-pixbuf2.0-dev -y
sudo ln -s /usr/lib/*/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders /usr/local/bin/gdk-pixbuf-query-loaders
sudo gdk-pixbuf-query-loaders --update-cache -y
sudo apt install ca-certificates python-certifi python3-certifi -y
sudo apt-get install -y --reinstall ca-certificates
sudo update-ca-certificates --fresh
NodeJs-Raspberry-Pi is very convinient to setup latest NodeJS with one command:
$ wget -O - https://raw.githubusercontent.com/audstanley/NodeJs-Raspberry-Pi/master/Install-Node.sh | sudo bash; node -v
Most likely using “apt install” won’t get the latest version and MagicMirror will complaint when installation.
$ git clone https://github.com/MichMich/MagicMirror
$ cd MagicMirror/
$ npm install
MagicMirror comes with some default modules.
# assuming in MagicMirror directory
$ cp config/config.js.sample config/config.js
# use "ctrl+c" to stop, this way of running is for testing
$ npm run
You can try play with the options provided by the modules in “config.js”, for example, you can add more RSS feed to the “News Feed” module:
{
title: "BBC",
url: "http://feeds.bbci.co.uk/news/video_and_audio/news_front_page/rss.xml?edition=us"
},
Or you can change the position referring to the layout mentioned above.
You can also change the language by changing “language” in “config.js”, check https://github.com/MichMich/MagicMirror/tree/master/translations for languages available.
Install in modules directory:
# assuming in MagicMirror directory
$ cd modules
$ git clone https://github.com/bibaldo/MMM-COVID19
Then config the module in “config/config.js”, register account at https://rapidapi.com/ and replace the “get-your-api-key” below with your own API key. After registered, go to https://rapidapi.com/astsiatsko/api/coronavirus-monitor and you can find the API key with name “X-RapidAPI-Key”.
{
module: 'MMM-COVID19',
position: "bottom_bar",
config: {
headerRowClass: "big",
infoRowClass: "big",
worldStats: true,
countries: ["USA", "China"],
lastUpdateInfo: true,
delta: true,
rapidapiKey: "get-your-api-key",
}
},
After making changes to “config/config.js”, you can restart MagicMirror.
The default data sources is lacking details, for example it won’t have the data for counties in USA, and no data for cities in China. You can add other data sources, but it won’t be a simple configuration, and requires some code changes since the data format is not compatible.
Here is the changes made to show counties statistics in USA and to add Chinese translation.
The data source used for USA counties is from https://github.com/ExpDev07/coronavirus-tracker-api, no API key required.
Another options people using in other projects is https://github.com/pomber/covid19, there are some other source available on internet for your country with more details and you can just search with google, and make changes to the code.
There is a wiki on 3rd party modules. The demo dashborad shows on top using the following modules:
You can try other modules based on your needs.
After you tested the dashboard, you still need some configuration to make it ready to use.
You need disable the screensaver, disable the WiFi power save mode and enable OpenGL driver, follow the wiki to config the system.
Notes: I have only one problem with disabling screensaver, when changing “/etc/xdg/lxsession/LXDE-pi/autostart”, have to comment line “@xscreensaver -no-splash” to make it work besides adding those 3 lines below it
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
#@xscreensaver -no-splash
@xset s noblank
@xset s off
@xset -dpms
Follow the steps on the wiki to enable auto start of MagicMirror when system start.
Notes: If after installing pm2 but it’s not found, you probably need to add PATH="/opt/nodejs/bin:$PATH"
in “~/.profile” and then source ~/.profile
Add the following lines in “/var/spool/cron/crontabs/pi” which start MagicMirror at 8 am and stop at 9 pm, it also turns on/off the monitor accordingly.
00 08 * * * vcgencmd display_power 1;pm2 start mm
00 21 * * * vcgencmd display_power 0;pm2 stop mm
If you add more plugins, you can use MMM-pages to put them in several pages, and most likely MagicMirror may consume a lot of memory, which will cause system unresponsive. Increase swap size helps.
sudo dphys-swapfile swapoff
dphys-swapfile setup
sudo dphys-swapfile swapon
curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
sudo apt update
sudo apt install plexmediaserver