User Tools

Site Tools


rocnet:headless-cam-en

Differences

This shows you the differences between two versions of the page.


rocnet:headless-cam-en [2022/06/17 09:42] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +======Headless Setup======
 +[[:english#rocview|{{  :viewer.png}}]][[:english|{{  :rocrail-logo-35.png}}]]
 +[[:english|Content]] -> [[:english#rocview|Rocview ]] -> [[:rocnet:cam-en|Camera Streaming]]
 +  * **[[:rocnet:headless-cam-en|Headless Setup]]**
 +  * [[:raspi:install:rpi-install-en|Rocrail graphical install]]
 + 
 +|< >|
 +^  [[https://en.wikipedia.org/wiki/Headless_computer|Wikipedia explains "headless"]]  ^
 + \\
 + \\
 +=====SD Card with Pi OS Lite (32bit)=====
 +Download the Raspberry Pi Imager:
 +  * __**[[https://www.raspberrypi.org/software/|Raspberry Pi Imager]]**__
  
 +{{:rocnet:pi-img-os-0.png?240}}{{:rocnet:pi-img-os-1.png? 240}}{{:rocnet:pi-img-os-2.png? 240}}{{:rocnet:pi-img-os-3.png? 240}}{{:rocnet:pi-img-os-00.png? 240}}\\
 +
 +Insert a SD-Card.\\
 +Start the "Raspberry Pi Imager" program.\\
 +
 +Select:
 +  - CHOOSE OS
 +  - Pi OS Other
 +  - Pi OS Lite (32bit)
 +
 +See also __**[[:raspi:install:rpi-install-en#advanced_options|Advanced Options]]**__ for setting up SSH and WiFi.\\
 +
 + \\
 +=====Config the Boot Partition=====
 +Insert the SD-Card again, after creating of the Image on the SD-Card has finished.\\
 +The SD-Card should be visible in the File-Explorer as ''boot''.\\
 + \\
 +To make the Zero able to connect to the WiFi, it must get some settings to get this done.\\
 +The easiest way is to create a text file locally named as ''wpa_supplicant.conf'' with the following content:
 +<code>
 +country=DE
 +ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
 +update_config=1
 +network={
 +       ssid="<my SSID1>"
 +       psk="<my PASSWORD>"
 +       key_mgmt=WPA-PSK
 +       priority=2
 +}
 +network={
 +       ssid="<my SSID2>"
 +       psk="<my PASSWORD>"
 +       key_mgmt=WPA-PSK
 +       priority=1
 +}
 +</code>
 +Replace the "<my*>" values with the access information of the Access Point.\\
 +  * **Note:** //Multiple network definitions may be added. The highest priority will be connected first if available.// \\
 +Copy an empty file named ''SSH'', and ''wpa_supplicant.conf'' to ''boot''. (Under Windows mostly drive ''D:'')\\
 +
 +to the boot partition of the SD-Card:\\
 +{{:rocnet:cam:boot-1.png?400}}{{:rocnet:cam:boot-2.png?400}}\\
 +
 +  - Unmount/Eject the SD-Card.
 +  - Insert the SD-Card into the slot on the Raspberry Pi.
 +  - Power on the Raspberry Pi.
 +  - Wait a few minutes to give Raspbian time to resize the file system. (With a connected monitor, on the Mini-HDMI, the progress can be watched.)
 +
 + \\
 +=====Raspbian SSH Connect=====
 +<code>
 +ssh pi@raspberrypi
 +</code>
 +The standard password is ''raspberry'' \\
 +
 +
 + \\
 +=====Raspbian Update=====
 +<code>
 +sudo apt update
 +sudo apt upgrade
 +</code>
 +
 +
 + \\
 +=====Raspi-Config=====
 +<code>
 +ssh pi@raspberrypi
 +sudo raspi-config
 +</code>
 +{{:rocnet:cam:conf-1.png?600}}\\
 +{{:rocnet:cam:conf-2.png?600}}\\
 +{{:rocnet:cam:conf-3.png?600}}\\
 +{{:rocnet:cam:conf-4.png?600}}\\
 +{{:rocnet:cam:conf-5.png?600}}\\
 +{{:rocnet:cam:conf-6.png?600}}\\
 +
 +
 +
 + \\
 +=====Python Script=====
 +Unzip the {{:rocnet:cam:cam.py.zip|cam.py.zip}}, and copy it to the Raspberry Pi:
 +<code>
 +scp cam.py pi@raspberrypi:/home/pi
 +</code>
 +
 +
 + \\
 +=====Install PiCamera=====
 +<code>
 +ssh pi@raspberrypi
 +sudo apt install python3-picamera
 +</code>
 +
 +
 + \\
 +=====Start Script=====
 +<code>
 +ssh pi@raspberrypi
 +nano startcam.sh
 +</code>
 +Create the script "/home/pi/startcam.sh" with the following content:
 +<code bash>
 +#!/bin/sh
 +cd /home/pi
 +python3 cam.py
 +</code>
 +Make the script executable:
 +<code>
 +chmod +x startcam.sh
 +</code>
 +
 + \\
 +=====Crontab=====
 +Add the line "@reboot /home/pi/startcam.sh" to the crontab:
 +<code>
 +ssh pi@raspberrypi
 +crontab -e
 +
 +no crontab for pi - using an empty one
 +
 +Select an editor.  To change later, run 'select-editor'.
 +  1. /bin/nano        <---- easiest
 +  2. /usr/bin/vim.tiny
 +  3. /bin/ed
 +
 +Choose 1-3 [1]: 
 +</code>
 +Close the nano editor with ctrl+x After edit to save the changes.\\
 +
 +Check if the changes are saved:
 +<code>
 +crontab -l
 +# Edit this file to introduce tasks to be run by cron.
 +
 +# Each task to run has to be defined through a single line
 +# indicating with different fields when the task will be run
 +# and what command to run for the task
 +
 +# To define the time you can provide concrete values for
 +# minute (m), hour (h), day of month (dom), month (mon),
 +# and day of week (dow) or use '*' in these fields (for 'any').
 +
 +# Notice that tasks will be started based on the cron's system
 +# daemon's notion of time and timezones.
 +
 +# Output of the crontab jobs (including errors) is sent through
 +# email to the user the crontab file belongs to (unless redirected).
 +
 +# For example, you can run a backup of all your user accounts
 +# at 5 a.m every week with:
 +# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
 +
 +# For more information see the manual pages of crontab(5) and cron(8)
 +
 +# m h  dom mon dow   command
 +@reboot /home/pi/startcam.sh
 +</code>
 +
 +Reboot the Raspberry Pi:
 +<code>
 +sudo reboot
 +</code>
 +
 + \\
 +=====Boot speed=====
 +Check the services which are not needed for the headless setup:
 +<code>
 +systemd-analyze blame
 +</code>
 +Google "raspberry zero systemd-analyze blame" to find tips, because this is a bit out of scope to include it in the Wiki.\\
 +
 +
 +
 + \\
 +=====Power consumption=====
 +====HDMI====
 +Running a headless Zero, there's no need to power the display circuitry.\\
 +Add the following line in ''/etc/rc.local'' to disable HDMI on boot.
 +<code>/usr/bin/tvservice -o</code>
 +(-p to re-enable).\\
 +Approximately 25mA reduction.\\
 +
 +
 + \\
 +=====Special Boot Options=====
 +To be able to use pin 27 and 28 as normal I/O, add an extra line in the /boot/config.txt:
 +<code>
 +force_eeprom_read=0
 +</code>
 +
 +  * https://www.raspberrypi.org/documentation/configuration/config-txt/boot.md
 +
 +
 +
 + \\
 +=====Notes=====
 +====SFTP File Transfer====
 +WinSCP and FileZilla can be used for transferring files to and from the Raspberry Pi.\\
 +For more information see:
 +  * https://www.raspberrypi.org/documentation/remote-access/ssh/sftp.md
 +
 +
 +====SSH====
 +  * The terminal/console commands **ssh** and **scp** are available under Linux, Windows10 and Apple macOS.
 +  * If "raspberrypi" cannot be resolved, "Could not resolve hostname raspberrypi", check the router and use the IP address instead: \\ {{:rocnet:cam:fritz.png?400}}
 +
 +====Wait for Network at Boot====
 +Under specific network conditions, the following system option (sudo raspi-conf) must be activated, if the WIOpi or CAM does not start at boot: 
 +  * **1** System Options
 +    * **S6** Network at Boot ((Select wait for network connection on boot))
 +
 +
 +
 +
 + \\
 +====Disable screen saver====
 +In case of a connected display, none headless, without user interaction.\\
 +
 +Edit the lightdm configuration:
 +<code>$ sudo nano /etc/lightdm/lightdm.conf</code>
 +find this section, and add the extra options:
 +<code>
 +[Seat:*]
 +xserver-command=X -s 0 -dpms
 +</code>
rocnet/headless-cam-en.txt · Last modified: 2022/06/17 09:42 by 127.0.0.1