Outils pour utilisateurs

Outils du site


issue109:c_c

I’ve always been a fan of electronics - be it Arduino, full-on computers, or something like a Raspberry Pi. However, I always try to balance out my purchases with actual need - which means I have never owned a Raspberry Pi. Until now. I recently ordered a model 3 off Amazon (in a complete bundle with a case, power supply and heatsinks - the SD card was missing, but as I own many of them, it wasn’t necessary). The intended use for this Raspberry Pi was to connect it to our older Brother MFC-230C printer - which is USB only. There were two reasons for this - firstly, heading to the office to manually connect a USB printer was a pain, and secondly, I wanted some method with which I could enable Google Cloud Print. For those who don’t know - Google Cloud Print is a service that allows printing from android tablets/phones and chromebooks to a printer connected to another computer. The small form-factor, and built-in wireless, in the model 3 made this a terrific way to connect the printer to our LAN – without having to leave a desktop computer or laptop running all the time. The main reason I selected this kit was because this bundle shipped with Amazon Prime – the other bundles had additional shipping costs.

Depuis toujours, je suis passionné d'électronique - qu'il s'agisse d'Arduino, d'ordinateurs ou de quelque chose comme un Raspberry Pi. Cependant, j'essaie toujours de faire mes achats en fonction de mes véritables besoins, ce qui signifie que je n'ai jamais été propriétaire d'un Raspberry Pi. Jusqu'à présent. J'ai récemment commandé un modèle 3 chez Amazon (dans un ensemble avec un boîtier, une alimentation et des refroidisseurs ; il ne manquait que la carte SD, mais puisque j'en ai beaucoup, je n'en avais pas besoin). Je prévoyais d'utiliser le Raspberry Pi en le connectant à notre imprimante vieillissante, uniquement sur USB, une Brother MFC-230C. J'avais deux raisons pour ce faire : d'abord, devoir me déplacer au bureau pour connecter manuellement une imprimante USB m'irritait profondément ; ensuite, je voulais un moyen d'activer Google Cloud Print. Pour ceux qui ne le savent pas, Google Cloud Print est un service qui permet l'impression à partir de tablettes/téléphones Android et de Chromebooks vers une imprimante connectée à un autre ordinateur. Sa petite taille et le WiFi embarqué du modèle 3 le rendaient idéal pour connecter l'imprimante à notre réseau local, sans devoir laisser tourner continuellement un ordinateur de bureau ou un portable.

La principale raison pour laquelle j'ai choisi cet ensemble, était qu'il était disponible avec Amazon Prime et les autres ensembles avaient des frais de port supplémentaires.

What are you covering? I’m going to focus on the setup of the Raspberry Pi (RPi) this month. Once I’ve given myself sufficient time to test out the CUPS setup and Google cloud print, I will follow this article up with those exact steps. What do I need? You’ll need a Raspberry Pi (and an SD card that is >= 4GB), a keyboard, a mouse, and a monitor. The last 3 items you’ll need only for the actual installation of raspbian - everything else can be done via SSH or VNC later. Logically, you’ll also need some device to download and copy the NOOBS installer from the Raspberry Pi website to the SD card. NOOBS installer: https://www.raspberrypi.org/downloads/noobs/ NOTE 1: There is also a manual installer, but I focused on the most typical use-case. NOTE 2: There are torrents as well as direct downloads - but the torrents failed to work in rtorrent. Heatsinks - do I need them? Heatsinks shouldn’t really be necessary at all - most people agree that even under the most extreme conditions, the RPi will be fine without. However, heatsinks may be beneficial for me, as the RPi will probably be operating in a slightly stuffy room, with a high chance of direct sunlight via the window. Heatsinks may help keep the RPi a little cooler in these positions. As the RPi seems to lack any sensors (for use with lm-sensors), I can’t make any temperature comparisons.

De quoi parlez-vous ?

Ce mois-ci, je vais me concentrer sur le paramétrage du Raspberry Pi (RPi). Dès que j'aurai trouvé assez de temps pour tester la configuration de CUPS et de Google Cloud Print, je ferai une suite de cet article pour vous en donner les étapes exactes.

De quoi ai-je besoin ?

Vous aurez besoin d'un Raspberry Pi (et d'une carte SD qui fait au moins 4 Go), un clavier, une souris et un écran. Les trois derniers ne sont nécessaires que pour l'installation de raspbian, tout le reste peut être fait via SSH ou VNC plus tard. Comme de bien entendu, vous aurez besoin aussi d'un dispositif avec lequel télécharger et copier l'installeur NOOBS du site Web de Raspberry Pi vers la carte SD.

Installeur NOOBS : https://www.raspberrypi.org/downloads/noobs/

NOTA 1 : Un installeur manuel existe aussi, mais j'ai mis l'emphase sur le cas d'utilisation le plus typique.

NOTA 2 : Outre des téléchargements directs, il y a des torrents, mais ils n'ont pas fonctionné dans rtorrent.

Les refroidisseurs, sont-ils nécessaires ?

On ne devrait pas avoir besoin de refroidisseurs, car la plupart des gens pensent que, même dans des conditions les plus extrêmes, le RPi sera très bien sans. Cependant, des refroidisseurs peuvent éventuellement m'être bénéfiques, car le RPi sera placé sans doute dans une pièce qui peut être un peu suffocante, avec une fenêtre sur laquelle le soleil tape directement. Les refroidisseurs peuvent aider le RPi à rester plus frais dans cet emplacement. Puisque le RPi semble manquer de capteurs (à utiliser avec des lm-sensors), je ne peux pas faire de comparaisons de température.

Step 0: Assembly & Prep I can’t offer exact instructions here, as it all depends on your case (or lack thereof). It shouldn’t be a difficult process. For the SD card, the official site recommends a tool for Windows or Mac. But if you’d rather do it by hand, the SD card just seems to need to be FAT32 (should be the standard for any size less than and including 32GB), or FAT16. Unfortunately, any SD card that is > 32GB will be exFAT by default. In any case, I recommend reformatting just to be safe. After that, copy all the extracted files from the archive onto the SD card. Eject it, and insert it into the underside of your RPi.

Étape 0 : Assemblage et préparatifs

Je ne peux pas vous proposer des instructions précises ici, car tout dépend de votre propre boîtier (ou de son absence). Cela ne devrait pas être difficile.

Pour ce qui concerne la carte SD, le site officiel recommande un outil pour Windows ou Mac. Mais si vous préférez le faire à la main, la carte SD devra vraisemblablement être formatée en FAT32 (ce qui est la norme pour toute taille jusqu'à 32 Go), ou FAT16. Malheureusement, par défaut, une carte qui fait plus de 32 Go sera exFAT. De toute façon, je recommande de la reformater juste au cas où. Après cela, copiez tous les fichiers extraits de l'archive vers la carte SD. Éjectez-la et insérez-la dans le dessous du RPi.

Step 1: Installation Once the case is set up, and the SD card ready, you’ll want to connect your peripherals, and then boot the device (by plugging in the power supply). The RPi will then boot to a very basic screen. You can either connect to the internet and download/install something other than Raspbian - or just select Raspbian and choose “Install” (Recommended). I’ve used Raspbian for this project. After that, you’ll need to just wait out the installation. Step 2: Booted up - now what? The first thing I did was connect my wireless, and tried to set a static IP (as my router doesn’t allow reserving IP addresses). The GUI tool seems to just add an entry into /etc/dhcpcd.conf with ssid information. This does seem to work - but resulted in the issue that the static IP was used for whatever interface came up first - so if I was using ethernet, it was used there instead (which shouldn’t be the case as it lacks an SSID). In order to solve this (as I want ethernet to run via DHCP - that way I can connect it directly to a laptop for debugging), I simply added the following line directly above the ssid line: Interface wlan0

Étape 1 : Installation

Une fois le boîtier configuré et la carte SD prête, vous devez connecter les périphériques, puis démarrer le dispositif (en branchant l'alimentation).

Le RPi démarrera sur un écran très basique. Vous pouvez, soit vous connecter au Net et télécharger/installer quelque chose d'autre que Raspbian, soit tout simplement sélectionner Raspbian et choisir « Install » (recommandé). J'utilise Raspbian pour ce projet. Après cela, il faut attendre que l'installation se fasse.

Étape 2 : Il a redémarré - et maintenant ?

La première chose que j'ai faite était de connecter mon WiFi et essayer de paramétrer une adresse IP statique (puisque mon routeur ne permet pas la réservation d'adresses). L'outil à interface graphique semble se contenter d'ajouter une entrée dans /etc/dhcpcd.conf contenant des informations ssid. Cela semble fonctionner, mais avec un problème : l'IP statique fut utilisée pour la première interface qui se présentait, quelle qu'elle soit. Ainsi, si j'utilisais l'Éthernet, l'adresse lui fut attribuée (ce qui ne devrait pas arriver, car il n'a pas de SSID). Afin de résoudre ceci (puisque je veux que l'Éthernet tourne via DHCP, car, ainsi, je peux le connecter directement à un ordinateur portable pour le déboguer), j'ai tout simplement ajouté la ligne suivante juste au-dessus de la ligne ssid :

Interface wlan0

This tells dhcpcd to apply the following settings only for the wireless interface - so ethernet runs normally on DHCP, and my wireless will use the static IP I chose when connected to my home network. Other wireless networks should default back to DHCP (so you’ll never run into the issue that the RPi is assuming the wrong subnet). I have yet to test the RPi with another wireless network. Once you have your IP reserved in your router, or statically assigned by the RPi, you’re ready to disconnect your keyboard/mouse/monitor, and switch to SSH (if you prefer). I’ll also cover installing tightvnc and using that, so you have access to the GUI apps. Step 2.1: TightVNC TightVNC is a VNC (Virtual Network Computing) client that is offered in the Raspbian repos. To install it just run: sudo apt-get install tightvncserver Once it’s installed, simply start it by running the command: tightvncserver This should result in some information in the terminal, telling you there is a new ‘X’ desktop. To save resources, I recommend killing the X session on :0, with: service lightdm stop

Cela indique au dhcpcd d'appliquer les paramètres suivants uniquement à l'interface sans fil. Ainsi, l'Éthernet tourne normalement sur DHCP et mon WiFi utilise l'IP statique choisie quand j'étais connecté à mon réseau domestique. D'autres réseaux sans fil devraient retourner à DHCP par défaut (afin que le problème du RPi, qui pourrait supposer un mauvais sous-réseau, soit complètement éliminé). Je n'ai pas encore testé le RPi avec un autre réseau sans fil.

Une fois l'IP réservée dans votre routeur, ou assignée statiquement par le RPi, le moment est venu de déconnecter le clavier/souris/écran et de basculer sur SSH (si c'est ce que vous préférez). Je vais parler également de l'installation et l'utilisation de tightvnc pour vous donner accès aux applis à interface graphique.

Étape 2.1 : TightVNC

TightVNC est un client VNC (Virtual Network Computing, informatique virtuelle en réseau) proposé dans les dépôts Raspbian. Pour l'installer, il suffit de lancer :

sudo apt-get install tightvncserver

Une fois l'installation terminée, démarrez-le tout simplement avec la commande :

tightvncserver

Vous devrez maintenant voir des informations dans le terminal vous disant qu'il y a un nouveau bureau « X ». Dans un but d'économie de ressources, je recommande d'arrêter la session X sur :0 avec :

service lightdm stop

Step 2.1.1: Connecting If you use vncviewer on a Linux machine, just using the IP followed by the display number, you’ll be fine. Such as 192.168.0.15:1. If you’re trying to connect using OS X’s integrated screen sharing application, it will need to be a port - 5900 = :0, 5901 = :1, etc. So 192.168.0.15:5901 would work there. I haven’t tested a connection on Windows, but one of the two options above should work. If you set a password, keep in mind that RPi truncates passwords to 8 characters - so if a password isn’t working, make sure it’s not too long - and if it is, just stop typing it after 8 characters. Step 2.2: Autostart I used the Raspberry Pi Configuration tool to boot automatically into the CLI - as I only need SSH access, and the occasional VNC call. If you want to automatically start a VNC session, I would recommend looking at the official documentation: https://www.raspberrypi.org/documentation/remote-access/vnc/

Étape 2.1.1 : Se connecter

Si vous vous servez de vncviewer sur une machine Linux, il suffit d'utiliser l'adresse IP suivie du numéro de l'affichage et tout devrait bien se passer. Par exemple 192.168.0.15:1. Si vous essayez de vous connecter avec l'application de partage d'écran intégrée dans OS X, vous devrez mettre un port - 5900 = :0, 5901 = :1, etc. Ainsi 192.168.0.15:5901 fonctionnerait dans ce cas. Je n'ai pas encore testé une connexion sur Windows, mais l'une des deux possibilités ci-dessus devrait fonctionner.

Si vous configurez un mot de passe, gardez à l'esprit que RPi les réduit à 8 caractères. Ainsi, si un mot de passe ne fonctionne pas, assurez-vous qu'il ne soit pas trop long et, si c'est le cas, il suffit d'arrêter sa saisie après avoir tapé les 8 premiers caractères.

Étape 2.2 : Autostart

J'ai utilisé l'outil de configuration Raspberry Pi pour démarrer automatiquement sur le CLI, car je n'ai besoin que d'un accès SSH et l'appel sur VNC de temps en temps.

Si vous voulez démarrer une session VNC automatiquement, je vous recommande de consulter la documentation officielle :

https://www.raspberrypi.org/documentation/remote-access/vnc/

Step 3: Applications Depending on what you want to do with the RPi, you may need to install other packages. In my case, I need to install the packages chromium-inspector (chromium browser - required for Cloud Print), and cups (for sharing the printer normally). There are various articles out there for exact steps, so here are just a list of a few things people may want to install/enable: • Bittorrent Sync (for sharing files). • Bluetooth (requires various packages - such as bluez bluez-hcidump, bluez-tools, blueman, etc). As this depends on whether you want GUI tools or not, I’d recommend following a guide that installs just what you need. • LAMP - for running a web server. • Docker - I’m not sure how well Docker would run on an RPi, but of the virtualization options I can think of, it would probably offer the best performance. • Samba (for using the RPi to share a USB hard drive on the network).

Étape 3 : Applications

Selon ce que vous voulez faire avec le RPi, vous aurez éventuellement besoin d'installer d'autres paquets. Dans mon cas, je dois installer les paquets chromium-inspector (navigateur chromium, nécessaire pour Cloud Print) et CUPS (pour partager l'imprimante normalement).

Divers articles fournissant les étapes exactes existent ; voici donc une liste de quelques trucs que des gens peuvent vouloir installer/activer : • Bittorrent Sync (pour le partage de fichiers). • Bluetooth (nécessite divers paquets tels que bluez, bluez-hcidump, bluez-tools, blueman, etc.). Puisque cela dépend de votre souhait concernant des outils à interface graphique, je recommande de suivre un guide qui installe exactement ce dont vous avez besoin. • LAMP - pour exécuter un serveur Web. • Docker - je ne sais pas du tout si Docker peut bien tourner sur un RPi, mais parmi les options de virtualisation que je connais, il donnerait sans doute les meilleures performances. • Samba (pour utiliser le RPi afin de partager un disque dur USB sur le réseau).

Step 4: Debugging If, for some reason, your RPi isn’t working properly, you have two options: • Connect a monitor, keyboard, mouse and/or ethernet connection. • Use SSH or VNC to debug issues. Naturally, the first option can be difficult to achieve, depending on where you are, and where the RPi is set up. However, it is by far the least complicated to actually implement. For option 2: It’s not going to be an issue as long as your RPi is actually connected to a network, and you know the IP (if it isn’t on a static IP you assigned, check your router, as it may have picked up a fallback DHCP IP). If you can find the IP, then you shouldn’t have any other issues connecting via SSH or VNC. If, however, the RPi isn’t connected to the network (because it’s a new wireless network, for example), then you’ll typically need to connect it via ethernet, or use a monitor, keyboard, and mouse to connect to the new network. If you’re lazy and want to make life easier for you - you can simply set up a DHCP server on your laptop (on both Windows and Linux you’ll need to install and set up some form of DHCP server, but OS X offers that option by default under System Preferences → Sharing → Internet Sharing). After the DHCP server is running, you can just connect an ethernet cable to the RPi from your laptop, and then start the RPi (it may work on an already running system, but I have tested it only from an off state). From your laptop, you should be able to get a list of clients and their IPs - this depends on the server and OS you’re using. Once you get the IP of the client, you can just connect via SSH or VNC, and work from there. That about wraps it up for this month. If you have any issues, or questions, feel free to email me at lswest34+fcm@gmail.com. The same is true for anyone who has suggestions or requests for articles - ideas are always welcome!

Étape 4 : Débogage

Si, pour une raison quelconque, votre RPi ne fonctionne pas comme il faut, vous avez deux possibilités : • Connecter un écran, clavier souris et/ou une connexion Éthernet. • Utiliser SSH ou VNC pour corriger les problèmes.

L'implémentation de la première option peut se révéler difficile, selon où vous vous trouvez et l'emplacement du RPi. Toutefois, c'est le moins compliqué à mettre en œuvre, et de loin.

Pour ce qui concerne l'option 2 : ce ne sera pas un problème du moment où votre RPi est connecté à un réseau et que vous connaissez l'IP (s'il n'est pas sur une adresse IP statique que vous avez assignée, vérifiez votre routeur, car il a pu récupérer une IP DHCP de secours). Si vous arrivez à trouver l'IP, vous ne devrez pas avoir d'autres problèmes pour vous connecter via SSH ou VNC.

Si, cependant, le RPi n'est pas connecté au réseau (notamment parce qu'il s'agit d'un nouveau réseau WiFi), vous devrez généralement le connecter via l'Éthernet, ou utiliser un écran, clavier et souris pour le connecter au nouveau réseau. Si vous êtes paresseux et cherchez une solution de facilité, vous pouvez tout simplement configurer un serveur DHCP sur votre ordinateur portable (sur Windows et Linux, vous devez installer un serveur DHCP quelconque, mais OS X propose cette option par défaut sous System Preferences → Sharing → Internet Sharing). Une fois le serveur DHCP démarré, vous pouvez tout simplement connecter un câble Éthernet de votre portable au RPi, puis démarrer le RPi (cela fonctionnera peut-être sur un système qui est déjà démarré, mais je ne l'ai testé que sur un système éteint, puis démarré). À partir de votre portable, vous devrez pouvoir récupérer une liste de clients et leur adresse IP, selon le serveur et l'OS que vous utilisez. Une fois l'IP du client récupérée, il suffit de vous connecter via SSH ou VNC, puis de commencer à travailler.

C'est tout pour ce mois-ci. Si vous avez des problèmes ou des questions, n'hésitez pas à m'envoyer un courriel à lswest34+fcm@gmail.com. Faites la même chose si vous avez des suggestions ou des demandes d'articles, de nouvelles idées sont toujours les bienvenues.

issue109/c_c.txt · Dernière modification : 2016/06/16 12:20 de andre_domenech