Raspberry Pi

Hardware

There are multiple Raspberry Pi models. I have the Pi Zero W.

  • 802.11 b/g/n wireless LAN
  • Bluetooth 4.1, Bluetooth Low Energy
  • 1GHz, single-core CPU
  • Mini HDMI and USB On-The-Go ports
  • CSI camera connector
  • (only) 512MB RAM

Installation

You can install the OS headless (so keyboard or screen required for the Raspberry PI). You just need an empty SD card and a computer with an SD card reader and install rpi-imager there (for details see https://www.raspberrypi.com/software/). I took the Raspberry Pi OS Lite (the full one has a desktop environment which seemed pointless without a screen attached). It is important to go through the extended options as you need to set at least

  • The Wifi (otherwise you can not connect)
  • Configure to allow login via ssh
  • Create a user to login
  • Maybe set the keyboard layout, just in case you will ever connect a keyboard

Once the image has been written to the SD card, put it into the Raspberry Pi and give it power via USB. Tricky part is to find out the name or IP it gets in your network.

  • Check the web interface of your router. FritzBox seems to assign it the name raspberrypi.fritz.box by default
  • Find out your local network and scan with nmap for open ssh ports. The IP needs to match the network you see with ifconfig from another device in the same network, just replace the last digit with 0
sudo nmap -p 22 192.168.123.0/24
  • broadcast pings seem to be ignored by everybody today so that is not helping

Configuration

For me the default configuration was fine, but you can have a look through all the options

sudo raspi-config

Firmware Update

Don't know if that is really needed, the tool even recommends to not run it, but as my Pi was rather old I did a firmware update and it worked well

apt-get install rpi-update
rpi-update

Restore access

Wifi

When you have a new wifi you can mount the SD card in another computer and change this file etc/wpa_supplicant/wpa_supplicant.conf

network={
    ssid="your-network-ssid-name"
    psk="your-network-password"
}

You can also compare it with one on a Linux computer in the same Wifi that works.

Login credentials

  • Put your ssh public key into the authorized_keys file in the .ssh folder in the home folder of the user you want to log in (by putting the SD card into another computer)
ls -la ~/.ssh/

total 12
drwx------ 2 foo foo 4096 May  3 02:26 .
-rw------- 1 foo foo  226 May  3 02:26 authorized_keys
}
  • You can also change the password of any user by editing the file etc/shadow. You will need to copy the hashed password from another user, where you know the password. I would recommend to stick to ssh public key login and later make the password in the shadow file invalid.

Camera

https://www.raspberrypi.com/documentation/computers/camera_software.html

Pictures

This should find a camera

libcamera-still --list-cameras
Available cameras
-----------------
0 : imx219 [3280x2464] (/base/soc/i2c0mux/i2c@1/imx219@10)
    Modes: 'SRGGB10_CSI2P' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop]
                             1640x1232 [41.85 fps - (0, 0)/3280x2464 crop]
                             1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                             3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]
           'SRGGB8' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop]
                      1640x1232 [83.70 fps - (0, 0)/3280x2464 crop]
                      1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                      3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]

This takes a photo. Unfortunately 90 and 270 is not supported for rotation. With --ev you can make the picture darker or brighter.

libcamera-jpeg  -t1 -n --ev -0.3 --rotation 0 --width 1920 --height 1080  -o /tmp/test.jpg
libcamera-still -t1 -n --ev -0.3 --rotation 0 --width 1920 --height 1080  -o /tmp/test.jpg

Videos

Record a 10 second video

libcamera-vid -t 10000 --width 1640 --height 1232  -o /tmp/test.h264

Streaming This sends from the server a stream and any client can connect to it. The second command it for the client to connect to the server

libcamera-vid -t 0 --width 800 --height 600   --inline -o - | cvlc stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8080}' :demux=h264
vlc http://192.168.0.17:8080

This sends an UDP stream from the Pi to the given IP and the second one reads the incoming stream and plays it. But not so useful as you need to configure the client on the server side

libcamera-vid -t 0 --inline --width 1640 --height 1232 -o udp://192.168.0.17:8554
vlc udp://@:8554 :demux=h264

Deprecated Camera tools

raspistill -o cam.jpg
ERROR: the system should be configured for the legacy camera stack

You could configure the Pi to use the legacy camera stack but better to use libcamera-still

motioneyeos

motioneyeos

Links

https://www.codeproject.com/Articles/665518/Raspberry-Pi-as-low-cost-HD-surveillance-camera