Software
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: https://github.com/oliverheisel/DataDrivenSailing
A_Basic Raspberry Pi Firmware
Install Raspberry Pi OS Lite 64bit with the Raspberry Pi Imager with the following settings:
Hostname: boat1.local (replace number accordingly)
Username and Password: As you like
Wlan: Use the hub network
Time/location: As you need
Power up the Raspberry Pi
Connect via SSH - https://marketplace.visualstudio.com/items?itemName=Kelvin.vscode-sshfs) - this extension in visual studio code cold make you life easier.
Update and upgrade:
sudo apt-get update && sudo apt-get -y upgradeReboot with:
sudo reboot
B_Create a virtual environment
Install the python3-venv:
sudo apt install python3-venv
python3 -m venv codeenv --system-site-packagesActivate the environment with:
source codeenv/bin/activate
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 pigpiodD_Activate i2c
Open rasp-config with:
sudo raspi-configSelect: “Interface options” > “I2c” > “Activate i2c” _> yes
Exit raspi-config
E_Change i2c speed
Open the firmware configuration file with:
sudo nano /boot/firmware/config.txtSearch for the "dparam" line
Uncomment the line by removing the hashtag
Add the following, so it looks like this: → changing from 400khz to 100khz:
dtparam=i2c_arm=on,i2c_arm_baudrate=100000Reboot with:
sudo reboot
F_Copy Code from GitHub
Install git with:
sudo apt-get install gitClone the repository:
git clone https://github.com/oliverheisel/DataDrivenSailing.git ddsrepoCopy the code that we need to where we need it:
cp -r ddsrepo/code /home/globaladmin/codeRemove the rest:
rm -rf ddsrepoInstall all required packages:
Activate the virtual environment:
source codeenv/bin/activateGo to the folder with:
cd codeInstall the packages:
pip install -r requirements.txt
G_Change the configuration
Open the code configuration file (it is a python script, so use your ide):
/home/globaladmin/code/config/config.pyChange the hostname number accordingly (it needs to be the same as you defined in the firmware - see Task 1)
Make sure that devicetype = "boat" and the others are commented out
Save and Reboot with:
sudo reboot
H_Create a Service
Create new service file with:
sudo nano /etc/systemd/system/startmain.servicePaste 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.targetEnable service:
sudo systemctl daemon-reload
sudo systemctl enable startmain.service
sudo systemctl start startmain.serviceI_Copy SSH Keys
Rsync uses SSH Keys to transfer the data securly.
SSH into the Hub
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 !!!Copy the key to the Tracker (change the host accordingly):
ssh-copy-id globaladmin@boat1.localTest it (change the host accordingly):
ssh globaladmin@boat1.local-> it should work without entering a password
Congrats, you made it 🎉
Last updated