Call-Informatique
Call-Informatique
Le média tech
Dashboard e-ink avancé : installation et optimisation complète
High-TechGuides8 min de lecture

Dashboard e-ink avancé : installation et optimisation complète

Guide technique complet pour configurer un dashboard e-ink avec Inkycal, optimisation énergétique, monitoring système et intégrations avancées.

Ce tutoriel détaille l'installation complète d'un dashboard e-ink professionnel basé sur Raspberry Pi et Inkycal. Nous couvrirons la configuration matérielle, l'optimisation système, les intégrations API et le déploiement en production avec monitoring.

Architecture et choix techniques

Le projet repose sur une stack optimisée pour la faible consommation énergétique :

  • Hardware : Raspberry Pi Zero 2 W (quad-core 1GHz, 512MB RAM, Wi-Fi/Bluetooth)
  • Display : Waveshare 7.5" HD e-Paper HAT (800x480px, 3-color ou monochrome)
  • OS : Raspberry Pi OS Lite (64-bit), headless
  • Runtime : Python 3.11+ avec environnement virtuel isolé
  • Framework : Inkycal v2.0+ avec modules personnalisés

Consommation mesurée : 0.8W en idle, 2.1W pendant le refresh e-ink. Autonomie estimée : 3-4 semaines sur batterie 10000mAh avec optimisation agressive.

Préparation de l'environnement

Flashing et configuration initiale

Utilisez Raspberry Pi Imager avec les paramètres avancés suivants :

bash
## Après flash, montez la partition boot et créez :

## 1. Activation SSH
touch /media/$USER/boot/ssh

## 2. Configuration Wi-Fi avec pays et sécurité
cat > /media/$USER/boot/wpa_supplicant.conf << 'EOF'
country=FR
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="YOUR_SSID"
    psk="YOUR_PASSWORD"
    scan_ssid=1
    key_mgmt=WPA-PSK
    proto=RSN
    pairwise=CCMP
    group=CCMP
}
EOF

## 3. Configuration hostname et utilisateur
cat > /media/$USER/boot/userconf.txt << 'EOF'
pi:$6$crypt$salt$hash
EOF
## Générez le hash : openssl passwd -6 'yourpassword'

## 4. Overclocking conservateur pour Zero 2 W
cat >> /media/$USER/boot/config.txt << 'EOF'

## E-ink display optimization
dtparam=spi=on
dtoverlay=spi0-0cs
gpio=25=op,dh

## Power saving
arm_freq=1000
over_voltage=2
gpu_freq=250
EOF

Hardening initial du système

bash
## Connexion SSH et mise à jour
ssh pi@raspberrypi.local
sudo apt update && sudo apt full-upgrade -y

## Sécurisation basique
sudo apt install -y fail2ban ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 192.168.0.0/16 to any port 22
sudo ufw enable

## Configuration fail2ban pour SSH
sudo tee /etc/fail2ban/jail.local << 'EOF'
[sshd]
enabled = true
port = 22
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
bantime = 3600
EOF

sudo systemctl enable fail2ban
sudo systemctl start fail2ban

## Désactivation des services inutiles
sudo systemctl disable bluetooth
sudo systemctl disable avahi-daemon
sudo systemctl disable triggerhappy
sudo systemctl disable ModemManager

Installation d'Inkycal et dépendances

Environnement Python isolé

bash
## Installation des dépendances système
sudo apt install -y \
    python3-pip python3-venv python3-dev \
    libopenjp2-7 libtiff5 libjpeg-dev \
    zlib1g-dev libfreetype6-dev \
    liblcms2-dev libwebp-dev tcl8.6-dev \
    tk8.6-dev python3-tk libharfbuzz-dev \
    libfribidi-dev libxcb1-dev git

## Création environnement virtuel
python3 -m venv —system-site-packages ~/inkycal-env
source ~/inkycal-env/bin/activate

## Upgrade pip et installation wheels
pip install —upgrade pip wheel setuptools

Installation Inkycal depuis source

bash
## Clonage et installation
cd ~
git clone —depth 1 https://github.com/aceisace/Inkycal.git
cd Inkycal
pip install -e .

## Vérification installation
python3 -c "import inkycal; print(inkycal.__version__)"

Configuration avancée settings.json

Voici une configuration complète avec modules multiples et optimisations :

json
{
  "model": "waveshare_7_5",
  "update_interval": 900,
  "orientation": 0,
  "info_section": true,
  "calibration_hours": [0, 12],
  "modules": [
    {
      "name": "Clock",
      "config": {
        "size": [400, 80],
        "position": [0, 0],
        "format": "24h",
        "show_seconds": false,
        "font": "Roboto-Bold.ttf"
      }
    },
    {
      "name": "Weather",
      "config": {
        "size": [200, 150],
        "position": [0, 80],
        "api_key": "${OPENWEATHER_API_KEY}",
        "location": "48.8566,2.3522",
        "units": "metric",
        "forecast_days": 3
      }
    },
    {
      "name": "SystemInfo",
      "config": {
        "size": [200, 150],
        "position": [200, 80],
        "show_cpu": true,
        "show_ram": true,
        "show_temp": true,
        "show_disk": true,
        "show_uptime": true
      }
    },
    {
      "name": "Calendar",
      "config": {
        "size": [400, 180],
        "position": [0, 230],
        "ical_urls": [
          "https://calendar.google.com/calendar/ical/.../basic.ics"
        ],
        "max_events": 5,
        "show_location": true
      }
    },
    {
      "name": "Feeds",
      "config": {
        "size": [400, 70],
        "position": [0, 410],
        "feeds": [
          {
            "name": "HackerNews",
            "url": "https://news.ycombinator.com/rss",
            "max_items": 3
          }
        ]
      }
    }
  ]
}

Stockez les secrets dans un fichier séparé :

bash
## ~/.inkycal-env
export OPENWEATHER_API_KEY="your_api_key_here"
export CALENDAR_URL="your_ical_url_here"

Scripts d'automatisation et monitoring

Service systemd avec auto-restart

bash
sudo tee /etc/systemd/system/inkycal.service << 'EOF'
[Unit]
Description=Inkycal E-ink Dashboard
Documentation=https://github.com/aceisace/Inkycal
After=network-online.target time-sync.target
Wants=network-online.target time-sync.target

[Service]
Type=simple
User=pi
Group=pi
WorkingDirectory=/home/pi/Inkycal
Environment=PATH=/home/pi/inkycal-env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Environment=PYTHONPATH=/home/pi/inkycal-env/lib/python3.11/site-packages
Environment=INKYCAL_SETTINGS=/home/pi/Inkycal/settings.json
ExecStartPre=/bin/sleep 30
ExecStart=/home/pi/inkycal-env/bin/python3 -m inkycal
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=60
StartLimitInterval=300
StartLimitBurst=5

## Resource limits
MemoryMax=256M
CPUQuota=50%

## Security hardening
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=read-only
ReadWritePaths=/home/pi/Inkycal /tmp
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable inkycal
sudo systemctl start inkycal

Script de monitoring et alertes

bash
## ~/inkycal-monitor.sh
#!/bin/bash

LOG_FILE="/var/log/inkycal-monitor.log"
ALERT_EMAIL="admin@example.com"

## Check service status
if ! systemctl is-active —quiet inkycal; then
    echo "$(date): ERROR - Inkycal service down" >> $LOG_FILE
    # Optional: send alert
    # echo "Inkycal stopped" | mail -s "Dashboard Alert" $ALERT_EMAIL
    systemctl restart inkycal
fi

## Check display responsiveness (requires custom endpoint)
if [ -f "/tmp/inkycal_last_update" ]; then
    LAST_UPDATE=$(cat /tmp/inkycal_last_update)
    NOW=$(date +%s)
    DIFF=$((NOW - LAST_UPDATE))
    
    if [ $DIFF -gt 3600 ]; then
        echo "$(date): WARNING - No update for ${DIFF}s" >> $LOG_FILE
    fi
fi

## Check system resources
CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}' | cut -d'%' -f1)
TEMP=$(vcgencmd measure_temp | cut -d'=' -f2 | cut -d"'" -f1)

if (( $(echo "$TEMP > 70" | bc -l) )); then
    echo "$(date): WARNING - High temp: ${TEMP}C" >> $LOG_FILE
fi
bash
## Crontab pour monitoring
echo "*/5 * * * * /home/pi/inkycal-monitor.sh" | crontab -

Optimisation énergétique avancée

Undervolting et gestion d'alimentation

bash
## Installation des outils de gestion d'énergie
sudo apt install -y raspi-config powertop

## Configuration du governor CPU
echo 'GOVERNOR="powersave"' | sudo tee /etc/default/cpufrequtils

## Désactivation des périphériques non utilisés dans /boot/config.txt
cat << 'EOF' | sudo tee -a /boot/config.txt

## Power optimization
## Disable Bluetooth
dtoverlay=disable-bt

## Disable Wi-Fi (if using Ethernet)
## dtoverlay=disable-wifi

## Reduce HDMI power (if headless)
hdmi_blanking=2

## Disable audio
dtparam=audio=off

## USB current limit for peripherals
max_usb_current=0

## Disable activity LED
dtparam=act_led_trigger=none
dtparam=act_led_activelow=off

## Disable power LED
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off
EOF

Script de mise en veille profonde entre les mises à jour

bash
## ~/inkycal-sleep.sh (pour batterie uniquement)
#!/bin/bash

INTERVAL=900  # 15 minutes

while true; do
    # Run inkycal update
    source ~/inkycal-env/bin/activate
    cd ~/Inkycal && python3 -m inkycal —run-once
    
    # Sleep until next update
    sleep $INTERVAL
done

Intégrations API avancées

Module personnalisé Home Assistant

python
## ~/Inkycal/inkycal/modules/ha_sensor.py
"""Home Assistant sensor module for Inkycal."""

import requests
from inkycal.modules.base import InkycalModule
from inkycal.custom import top_level

class HomeAssistant(InkycalModule):
    """Fetch and display Home Assistant sensor data."""
    
    name = 'Home Assistant Sensor'
    
    requires = {}
    
    defaults = {
        'size': [400, 100],
        'position': [0, 0],
        'ha_url': 'http://homeassistant.local:8123',
        'ha_token': '',
        'sensors': [],
    }
    
    def __init__(self, config):
        super().__init__(config)
        self.ha_url = config.get('ha_url')
        self.ha_token = config.get('ha_token')
        self.sensors = config.get('sensors', [])
        
    def _fetch_sensor(self, entity_id):
        """Fetch sensor state from Home Assistant API."""
        url = f"{self.ha_url}/api/states/{entity_id}"
        headers = {
            'Authorization': f'Bearer {self.ha_token}',
            'Content-Type': 'application/json'
        }
        try:
            response = requests.get(url, headers=headers, timeout=10)
            response.raise_for_status()
            return response.json()
        except Exception as e:
            return {'state': 'Error', 'attributes': {'friendly_name': entity_id}}
    
    def generate_image(self):
        """Generate image with sensor data."""
        image = self._create_image()
        draw = self._create_draw(image)
        
        y_offset = 10
        for sensor in self.sensors:
            data = self._fetch_sensor(sensor)
            state = data.get('state', 'N/A')
            name = data.get('attributes', {}).get('friendly_name', sensor)
            unit = data.get('attributes', {}).get('unit_of_measurement', '')
            
            text = f"{name}: {state} {unit}"
            draw.text((10, y_offset), text, font=self.font, fill=0)
            y_offset += 25
        
        return image

Troubleshooting et débogage

Logs et diagnostic

bash
## Voir les logs en temps réel
sudo journalctl -u inkycal -f

## Test manuel avec verbose
cd ~/Inkycal && source ~/inkycal-env/bin/activate
python3 -m inkycal —test

## Vérification SPI
ls -la /dev/spi*
## Doit afficher : /dev/spidev0.0 et /dev/spidev0.1

## Test d'affichage direct
python3 << 'PYEOF'
import sys
sys.path.insert(0, '/home/pi/Inkycal')
from inkycal.display import Display
disp = Display('waveshare_7_5')
disp.test_pattern()
PYEOF

Erreurs courantes et solutions

| Erreur | Cause | Solution |

|————|———-|—————|

| "No module named 'inkycal'" | Environnement non activé | source ~/inkycal-env/bin/activate |

| "SPI permission denied" | Utilisateur non dans groupe spi | sudo usermod -aG spi pi puis reboot |

| Écran blanc/noir | Mauvais modèle configuré | Vérifier settings.json model |

| Ghosting | Calendrier manquant | Activer calibration_hours |

| Météo vide | Clé API invalide | Vérifier sur openweathermap.org |

Déploiement et maintenance

Backup et restauration

bash
## Script de backup
#!/bin/bash
BACKUP_DIR="/backup/inkycal-$(date +%Y%m%d)"
mkdir -p $BACKUP_DIR

## Backup configuration
cp ~/Inkycal/settings.json $BACKUP_DIR/
cp -r ~/inkycal-env $BACKUP_DIR/

## Backup systemd service
cp /etc/systemd/system/inkycal.service $BACKUP_DIR/

## Création archive
tar czf ${BACKUP_DIR}.tar.gz $BACKUP_DIR
echo "Backup saved to: ${BACKUP_DIR}.tar.gz"

Mise à jour d'Inkycal

bash
cd ~/Inkycal
git pull origin main
source ~/inkycal-env/bin/activate
pip install -e . —upgrade
sudo systemctl restart inkycal

Votre dashboard e-ink est maintenant opérationnel avec monitoring, hardening et optimisations énergétiques complètes.

Sur le même sujet

À lire aussi

#tutoriel#raspberry-pi#e-ink#inkycal#iot#dashboard