Move fast, break things
Download latest Raspbian image
- https://www.raspberrypi.org/downloads/raspbian/
Flash your SD card with Raspbian
- I used Balena Etcher (now working with Catalina)
- https://www.balena.io/etcher/
Mount your freshly flashed SD card
- unplug and replug the SD card
- Navigate to the SD card from terminal
cd /Volumes/boot- I want to run this Pi headless, enable ssh by creating a file "ssh"
touch ssh- Prepare the headless Pi to join the Wi-Fi by creating a file "wpa_supplicant.conf"
nano wpa_supplicant.confcountry=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="TwoPointFourBillionHertz"
psk="NETWORK-PASSWORD"
}- eject the SD card
- slam the SD card into the Pi
- power it up
- watch your DHCP server for new leases or scan your LAN to discover the IP assigned to your freshly minted Pi
- ssh into the Pi
If you are rebuilding the pi, you might need to wipe the 'known hosts' from your mac
rm -f .ssh/known_hostsssh [email protected] #You need to find your own Pi's IP address- default password is raspberry
- you should change that
sudo raspi-configFrom here you can:
- Change User Password
Change the Hostname
- Network Options > Hostname
Enable the Camera
- Interfacing Options > Camera
Expand the Filesystem
- Advanced Options > Expand Filesystem
Exit and Reboot
- Finish
Ok, looking good, sir!
ssh back into the Pi
sudo apt-get updatesudo apt-get upgradeCongratulations, the Pi is all setup
Next up, test the camera
Find the latest version of Motion suitable for Raspberry Pi
https://github.com/Motion-Project/motion/releases
Look out for 'pi_' at the beginning
probably looks something like: pi_buster_motion_4.3.1-1_armhf.deb
copy its link URL
wget {copied URL}sudo apt-get install gdebi-coresudo gdebi {deb package name}test motion
sudo motionreview output, if no errors, proceed...
If you get 'segmentation fault' you have installed the wrong version of Motion, not the specifically Pi version
Configure Motion for real now
sudo nano /etc/motion/motion.confThe Motion 4.1.1 default config contained many many more additional lines of configuration. In 4.2.2 it has been cleaned up greatly, but I feel could lead to some config options being missed out. Below is an example config file similar to one I use, with the interesting options included.
- In case that is all too much, here are the really important lines to change:
daemon on
stream_localhost off
target_dir /home/pi/motion- Assuming you wish to save pictures / video, the target directory is important to pay attention to!
- You need to make the directory for Motion
mkdir /home/pi/motion- You also need to setup the permissions for this folder
sudo chgrp motion motionsudo chmod g+rwx motion- Finally, setup the daemon
sudo nano /etc/default/motion- change the line to read "yes"
start_motion_daemon=yes- Now we can test Motion
sudo motion- test via browser
- Theoretically you can now browse to the ip address of your Pi, and view the live stream
IP ADDRESS OF YOUR PI:8081- If the page does not load, motion has got a problem, to take a look at that:
sudo service motion status- If you see errors relating to permissions, such as
[1:ml1] [NTC] [ALL] motion_detected: Motion detected - starting event 1
[1:ml1] [ERR] [ALL] myfopen: Error opening file ~/home/pi/motion/20191117 1042 42-10 [01] (0).jpg with mode w: Permission denied
[1:ml1] [ERR] [ALL] put_picture: Can't write picture to file ~/home/pi/motion/20191117 1042 42-10 [01] (0).jpg - check access rights to target directory
Thread is going to finish due to this fatal error: Permission denied
Possibilities:
The folder where you are attempting to save the images does not exist
- in my example:
~/home/pi/motionis WRONG - it should have read
/home/pi/motion - The permissions are insufficient for the user "motion" to write to the intended folder
Much credit and thanks to:
https://pimylifeup.com/raspberry-pi-webcam-server/
https://desertbot.io/blog/headless-raspberry-pi-4-ssh-wifi-setup