Pi4 with Raspbian Bookworm

From Global Meteor Network
Revision as of 06:43, 14 May 2024 by Markmcintyre (talk | contribs)
Jump to navigation Jump to search


Burn an SD Card

  • Download the Raspberry Pi Imager from https://www.raspberrypi.com/software/
  • Run the tool, select your model of Pi, then select Bookworm 64-bit.
  • Select your SD card and click Next and then Edit Settings. Make the following changes:
    • If you know your station ID set the Hostname to match it but in lower case. For example if your station is UK1234 set the hostname to uk1234
    • otherwise set the hostname to be something you'll remember
    • Set the username to rms and enter a password of your choice. Remember this!
    • Add your Wifi network details
    • Set the locale to UTC and the keyboard layout to match your keyboard.
    • save settings, and on the next screen click Yes and then Yes again
  • Once the image has been burned, insert the SD card into your Pi power it on. The Pi will reboot a few times as it sets things up.

Configure the Operating System

  • Login as the rms user you created above and run the following commands to install the system libraries required by RMS.
sudo apt-get install -y cmake git mplayer python3 python3-dev python3-tk python3-pip libblas-dev libatlas-base-dev liblapack-dev at-spi2-core libopencv-dev libffi-dev libssl-dev socat ntp libxml2-dev libxslt-dev imagemagick ffmpeg qt5-qmake python3-pyqt5 libqt5gstreamer-1.0-0 python3-pyqt5.qtmultimedia qtgstreamer-plugins-qt5 libqt5gstreamer-dev libqt5gstreamerui-1.0-0 libqt5gstreamerutils-1.0-0 python3-opencv libcairo2-dev
sudo apt-get install -y gobject-introspection libgirepository1.0-dev
sudo apt-get install -y gstreamer1.0-libav gstreamer1.0-plugins-bad
sudo apt-get install -y chrony
  • now create a python environment for RMS and ensure its always active:
python -m venv ~/vRMS
echo source ~/vRMS/bin/activate >> ~/.bashrc
echo cd ~/source/RMS >> ~/.bashrc

We recommend at this point you should reboot the pi, to pick up all the changes you've just made.

sudo reboot

Connect a Camera

Out-of-the box, RMS on Bookworm can connect to any camera attached to your network. This is the simplest way. If you prefer to connect the camera directly to the Pi, jump ahead to this section. If you're happy using a connection via your router, plug the camera in and find its IP address as explained here.

Install RMS

  • Login to the Pi again and download the code:
mkdir ~/source
cd ~/source
git clone https://github.com/CroatianMeteorNetwork/RMS.git
  • Activate the python environment, if not already active. The prompt will change to (vRMS) rms@yourhostname: if its active.
source ~/vRMS/bin/activate


  • Now, set up Python in the environment we just created:
cd ~/source/RMS
pip install -U pip setuptools
pip install -r requirements.txt
  • Configure git so that the script can stash changes in the repo and update the code:
git config --global user.email "rms@gmn.uwo.ca"
git config --global user.name "RMS"
  • Ready the RMS software for use. This may take some time as the app is built and installed.
cd ~/source/RMS
python setup.py install
./Scripts/GenerateDesktopLinks.sh

Configure RMS

  • Edit the configuraton file
nano ~/source/RMS/.config
    • Fnd your latitude, longitude and elevation above sea level. These need to be known to 5 decimal places for Meteor Science so use a GPS or an accurate map. Be careful to enter longitude as negative if west of Greenwich, and note you must enter decimals not minutes and seconds. For example 1 degree 18 minutes 12 seconds West would be entered as -1.30333.
    • If you already have a stationID you can add this to the config file too.
    • Finally, find the device: line in the file and update it to contain your camera's IP address.
  • Now run RMS for the first time. You will be asked to confirm a number of system settings. You don't need to expand the filesystem so you can skip over that step.
 ./Scripts/RMS_FirstRun.sh

If you have no station-ID yet, request one with the instructions shown on screen and then abort the script by pressing the Ctrl-C key combination. Once you have your station ID, add it into the .config file and rerun this step.

  • Once you've finished the configuration steps, RMS will run an automated update and installation step. Eventually, you'll see a message that RMS is starting up. Let it start up to ensure there are no problems, then once its either waiting for night, or already capturing images, stop it by pressing Ctrl-C and letting the script run its tidy-up steps.

Job done

Thats it, RMS should now be working. hopefully, during the configuraton steps above you sent your SSH key and location details to the network coordinator who will add your station to the GMN network, and you can now wait for a clear night to make a detection mask calibrate the field of view. That's covered in a different article here.

Direct Camera connection

The simplest approach is to connect the camera to your router. However, ff you have no wired network available you could connect the camera to the Raspberry directly and then connect the Raspberry Pi to your network over Wifi. If you want to do this, proceed as follows:

1. First, install the DHCP server:

 sudo apt-get install -y isc-dhcp-server

2. Edit the DHCP configuration file:

 sudo nano /etc/dhcp/dhcpd.conf

We need to add a fixed address for the camera, so append this at the end of the file:

 subnet 192.168.42.0 netmask 255.255.255.0 {
   authoritative;
   pool {
 	  range 192.168.42.10 192.168.42.10;
   }
   option broadcast-address 192.168.42.255;
   default-lease-time 600;
   max-lease-time 7200;
   option domain-name "local";
 }

This will assign a fixed IP address 192.168.42.10 to the camera.

3. Edit the DCHP server configuration so it will only listen to the ethernet interface. Open the file:

 sudo nano /etc/default/isc-dhcp-server

and edit the line with INTERFACESv4 by adding "eth0":

 INTERFACESv4="eth0"

4. Next, we need to give the ethernet interface the proper subnet. Open:

 sudo nano /etc/dhcpcd.conf

and add this at the end of the file:

 interface eth0
 static ip_address=192.168.42.1/24

This will give the ethernet interface a static IP address.

5. Finally, the DHCP server will try to run before the ethernet interface is up, which will produce an error. We can tell it to try again, until it is successful. Run the following commands:

 sudo cp /run/systemd/generator.late/isc-dhcp-server.service /etc/systemd/system
 sudo nano /etc/systemd/system/isc-dhcp-server.service

Edit the [Service] section:

  • set Restart=on-failure
  • add RestartSec=5 to instruct systemd to wait 5 seconds before restarting a failed service.

Add the [Install] section which is missing, and add the follow line to it:

 WantedBy=multi-user.target

Run the commands:

 sudo systemctl daemon-reload
 sudo systemctl disable isc-dhcp-server
 sudo systemctl enable isc-dhcp-server

6. Reboot so to test the configuration:

 sudo reboot

Make sure the camera is connected to the Pi’s ethernet interface, and that a fixed IP address of 192.168.42.10 is set on the camera.

7. Now, if you run arp -a, you will be able to see the IP camera: ? (192.168.42.10) at 00:12:16:b6:79:db [ether] on eth0 If not, check the status of the DHCP server service:

 sudo service isc-dhcp-server status

The service should be active.


(more to come)