User Tools

Site Tools


rocnet:headless-cam-en

Headless Setup

SD Card with Raspbian Lite

See

on how to create a SD image.


Config the Boot Partition

Create locally a file named as "wpa_supplicant.conf" with the following content:

country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
       ssid="<my SSID>"
       psk="<my PASSWORD>"
       key_mgmt=WPA-PSK
}

Replace the "<my*>" values with the real ones.

Copy an empty file named "SSH", and "wpa_supplicant.conf" file into the boot partition of the SD-Card:

  1. Unmount/Eject the SD-Card.
  2. Insert the SD-Card into the slot on the Raspberry Pi.
  3. Power on the Raspberry Pi.
  4. 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 Update

ssh pi@raspberrypi
sudo apt update
sudo apt upgrade


Raspi-Config

ssh pi@raspberrypi
sudo raspi-config








Python Script

Unzip the cam.py.zip, and copy it to the Raspberry Pi:

scp cam.py pi@raspberrypi:/home/pi


Install PiCamera

ssh pi@raspberrypi
sudo apt install python3-picamera


Start Script

ssh pi@raspberrypi
nano startcam.sh

Create the script "/home/pi/startcam.sh" with the following content:

#!/bin/sh
cd /home/pi
python3 cam.py

Make the script executable:

chmod +x startcam.sh


Crontab

Add the line "@reboot /home/pi/startcam.sh" to the crontab:

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]: 

Close the nano editor with ctrl+x After edit to save the changes.

Check if the changes are saved:

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

Reboot the Raspberry Pi:

sudo reboot


Notes

  • 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/headless-cam-en.txt · Last modified: 2019/08/16 20:43 by rjversluis