This project works thanks to MagicMirror² ("The open source modular smart mirror platform”) running on Raspberry Pi OS.
This document is a guide (step-by-step) to install and configure all software, dependencies and modules from scratch.
This guide works but only with the root
user.
This is due to a problem accessing /dev/mem
(witch is needed for e-ink).
It currently can't be accessed thru npm call at this stage, neither as sudo npm
nor with sticky bit or cap_sys_rawio
capability set.
It works only with user root
(sudo su
).
Thus, all parts about serverusr
must be replaced by root
.
This section deals with the installation and configuration of the operating system.
Create the SD card with Raspberry Pi Imager: Raspberry Pi OS - Raspberry Pi May be installed from Linux distribution of manually.
This project requires a lite 64-bits
version.
i2c_bus
for adafruit-mpr121
), it is necessary to use a 64-bit version:
https://downloads.raspberrypi.org/raspios_full_arm64/images/
Create a file named ssh
in the boot
partition of the card (no extension, no content).
Create a file named wpa_supplicant.conf
in the boot
partition of the card.
The file should contain the following data (change SSID and password):
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=FR
network={
ssid="SSID"
psk="password"
key_mgmt=WPA-PSK
}
# Change the password
passwd
sudo raspi-config
- Change timezone
- Location Options
- Change Timezone
- Change keyboard layout
- Location Options
- Change Keyboard Layout
- Enable SPI
- Interfacing options
- SPI Enable / Disable automatic loading of SPI core module
- Enable i²c
- Interfacing options
- I2C Enable / Disable automatic loading of the I2C kernel module
To run MagicMirror², a specific user serverusr
is created.
# Creation of the user running the MagicMirror service
sudo adduser serverusr
# Add user to the groups allowing access to the i2c and spi
sudo adduser serverusr i2c
sudo adduser serverusr spi
sudo adduser serverusr kmem
Add serverusr
user to sudoers for shutdown
command.
Edit sudoers file:
sudo visudo
Add line:
serverusr ALL=NOPASSWD: /sbin/shutdown
Configure GPIO access (from https://github.com/jperkin/node-rpio):
Disable GPIO interrupts:
Edit /boot/config.txt
:
sudo nano /boot/config.txt
Add following line:
dtoverlay=gpio-no-irq
Enable /dev/gpiomem
access:
Create /etc/udev/rules.d/20-gpiomem.rules
:
sudo nano /etc/udev/rules.d/20-gpiomem.rules
Add following line:
SUBSYSTEM=="bcm2835-gpiomem", KERNEL=="gpiomem", GROUP="gpio", MODE="0660"
# Installation of auto updates
sudo apt install -y unattended-upgrades
# Installation of MagicMirror dependencies
sudo apt install -y npm nodejs
# Installation of tools
sudo apt install -y git make gcc g++
sudo apt install -y ca-certificates curl gnupg
# To compile and install native addons from npm you may also need to install build tools
sudo apt install -y build-essential
# Installation of modules dependencies
sudo apt install -y chromium-browser
Installation of a required nodejs version using project https://github.com/nodesource/distributions.
# Download and import the Nodesource GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
# Create deb repository
NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
# Install nodejs
sudo apt install -y nodejs
Configure automatic updates for the distribution:
Run the following commands to create the automatic updates configuration files:
echo 'APT::Periodic::Enable "1";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::AutocleanInterval "7";'
| sudo tee /etc/apt/apt.conf.d/20auto-upgrades
```sh
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Uncomment / Edit following lines:
Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=${distro_codename}-updates";
// "origin=Debian,codename=${distro_codename}-proposed-updates";
"origin=Debian,codename=${distro_codename},label=Debian";
"origin=Debian,codename=${distro_codename},label=Debian-Security";
"origin=Debian,codename=${distro_codename}-security,label=Debian-Security";
};
Unattended-Upgrade::Automatic-Reboot True;
Unattended-Upgrade::Automatic-Reboot-Time "03:00";'
The Raspberry pi zero 2 W has few RAM.
In order to be able to compile some modules, it is necessary to have a larger swap than the default (100mb)
sudo nano /etc/dphys-swapfile
# change the line to "CONF_SWAPSIZE=1024
sudo dpkg-reconfigure dphys-swapfile
To increase the life of the SD card, it is possible to mount the tmp
partition and logs directory in RAM (or disable logs).
Run the command :
sudo cp -v /usr/share/systemd/tmp.mount /etc/systemd/system/
sudo systemctl enable tmp.mount
Edit the /etc/fstab
file:
sudo nano /etc/fstab
Add the following lines (if they have no entries) to the /etc/fstab
file:
tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,size=100M 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,nodev,noexec,size=10M 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,nodev,noexec,mode=0755,size=10M 0 0
To limit size of logs to 1M
, edit the /etc/systemd/journald.conf
file:
sudo nano /etc/systemd/journald.conf
Replace the following lines:
#Storage=volatile
#RuntimeMaxUse=
by:
Storage=volatile
RuntimeMaxUse=1M
Change hostname to einkframe
sudo echo "einkframe" > /etc/hostname
When configuration is done, run the following command to reboot:
sudo reboot
To configure SSH for login without password, execute from computer:
ssh-copy-id -i ~/.ssh/<filename.pub> pi@einkframe.local
This section deals with the installation and configuration of the application and data display modules.
See MagicMirror² for details.
See Installation & Usage | MagicMirror² Documentation for details.
Run the script installMM.sh commands to retrieve and install MagicMirror² and all necessary modules for this project: Then, apply patch applyPatches.sh to adapt some modules that need it.
cd ~
git clone https://github.com/seb-ma/eInkFrame
eInkFrame/magicmirror_files/installMM.sh
The configuration is split in 2 parts:
- one for near all of the configuration including modules (variable
config
) - one specific for all private data (location, api keys, passwords) (variable
configPrivateParts
)
Edit the configuration file in ~/MagicMirror/config/
and fill variable configPrivateParts
(+ adapt configuration of each module if necessary).
To adapt modules position, see visual representation of module positions in a thread of MagicMirror² forum: module positions.
https://docs.magicmirror.builders/configuration/introduction.html
nano ~/MagicMirror/config/config.js
And fill needed data. Some modules need a specific initialization in order to work. Follow each procedure:
- MMM-FreeBox-Monitor: https://github.com/tataille/MMM-FreeBox-Monitor#readme
- MMM-Spotify: https://github.com/skuethe/MMM-Spotify#install
- MMM-Trello: https://github.com/Jopyth/MMM-Trello#readme
- MMM-VigilanceMeteoFrance: https://github.com/grenagit/MMM-VigilanceMeteoFrance#readme
Custom CSS is copied by install script into ~/MagicMirror/css/custom.css
.
To run MagicMirror² run the following command in ~/MagicMirror
directory:
npm run server
Create a service to automatically start the server:
sudo nano /etc/systemd/system/magicmirror.service
Put the following content in the file:
[Unit]
Description=MagicMirror²
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=serverusr
WorkingDirectory=/home/serverusr/MagicMirror/
ExecStart=node serveronly
[Install]
WantedBy=multi-user.target
Enable and start the service:
# Starting the service
sudo systemctl start magicmirror.service
systemctl status magicmirror.service
# Enabling the service
sudo systemctl enable magicmirror.service
To update MagicMirror² and all installed modules, run the commands in the script updateMM.sh
updateMM.sh
NB: Some modules may need a npm update
before npm install
to resolve electron-rebuild/node-abi version detection error.
Within the same network, open http://einkframe.local:8080/ in a browser.
Run the following commands:
# Distribution
sudo apt update
sudo apt full-upgrade -y
sudo apt clean