Outils pour utilisateurs

Outils du site


raspberry_pi_configurations_complementaires

Ceci est une ancienne révision du document !


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

Il faut éditer le fichier/boot/config.txt :

sudo nano /boot/config.txt

Il suffit de décommenter les deux lignes suivantes

hdmi_force_hotplug=1
hdmi_drive=2 // Configue

Installer le son

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

# 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

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

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 :

sftp-raspberry.png sftp-raspberry.png

Autlogin et lancement de script automatique

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 <html></dev/tty1 ></html>  /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

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
http://iwearshorts.com/blog/raspberry-pi-setting-up-your-audio/
http://mutsuda.com/2012/09/07/raspberry-pi-into-an-audio-spying-device/
http://www.pobot.org/Son-et-image-avec-la-Sony-PS3-Eye.html?lang=fr

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 là : http://newscentral.exsees.com/item/e456459d879e22822b972ae69412f9bb-1d47a4b42edb41980bf1f8a79ea404d4

Gérer les langues

sudo dpkg-reconfigure locales

Désactiver la veille moniteur et systeme

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

 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

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

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 &

Augmenter le durée de vie des cartes SD

Mettre Raspbian en read only pour préserver des crashs de carte SD

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

raspberry_pi_configurations_complementaires.1558476025.txt.gz · Dernière modification : 2019/05/21 22:00 de Mushussu