Software
Step by step instructions
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: hub.local (replace number accordingly)
Username and Password: As you like (remcommened to have the same for every device)
Wlan: Use your home network
Time/location: As you need
Insert the SD-Card
Power up the Raspberry Pi
Connect via Remote Desktop https://marketplace.visualstudio.com/items?itemName=ms-vscode.remote-explorer) - 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
Install the external wifi adapter driver
The needed driver for the chipset: https://store.rokland.com/en-de/pages/alfa-awus036ach-driver-install-help-raspberry-pi-os?srsltid=AfmBOorBs4XS-8Mpf6uSAAeZ3Dq3ApVKE7zvbZ8CR53gpzx7WgxuYlPZ
It needs a driver to be installed and some configuration, so it will host your wanted network.
install dependen packages packages:
sudo apt install -y raspberrypi-kernel-headers build-essential bc dkms gitcreate directory /src:
mkdir -p ~/srcgo to the created directory:
cd ~/srcclone the github repository with the driver:
git clone <https://github.com/morrownr/8812au-20210820.git>go to the downloaded folder:
cd ~/src/8812au-20210820install the driver:
sudo ./install-driver.shreboot:
sudo reboot
→ The led on the wifi module should start flashing
If not → ip a → If it not shows wlan1 → check if adapter is listed in lsusb → Bus 001 Device 003: ID 0bda:8812 Realtek Semiconductor Corp. RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
If the modul doesnt start flashing after rebooting, run the installation of the driver again.
Create the host the network "hub"
check the network device status:
sudo nmcli device statusif wlan1 connection is “preconfigured” → that means the external wifi adapter. The external wifi adapter is needed for the website hosting. Before disconnecting wlan1 we want to connect wlan0 to the home network. Otherwise our connection to the Pi
Connect wlan0 to the preconfigured/ home network:
sudo nmcli con up "preconfigured" ifname wlan0turn autoconnect on for wlan0:
sudo nmcli con modify "preconfigured" connection.autoconnect yes→ you may have to reconnect with sshCreate a AccessPoint with the external network:
sudo nmcli con add type wifi ifname wlan1 con-name hub autoconnect yes ssid hubAdd the AP configuration (change the password and channel accordingly)
Enable Internet Sharing (NAT routing) for wlan1:
sudo nmcli con modify hub ipv4.method sharedStart the Hotspot:
sudo nmcli con up hub

Restart:
sudo rebootCheck if everything works:
sudo nmcli device status
Create a script that checks the network configuration and corrects it
Add a small script, to ensure, that wlan1 stays with hosting the hub network:
create a script:
sudo nano /usr/local/bin/check_wlan1.shpaste this:
“STRG” + “X” → “Y” → “Enter”
Make it executable:
sudo chmod +x /usr/local/bin/check_wlan1.shRun it every minuite:
sudo crontab -eAdd this to the bottom line:
* * * * * /usr/local/bin/check_wlan1.sh
Reboot:
sudo reboot
B_Create a virtual environment
Install the python3-venv:
Activate the environment with:
source codeenv/bin/activate
C_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_nodered /home/globaladmin/code_noderedCopy the code that we need to where we need it:
cp -r ddsrepo/Hub/Software/code /home/globaladmin/codeRemove the rest:
rm -rf ddsrepoInstall all required packages:
Go to the folder with:
cd code_localInstall the packages:
pip install -r requirements.txt
D_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:
E_Activate i2c
Open rasp-config with:
sudo raspi-configSelect: “Interface options” > “I2c” > “Activate i2c” _> yes
Exit raspi-config
F_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
H_Create "Local" Service
Create new service file with:
sudo nano /etc/systemd/system/startmainlocal.servicePaste the following in the file and exit it with "Ctrl"+"X" > "Y" > "Enter"
Enable service:
I_Create "Nodered-Helper" Service
Create new service file with:
sudo nano /etc/systemd/system/startmainnodered.servicePaste the following in the file and exit it with "Ctrl"+"X" > "Y" > "Enter"
Enable service:
J_Create the docker enviroment (Mosquitto, Node-Red, Influx DB, Grafana)
To not have to install everything by our self, we use IOT Stack: https://sensorsiot.github.io/IOTstack/ Here you can find the instructions: https://sensorsiot.github.io/IOTstack/Basic_setup/ More explanation for IOT Stack and Docker you can find here: https://www.youtube.com/watch?v=_DO2wHI6JWQ
Download and install IOTstack:
curl -fsSL https://raw.githubusercontent.com/SensorsIot/IOTstack/master/install.sh | bash
→ this can take a while. It also depends on the strength of your Raspberry Pi. It will install Docker and other requirements for us! → it will restart in this process. Don’t worry. Just connect via SSH again
Go in the IOTStack directory:
cd IOTstack/run:
./menu.sh
click "Build stack"
Select with the following containers to build with the spacebar and arrow keys: (mosquitto, nodered, influxdb2, grafana) !! When you select nodered, it will show an issue. Just open the options for node red (hitting right arrow) and select “Select & build add ons list. → hit enter and next step just go with the default selection and hit enter again:

Everything selected → hit enter. You will end up on the start screen
Now lets start the stack: Go to “Docker commands” and select “Start stack” → It will start pulling the images for the containers - this can take a while.


Hit enter and than exit it.
To check the running containers and check their port:
docker ps
To test if we can reach all service, let's check the following addresses. Make sure you are connected to the hub network:
Nodered: hub.local:1880
Grafana: hub.local:3000
InfluxDB2: hub.local:8087



K_Install the data explorer
To be able do download the data that we collected, to drag it into the analytic software, you need another container. Information about the image: https://github.com/awesometic/docker-h5ai
Open a terminal and ssh into the hub
Give permissions to the folders of the IOTstack:
Paste this to get the data explorer image "h5ai" and run it as docker container
To check the running containers:
docker psCheck the webui by opening the website: hub.local:80
L_SetUp InfluxDB2
Go to the InfluxDB2 WebUi: hub.local:8087
Login with the default user:
Username: me
Password: mypassword
Click on "Load data" > "Buckets"
Create the following Buckets
BoatLog
12 hr
Temporary log of live boat data
BoatStatus
12 hr
Temporary log of boat status
BuoyLog
12 hr
Temporary log of live buoy data
Comments
7 days
Database of comments and marks for timeline
HubLog
7 days
Database for all sensors on the hub
Create a 3 API-Keys. "Load Data" > "API Tokens"
Click "Create API-Token" > "All Access Tokens
Description (1. "Grafana", 2. "NodeRed", 3. "RaspberryPi")
Write all Keys down! You cant review them!
M_Setup NodeRed
Download the flows.json file from: https://github.com/oliverheisel/DataDrivenSailing/tree/main/Hub/NodeRed
Open your browser and go to hub.local:1880 to access Node-RED.
In Node-RED, click the hamburger menu in the top-right corner, select Manage Palette, go to the Install tab, search for node-red-node-ui-table, and click Install.
Click the hamburger menu again, select Import, and upload the flows.json file you downloaded.
Insert API-Key
Open one flow (doesn't matter wich) and find a InfluxDB node and click on it
Click on the pencile next to "server"
Replace the token with NodeRed you created
Save and exit
N_Setup Grafana
Download the dashboard files from: https://github.com/oliverheisel/DataDrivenSailing/tree/main/Hub/Grafana
Open your browser and go to hub.local:3000 to access Grafana.
Go to "Dashboard" > "New" > "Import"
Upload the file and create a new dashboard
Check if the connections works - Use the InfluxDB API-Key
Congrats, you made it 🎉
Optional_Add a 4G mobile router
Configure the router
login to your router
change to SSID: hub4G
wifipassword: SailingBoat#7xTq9!
Set it on auto network select + roaming on
Set second wifi connection on Raspberry Pi
ssh into the hub and paste the following into the terminal:
Set connection priorities (The higher the priority value, the more preferred the network is.)
sudo nmcli con modify "preconfigured" connection.autoconnect-priority 50sudo nmcli con modify "4ghotspot" connection.autoconnect-priority 30
Check it:
sudo nmcli connection showsudo nmcli con show "preconfigured" | grep autoconnect-prioritysudo nmcli con show "4ghotspot" | grep autoconnect-priority
Last updated