======Raspberry Pi Configurations complémentaires====== ===== Réseau ethernet et wifi ===== La configuration des adaptateurs réseau se passe dans le fichier /etc/network/interfaces, il est possible d'éditer ce fichier sur son ordinateur avant d'insérer la carte SD dans la raspberry\\ Voici des exemples de config (quand il y a un # en début de ligne, la ligne est commentée) sudo nano /etc/network/interfaces  # The loopback interface  auto lo  iface lo inet loopback  auto eth0  ### Pour IP Dynamique sur eth0  # iface eth0 inet dhcp  ### Pour IP Statique sur eth0  iface eth0 inet static  #your static IP  address 192.168.1.118    #your gateway IP  gateway 192.168.1.1  netmask 255.255.255.0  #your network address "family"  network 192.168.1.0  broadcast 192.168.1.255 relancer le réseau (si vous êtes loggué sur la Pi) sudo /etc/init.d/networking restart ===== WiFi WPA ===== Testé avec une clef **TL-WN722N**. Un... lsusb donne... Bus 001 Device 004: ID 0cf3:9271 Atheros Communications, Inc. AR9271 802.11n si la carte est reconnue. Pour scanner les SSID: sudo iwlist wlan0 scan | grep ESSID Editer **wpa-supplicant.conf** sudo nano /etc/wpa_supplicant/wpa_supplicant.conf avec ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 # ap_scan=1 network={    ssid="NOM_RESEAU" # à renseigner #    scan_ssid=1 # nécessaire quand le ssid n'est pas diffusé    proto=RSN    key_mgmt=WPA-PSK    pairwise=CCMP TKIP    group=CCMP TKIP    psk="PASSWORD" # à renseigner } ===== Permettre l'utilisation de la sortie HDMI + Identifier l'écran ===== ==== Identifier les modes et fréquences supportées par l'écran ==== HDMI a 2 groupes : CEA (Consumer Electronics Association, utilisé pour les TVs) et DMT (Display Monitor Timings, utilisé par les moniteurs). Chaque groupe a sa définition des modes, pour les connaître, utiliser tvservice : tvservice -s state 0xa [HDMI CEA (16) RGB lim 16:9], 1920x1080 @ 60.00Hz, progressive tvservice -m CEA tvservice -m DMT Il faut ensuite entrer le mode désiré dans le fichier config/txt (voir ci-dessous) * Tout savoir sur la [[https://www.raspberrypi.org/documentation/configuration/hdmi-config.md|configuration du HDMI]] ==== Modifier la configuration d'affichage ==== Il faut éditer le fichier/boot/config.txt : sudo nano /boot/config.txt hdmi_force_hotplug=1 // si difficulté au branchement hdmi_group=1 // pour (CEA) hdmi_mode=5 // 1080p * La [[https://www.raspberrypi.org/documentation/configuration/config-txt/video.md|configuration vidéo]] ==== Rotation de l'écran ==== Avec interface graphique, via utilitaire Screen Configuration Utility ou en ligne de commande xrandr --output HDMI-1 --rotate normal xrandr --output HDMI-1 --rotate left xrandr --output HDMI-1 --rotate right xrandr --output HDMI-1 --rotate inverted Avec Legacy graphics driver (default on models prior to the Pi4) Dans le fichier config.txt display_hdmi_rotate=0 // pas de rotation display_hdmi_rotate=1 // 90 degré * La [[https://www.raspberrypi.org/documentation/configuration/display_rotation.md|page sur la rotation]] ==== Supprimer les bordures noires ==== Voir le paramètre overscan / underscan dans les propriétés d'affichage de raspi-config ==== Supprimer les logos à l'affichage ==== ajouter en fin de ligne sudo nano /boot/cmdline.txt logo.nologo ===== Installer le son ===== * Cartes son supportées : * [[http://www.raspyfi.com/raspberry-pi-usb-dac-and-raspyfi-supported-dacs/|Supported Dacs]] * [[http://elinux.org/RPi_VerifiedPeripherals#USB_Sound_Cards|USB Sound Cards]] * [[https://www.behringer.com/Categories/Behringer/Computer-Audio/Interfaces/UCA202/p/P0484|Behringer U-Control UCA 202]] cat /proc/asound/cards en cas d'utilisation d'une carte son USB, de créer un fichier .asoundrc dans le home/user avec le contenu suivant : pcm.!default { type hw card 1 } ctl.!default { type hw card 1 Pour forcer l'ordre des cartes, il faut éditer le fichier alsa-base.conf: sudo nano /etc/modprobe.d/alsa-base.conf Ajoutez les 2 lignes décommentées : # Keep snd-usb-audio from beeing loaded as first soundcard options snd-usb-audio index=0 options snd_bcm2835 index=1 Après, le redémarrage la carte USB sera utilisée par défaut * Pas nécessaire avec Occidentalis : [[http://www.pobot.org/Activer-le-son-sur-Raspberry-Pi.html|Activer le son sur Raspberry Pi]] # audio sur le jack $ sudo amixer cset numid=3 1 # audio sur le HDMI $ sudo amixer cset numid=3 2 # commutation automatique $ sudo amixer cset numid=3 0 ===== Installer un bureau après une installation stretch Lite ===== sudo apt-get install --no-install-recommends xserver-xorg sudo apt-get install --no-install-recommends xinit sudo apt-get install raspberrypi-ui-mods sudo apt-get install lightdm ===== Serveur X déporté avec ssh ===== ssh -X 192.168.1.69 -l pi ===== Installer un VNC ===== [[http://www.pommehappy.fr/2016/04/03/partage-de-fichiers-decran-entre-raspberry-mac/|Partage de fichiers et d’écran entre Raspberry et un Mac]] ==== Installation de tightvncserver ==== Installer la partie serveur sur la RasPi : sudo apt-get install tightvncserver Puis lancer la commande suivante (par exemple) pour lancer le serveur et le configurer : vncserver :1 -geometry 1366x600 -depth 16 -pixelformat rgb565 Installer la partie client sur l'ordi qui affichera la session : sudo apt-get install xtightvncviewer Puis le lancer : xtightvncviewer 10.0.0.141:1 Zou... ==== Installation de x11vnc ==== Configurer la sortie HDMI de manière idoine en modifiant le fichier config.txt : sudo nano /boot/config.txt Le modifier comme suit : # uncomment if hdmi display is not detected and composite is being output hdmi_force_hotplug=1 \\ # uncomment to force a specific HDMI mode (this will force VGA) hdmi_group=2 hdmi_mode=16 et redémarrer la Pi pour que les changements soient pris en compte. Installer la partie serveur sur la RasPi : sudo apt-get install x11vnc Initialisation du mot de passe : sudo x11vnc -storepasswd MotDePasse /etc/x11vnc.pass Création d'un fichier de configuration : sudo nano /lib/systemd/system/x11vnc.service Dans ce fichier taper : [Unit] Description="x11vnc" Requires=display-manager.service After=display-manager.service \\ [Service] ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass ExecStop=/usr/bin/killall x11vnc Restart=on-failure Restart-sec=2 \\ [Install] WantedBy=multi-user.target Ensuite vous pouvez démarrer le serveur sudo systemctl daemon-reload sudo systemctl start x11vnc Pour qu'il démarre dès le démarrage de la Pi : sudo systemctl enable x11vnc ==== Installer dispmanx_vnc ==== [[https://discourse.osmc.tv/t/howto-install-a-vnc-server-on-the-raspberry-pi/1517|[HowTo] Install a vnc server on the Raspberry pi]] ===== FTP ===== À partir du moment où le SSH est activé, il est possible d'avoir accès au contenu de la RasPi en SFTP (moyennant l'IP, l'identifiant et le mot de passe de la Pi) Avec Filezilla, par exemple, ces infos suffisent pour pour avoir une connexion SFTP opérationnelle : {{media_12:sftp-raspberry.png|sftp-raspberry.png sftp-raspberry.png}} ===== Lancement d'une vidéo en boucle en plein écran après démarrage avec omxplayer sur RaspiOS Pi4 ===== Installer omxplayer sudo apt update sudo apt install omxplayer Mettre la video mavideo.mp4 sur le bureau Créer un fichier texte videoplayer.sh sur le bureau, l'ouvrir avec un éditeur de texte et y copier-coller le code ci-dessous : #/bin/bash while true; do cd /home/pi/Desktop omxplayer -o hdmi -b --loop mavideo.mp4 sleep 1 done Rendre ce fichier exécutable en ouvrant un terminal : cd Desktop chmod +x videoplayer.sh Toujours dans le terminal, on va éditer un fichier système pour réaliser le lancement automatique et désactiver la veille sudo nano /etc/xdg/lxsession/LXDE-pi/autostart Aller tout en bas du fichier avec flèche du bas, y coller le code ci-dessous : @lxpanel --profile LXDE @pcmanfm --desktop --profile LXDE @xset s off @xset -dpms @xset s noblank @lxterminal --command "/home/pi/Desktop/videoplayer.sh" @xscreensaver -no-splash@ Pour enregistrer et sortir de l'éditeur nano : CTRL-x, y and then ENTER Redémarrer et vérifier que cela marche Note : la vidéo doit être encodée en mp4 idéalement à la taille de l'écran, [[https://www.raspberrypi.org/documentation/raspbian/applications/omxplayer.md|il existe des réglages complémentaires pour omxplayer]] ===== Autlogin et lancement de script automatique ===== * [[http://elinux.org/RPi_Debian_Auto_Login|RPi Debian Auto Login]] In Terminal: sudo nano /etc/inittab Scroll down to: 1:2345:respawn:/sbin/getty 115200 tty1 and change to #1:2345:respawn:/sbin/getty 115200 tty1 Under that line add: 1:2345:respawn:/bin/login -f pi tty1  /dev/tty1 2>&1 Ctrl+X to exit, Y to save followed by enter twice How to automatically run a script after login. Step 1: Open a terminal session and edit the file /etc/profile sudo nano /etc/profile Step 2: Add the following line to the end of the file . /home/pi/your_script_name.sh replace the script name and path with correct name and path of your start-up script. Step 3: Save and Exit Press Ctrl+X to exit nano editor followed by Y to save the file. **Possibilité de lancer un script une fois le serveur X lancé** en créant un fichier .xinitrc dans le home ===== Webcam ===== * [[http://www.handsdown.be/raspicam/index.html|Les commandes raspicam]] * [[http://antonsmindstorms.blogspot.nl/2014/12/realtime-video-stream-with-raspberry-pi.html|Streaming avec raspicam]] ===== Webcam Ps3 eye ===== ==== Configuration de l'audio ==== * test sortie audio speaker-test -c 2 * Test et reconnaissance de la camera arecord -l * enregistrement de 10 secondes de son via les micro de la webcam arecord -d 10 -D plughw:1,0 prout.wav * lecture du fichier son aplay proute.wav ressources : [[http://renatocunha.com/blog/2012/04/playstation-eye-audio-linux/#fn:2\|Making the Playstation Eye’s microphones work on Linux]] [[http://iwearshorts.com/blog/raspberry-pi-setting-up-your-audio/\|Raspberry Pi – Setting Up Your Audio]] [[http://mutsuda.com/2012/09/07/raspberry-pi-into-an-audio-spying-device/\|Raspberry Pi into an audio spying device]] [[http://www.pobot.org/Son-et-image-avec-la-Sony-PS3-Eye.html?lang=fr\|Son et image avec la Sony PS3 Eye]] ===== Install un écran TFT touchscreen ===== sudo nano /boot/cmdline.txt  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo sudo nano /boot/config.txt #uncomment to overclock the arm. 700 MHz is the default. #arm_freq=800 # Uncomment some or all of these to enable the optional hardware interfaces #dtparam=i2c_arm=on #dtparam=i2s=on #dtparam=spi=on # Uncomment this to enable the lirc-rpi module #dtoverlay=lirc-rpi # Additional overlays and parameters are documented /boot/overlays/README ### touchscreen parameters start_x=1 gpu_mem=128 core_freq=250 sdram_freq=400 over_voltage=0 dtparam=spi=on dtparam=i2c_arm=on dtoverlay=w1-gpio-pullup,gpiopin=4,extpullup=1 Modifier le fichier /etc/modules # /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. # Parameters can be specified after the module name. snd-bcm2835 i2c-bcm2708 i2c-dev flexfb width=320 height=480 regwidth=16 init=-1,0xb0,0x0,-1,0x11,-2,250,-1,0x3A,0x55,-1,0xC2,0x44,-1,0xC5,0x00,0x00,0x00,0x00,-1,0xE0,0x0F,0x1F,0x1C,0x0C,0x0F,0x08,0x48,0x98,0x37,0x0A,0x$ fbtft_device debug=3 rotate=90 name=flexfb speed=16000000 gpios=reset:25,dc:24 ads7846_device model=7846 cs=1 gpio_pendown=17 keep_vref_on=1 swap_xy=0 pressure_max=255 x_plate_ohms=60 x_min=200 x_max=3900 y_min=200 y_max=3900 **Pour le Touchscreen**, il faut installer un module complémentaire et recompiler le noyau, ou utiliser un noyau custom en suivant les instructions [[http://newscentral.exsees.com/item/e456459d879e22822b972ae69412f9bb-1d47a4b42edb41980bf1f8a79ea404d4|là]] ===== Gérer les langues ===== sudo dpkg-reconfigure locales ===== Désactiver la veille moniteur et systeme ===== * [[http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=35054|How to disable power saving ?]] * [[http://www.raspberrypi.org/phpBB3/viewtopic.php?f=65&t=18692|Désactivé la veille de l'écran]] ou d'après [[http://www.framboise314.fr/raspbian-tout-un-tas-de-trucs/#Demarrer_le_Raspberry_Pi_sur_une_page_web_en_plein_ecran|Démarrer le Raspberry Pi sur une page web en plein écran]]  nano .config/lxsession/LXDE-pi/autostart #@lxpanel --profile LXDE-pi #@pcmanfm --desktop --profile LXDE-pi #@xscreensaver -no-splash @xset s off @xset -dpms @xset s noblank éviter la mise en veille de façon bourrin : toutes les 4 minutes crontab -e */5 * * * * xset s active ===== Récupérer une partition après une extinction sauvage ===== sudo fsck.ext4 -cDfty -C 0 /dev/sdb2 à faire 2 fois ... ===== Ajouter un bouton pour extinction propre ===== Si on débranche une raspberry alors qu'elle est en train d'écrire sur la carte SD, possibilité de corruption du système de fichier, il est donc bon de rajouter un bouton physique pour éteindre proprement la bête lorsqu'on l'utilise sans écran/clavier * [[http://www.instructables.com/id/Simple-Raspberry-Pi-Shutdown-Button/?ALLSTEPS|Simple Raspberry Pi Shutdown Button]] * [[http://elinux.org/RPi_Low-level_peripherals|Voir les GPIO]] Créer le script on-off-button.py #!/bin/python #This script was authored by AndrewH7 and belongs to him (www.instructables.com/member/AndrewH7) #You have permission to modify and use this script only for your own personal usage #You do not have permission to redistribute this script as your own work #Use this script at your own risk import RPi.GPIO as GPIO import os gpio_pin_number=YOUR_CHOSEN_GPIO_NUMBER_HERE #Replace YOUR_CHOSEN_GPIO_NUMBER_HERE with the GPIO pin number you wish to use #Make sure you know which rapsberry pi revision you are using first #The line should look something like this e.g. "gpio_pin_number=7" GPIO.setmode(GPIO.BCM) #Use BCM pin numbering (i.e. the GPIO number, not pin number) #WARNING: this will change between Pi versions #Check yours first and adjust accordingly GPIO.setup(gpio_pin_number, GPIO.IN, pull_up_down=GPIO.PUD_UP) #It's very important the pin is an input to avoid short-circuits #The pull-up resistor means the pin is high by default try: GPIO.wait_for_edge(gpio_pin_number, GPIO.FALLING) #Use falling edge detection to see if pin is pulled #low to avoid repeated polling os.system("sudo shutdown -h now") #Send command to system to shutdown except: pass GPIO.cleanup() #Revert all GPIO pins to their normal states (i.e. input = safe) Rendre le script exécutable : chmod +x on-off-button.py Le lancer au démarrage : sudo nano /etc/rc.local ajouter la ligne : python on-off-button.py & Une autre [[https://www.firediy.fr/article/alimenter-une-raspberrypi-comme-un-pc|alternative]] que l'on pourra tester. On peut aussi ajouter des composants de protection comme dans cette [[https://www.youtube.com/watch?v=TKSIDOsrpsQ|vidéo]]. ===== Augmenter le durée de vie des cartes SD ===== * [[https://www.jeedom.com/forum/viewtopic.php?f=23&t=16563|Soulagez la SD du RPi: partitions en mémoire vive]] * [[https://www.jeedom.com/forum/viewtopic.php?f=23&t=10102|Déplacement de la partition linux (rpi/jeedomboard)]] * [[https://www.jeedom.com/forum/viewtopic.php?f=66&t=8440&p=184190#p184190|Autre méthode déplacement sur disque]] ===== Mettre Raspbian en read only pour préserver des crashs de carte SD ===== Voir la page [[micro_ordinateur#mise_en_place_d_une_raspberrypi_robuste|Micro Ordinateur mise_en_place_d_une_raspberrypi_robuste]] * [[https://www.raspberrypi.org/forums/viewtopic.php?t=161416|Raspbian with Read-only Root]] ===== Améliorer la réactivité d'un écran tactile ===== Ecran iiyama tactile initialement : add usbhid.mousepoll=0 to /boot/cmdline.txt in the same line separated from the other stuff by spaces ===== Installer Java 8 ===== [[https://www.raspinews.com/installing-oracle-java-jdk-8-on-raspberry-pi/|Installing Oracle Java JDK 8 on Raspberry Pi]] ===== Installer PiKISS pour avoir des configurations complémentaires faciles ===== [[https://github.com/jmcerrejon/PiKISS|PiKISS]] (Pi Keeping It Simple, Stupid!) are scripts (Bash) for Raspberry Pi 4 boards which has a menu that will allow you to install some applications or configure files automatically as easy as possible. ===== Booter la pi sur une clef ou un disque dur USB ===== * Voir [[https://raspberry-pi.fr/boot-raspberry-pi-usb/|cette documentation]] pour utiliser une pi sans carte SD //À noter, pour la Raspberry Pi 3B+, vous n’avez pas besoin d’effectuer les opérations ci-dessous, simplement d’installer Raspbian sur votre périphérique USB, l’inséré dans la Pi sans la carte MicroSD, il sera détecté automatiquement. A voir si ce système a été implanté sur la Pi 4// Installer Raspbian sur votre carte SD. Pour cela, nous vous renvoyons à notre article pour installer Raspbian depuis Windows, ou depuis Linux. Raspbian installé sur votre carte microSD, répétez l’opération en installant cette fois-ci Raspbian sur votre clef USB/disque dur. Une fois fini, débranchez la clef USB/disque dur. Une fois les deux installations terminées, connectez la carte SD à votre PC et rendez vous dans la partition boot de la carte (la seule accessible depuis Windows, normalement) pour éditer le fichier config.txt et rajouter à la fin du fichier la ligne suivante : program_usb_boot_mode=1 Sauvegardez le fichier, puis insérez la carte micro SD dans votre Raspberry Pi et démarrez la (insérez seulement la carte SD, pas la clef USB/disque dur). Normalement une fois démarrée, la Raspberry Pi va automatiquement se configurer pour à l’avenir démarrer sur la clé USB. Pour vérifier que tout est bon, on peut regarder le registre 17 de l’OPT (One-Time programmable qui désigne la mémoire morte qui ne peut être programmée qu’une seule fois). Pour cela on utilise la commande suivante : vcgencmd otp_dump | grep 17 La Raspberry Pi doit nous retourner : 17:3020000a. Si ce n’est pas le cas, c’est que vous avez mal effectué une étape précédente et que vous devez recommencer la création de la carte. Vous pouvez maintenant éteindre votre Raspberry Pi, sortir votre carte micro SD et insérer votre clef USB/disque dur avec Raspbian installé. ===== Raspberry Pi démarrage automatique d'un service via systemd et l'affichage graphique ===== Faire le script bash de démarrage en intégrant la variable d'environnement graphique : si pi@raspberrypi:~ $ echo $DISPLAY :0 Alors le script peut ressembler à ça : #!/bin/bash cd /home/pi/Desktop/Telephones-interactifs python relay.py sleep 10 export DISPLAY=:0 pd -alsa -audiobuf 122 -noadc -audiooutdev 2 /home/pi/Desktop/Telephones-interactifs/telephones01.pd exit 0 Il faut bien attendre le démarrage de l'interface graphique d'où le sleep 10 sinon ça croute .... Il faut alors créer un service avec un fichier de ce type nano /etc/systemd/system/telephone.service [Unit] Description=Lance le compte à rebours des téléphones et la lecture audio des défis [Service] Type=simple WorkingDirectory=/home/pi/Desktop/Telephones-interactifs ExecStart=/home/pi/Desktop/Telephones-interactifs/./startTelephone.sh Restart=on-failure RestartSec=1 User=pi Group=pi [Install] WantedBy=multi-user.target Puis lancer les commandes au démarrage pour l'activer : sudo systemctl enable telephone.service sudo systemctl status telephone.service {{tag>sylvain bj micro_ordinateur raspberry_pi}}