Software
Last updated
Last updated
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:
Install Raspberry Pi OS Lite 64bit with the 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 ) - this extension in visual studio code cold make you life easier.
Update and upgrade: sudo apt-get update && sudo apt-get -y upgrade
Reboot with: sudo reboot
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 git
create directory /src: mkdir -p ~/src
go to the created directory: cd ~/src
clone the github repository with the driver: git clone <https://github.com/morrownr/8812au-20210820.git
>
go to the downloaded folder: cd ~/src/8812au-20210820
install the driver: sudo ./install-driver.sh
reboot: 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.
check the network device status: sudo nmcli device status
if 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 wlan0
turn autoconnect on for wlan0: sudo nmcli con modify "preconfigured" connection.autoconnect yes
→ you may have to reconnect with ssh
Create a AccessPoint with the external network: sudo nmcli con add type wifi ifname wlan1 con-name hub autoconnect yes ssid hub
Add the AP configuration (change the password and channel accordingly)
Enable Internet Sharing (NAT routing) for wlan1: sudo nmcli con modify hub ipv4.method shared
Start the Hotspot: sudo nmcli con up hub
Restart: sudo reboot
Check if everything works: sudo nmcli device status
Add a small script, to ensure, that wlan1 stays with hosting the hub network:
create a script: sudo nano /usr/local/bin/check_wlan1.sh
paste this:
“STRG” + “X” → “Y” → “Enter”
Make it executable: sudo chmod +x /usr/local/bin/check_wlan1.sh
Run it every minuite: sudo crontab -e
Add this to the bottom line: * * * * * /usr/local/bin/check_wlan1.sh
Reboot: sudo reboot
Install the python3-venv:
Activate the environment with: source codeenv/bin/activate
Install git with: sudo apt-get install git
Clone the repository: git clone https://github.com/oliverheisel/DataDrivenSailing.git ddsrepo
Copy the code that we need to where we need it: cp -r ddsrepo/Hub/Software/code_nodered /home/globaladmin/code_nodered
Copy the code that we need to where we need it: cp -r ddsrepo/Hub/Software/code_local /home/globaladmin/code_local
Remove the rest: rm -rf ddsrepo
Install all required packages:
Go to the folder with: cd code_local
Install the packages: pip install -r requirements.txt
pigpiod itself is a daemon that provides low-level access to Raspberry Pi’s GPIO pins. Paste the following code in the terminal:
Open rasp-config with: sudo raspi-config
Select: “Interface options” > “I2c” > “Activate i2c” _> yes
Exit raspi-config
Open the firmware configuration file with: sudo nano /boot/firmware/config.txt
Search 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=100000
Reboot with: sudo reboot
Create new service file with: sudo nano /etc/systemd/system/startmainlocal.service
Paste the following in the file and exit it with "Ctrl"+"X" > "Y" > "Enter"
Enable service:
Create new service file with: sudo nano /etc/systemd/system/startmainnodered.service
Paste the following in the file and exit it with "Ctrl"+"X" > "Y" > "Enter"
Enable service:
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/
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:
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 ps
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!
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
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 🎉
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 50
sudo nmcli con modify "4ghotspot" connection.autoconnect-priority 30
Check it:
sudo nmcli connection show
sudo nmcli con show "preconfigured" | grep autoconnect-priority
sudo nmcli con show "4ghotspot" | grep autoconnect-priority
The needed driver for the chipset:
To not have to install everything by our self, we use IOT Stack: Here you can find the instructions: More explanation for IOT Stack and Docker you can find here:
run: ./menu.sh
Nodered:
Grafana:
InfluxDB2:
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:
Check the webui by opening the website:
Go to the InfluxDB2 WebUi:
Download the flows.json file from:
Open your browser and go to to access Node-RED.
Download the dashboard files from:
Open your browser and go to to access Grafana.