DataDrivenSailing Wiki
GitHub RepositoryContactContribuit
  • Welcome!
  • What is DDS?
  • How to use DDS?
  • How to replicate DDS?
  • How to customize DDS?
  • Who is behind DDS?
  • BoatTracker
    • Details
    • Setup Instructions
      • Hardware
      • Software
      • Enclosure
  • Hub
    • Details
    • Hub - Setup Instructions
      • Hardware
      • Software
      • Enclosure
    • Power - Setup Instructions
      • Hardware
      • Enclosure
  • BuoyTracker
    • Details
    • Setup Instructions
      • Hardware
      • Software
      • Enclosure
  • Controlbox
    • Coming soon
  • Add-ons
    • Camera
    • Coaching Buoys
  • Other
    • Core instructions
      • 3D Printing with Online Services
    • Contribuit
  • Changelog
  • Support
  • License
Powered by GitBook
On this page
  • Step by Step setup
  • A_Basic Raspberry Pi Firmware
  • B_Create a virtual environment
  • C_Activate pigiod
  • D_Activate i2c
  • E_Change i2c speed
  • F_Copy Code from GitHub
  • G_Change the configuration
  • H_Create a Service
  • I_Copy SSH Keys
Edit on GitHub
  1. BoatTracker
  2. Setup Instructions

Software

Last updated 2 months ago

Step by Step setup

You don't have to program the compute module yourself, but you have to set it up. The following steps help you to setup your Tracker.

If you want to have a deeper insight in the code itself, you can find the documented code in the github repository:

A_Basic Raspberry Pi Firmware

  1. Install Raspberry Pi OS Lite 64bit with the with the following settings:

    1. Hostname: boat1.local (replace number accordingly)

    2. Username and Password: As you like

    3. Wlan: Use the hub network

    4. Time/location: As you need

  2. Power up the Raspberry Pi

  3. Connect via SSH - ) - this extension in visual studio code cold make you life easier.

  4. Update and upgrade: sudo apt-get update && sudo apt-get -y upgrade

  5. Reboot with: sudo reboot

B_Create a virtual environment

  1. Install the python3-venv:

sudo apt install python3-venv
python3 -m venv codeenv --system-site-packages
  1. Activate the environment with: source codeenv/bin/activate

→ you should see a “(env)” in front of your Terminal name

→ for deactivate the env -> deactivate

C_Activate pigiod

pigpiod itself is a daemon that provides low-level access to Raspberry Pi’s GPIO pins. Paste the following code in the terminal:

sudo systemctl enable pigpiod
sudo systemctl start pigpiod

D_Activate i2c

  1. Open rasp-config with: sudo raspi-config

  2. Select: “Interface options” > “I2c” > “Activate i2c” _> yes

  3. Exit raspi-config

E_Change i2c speed

  1. Open the firmware configuration file with: sudo nano /boot/firmware/config.txt

  2. Search for the "dparam" line

  3. Uncomment the line by removing the hashtag

  4. Add the following, so it looks like this: → changing from 400khz to 100khz: dtparam=i2c_arm=on,i2c_arm_baudrate=100000

  5. Reboot with: sudo reboot

F_Copy Code from GitHub

  1. Install git with: sudo apt-get install git

  2. Clone the repository: git clone https://github.com/oliverheisel/DataDrivenSailing.git ddsrepo

  3. Copy the code that we need to where we need it: cp -r ddsrepo/Tracker/Software/code /home/globaladmin/code

  4. Remove the rest: rm -rf ddsrepo

  5. Install all required packages:

    1. Go to the folder with: cd code

    2. Install the packages: pip install -r requirements.txt

G_Change the configuration

  1. Open the code configuration file (it is a python script, so use your ide): /home/globaladmin/code/config/config.py

  2. Change the hostname number accordingly (it needs to be the same as you defined in the firmware - see Task 1)

  3. Make sure that Type = "Boat" and the others are commented out

  4. Save and Reboot with: sudo reboot

H_Create a Service

  1. Create new service file with: sudo nano /etc/systemd/system/startmain.service

  2. Paste the following in the file and exit it with "Ctrl"+"X" > "Y" > "Enter"

[Unit]
Description=Run Main.py on Boot
After=network.target

[Service]
User=globaladmin
WorkingDirectory=/home/globaladmin/code
ExecStart=/bin/bash -c 'source /home/globaladmin/codeenv/bin/activate && /home/globaladmin/codeenv/bin/python /home/globaladmin/code/main.py'
Restart=always
RestartSec=2
Environment=VIRTUAL_ENV=/home/globaladmin/codeenv
Environment=PATH=/home/globaladmin/codeenv/bin:$PATH
ExecStartPre=/bin/sleep 5

[Install]
WantedBy=multi-user.target
  1. Enable service:

sudo systemctl daemon-reload
sudo systemctl enable startmain.service
sudo systemctl start startmain.service

The service will start the main script each time the Raspberry Pi boots.

If you have to stop or restart the service (in case you changed the code) you can do it with:

STOP: sudo systemctl stop startmain.service

RESTART: sudo systemctl restart startmain.service

I_Copy SSH Keys

Rsync uses SSH Keys to transfer the data securly.

  1. SSH into the Hub

  2. Create an SSH Key: ssh key authentification: ssh-keygen -t rsa -b 2048 !!! You only need to do this for the first device! It will be saved on the hub !!!

  3. Copy the key to the Tracker (change the host accordingly): ssh-copy-id globaladmin@boat1.local

  4. Test it (change the host accordingly): ssh globaladmin@boat1.local -> it should work without entering a password

Congrats, you made it 🎉

https://github.com/oliverheisel/DataDrivenSailing
Raspberry Pi Imager
https://marketplace.visualstudio.com/items?itemName=Kelvin.vscode-sshfs