From 0a56dc63456269ea8b56545fc00d5db397f91502 Mon Sep 17 00:00:00 2001 From: PrincessPi3 Date: Tue, 14 Oct 2025 00:39:07 -0600 Subject: [PATCH] waypoint --- README.md | 2 +- huawaii-ub-8mt-breakout.md | 18 ++++++------ info-level-conf-huawaii/50-tty.rules | 5 ++++ .../boot-firmware-config.txt | 12 ++++++++ info-level-conf-huawaii/chrony.conf | 28 +++++++++++++++++++ info-level-conf-huawaii/gpsd | 14 ++++++++++ info-level-conf-huawaii/grafana.ini | 26 +++++++++++++++++ info-level-conf-huawaii/hwclock-set | 2 ++ info-level-conf-huawaii/influxdb.conf | 21 ++++++++++++++ info-level-conf-huawaii/root-crontab | 4 +++ info-level-conf-huawaii/telegraf.conf | 22 +++++++++++++++ installer2.sh | 4 +-- installer3.sh | 8 +++--- installer_auto.sh | 6 ++-- 14 files changed, 153 insertions(+), 19 deletions(-) create mode 100644 info-level-conf-huawaii/50-tty.rules create mode 100644 info-level-conf-huawaii/boot-firmware-config.txt create mode 100644 info-level-conf-huawaii/chrony.conf create mode 100644 info-level-conf-huawaii/gpsd create mode 100644 info-level-conf-huawaii/grafana.ini create mode 100644 info-level-conf-huawaii/hwclock-set create mode 100644 info-level-conf-huawaii/influxdb.conf create mode 100644 info-level-conf-huawaii/root-crontab create mode 100644 info-level-conf-huawaii/telegraf.conf diff --git a/README.md b/README.md index dc67a95..48f2b73 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ * `bash ~/Precision-Timekeeping-Fuckery/full_status.sh` **Status (Services)** -* `bash ~/Precision-Timekeeping-Fuckert/status_services.sh` +* `bash ~/Precision-Timekeeping-Fuckery/status_services.sh` **Test PPS** * `sudo ppstest /dev/pps0` diff --git a/huawaii-ub-8mt-breakout.md b/huawaii-ub-8mt-breakout.md index c142be2..d1cd609 100644 --- a/huawaii-ub-8mt-breakout.md +++ b/huawaii-ub-8mt-breakout.md @@ -2,15 +2,15 @@ **Pins are 2mm pitch** **3.3 Volts** | Cable | Module Pin | Module Pin Meaning | Raspberry Pi 4 Pin | Voltage | Notes | -|:-------|:-----------|:-------------------------|:---------------------------|:------------------------|:----------------------------------------------------------| -| Red | 2 - VCC | Voltage In | 1 - 3.3 Volts Out | 3.3 V | NOT 5 V TOLERANT | -| Black | 8 - GND | Ground | 25 - Ground | 3.3 V? | UNKNOWN 3 V AND 5 V TOLERANCES | -| Yellow | 4 - RST | Hardware Reset | NC? - Not Connected/GPIO? | 3.3 V | NOT 5 V TOLERANT | -| White | 6 - TP1 | Time Pulse 1/PPS | 12 - GPIO 18 | 3.3 V | NOT 5 V TOLERANT | -| Purple | 7 - TP2 | Time Pulse 2/PPS | NC? - Not Connected/GPIO? | 3.3 V | NOT 5 V TOLERANT | -| Green | 5 - RXD | UART Receive | 8 - UART Transmit | 3.3 V | NOT 5 V TOLERANT | -| Grey | 3 - TXD | UART Transmi t | 10 - UART Receive | 3.3 V | NOT 5 V TOLERANT | -| Orange | 1 - VCC_ANT | Antenna Power Supply | NC? Regulated Power Supply | 5.0 V Max 100 mA | MUST USE REGULATED POWER SUPPLY AND UNKNOWN 3 V TOLERANCE | +|:-------|:-----------|:-------------------------|:---------------------------|:-----------------|:----------------------------------------------------------| +| Red | 2 - VCC | Voltage In | 1 - 3.3 Volts Out (Split) | 3.3 V | NOT 5 V TOLERANT | +| Black | 8 - GND | Ground | 25 - Ground | 3.3 V? | UNKNOWN 3 V AND 5 V TOLERANCES | +| Yellow | 4 - RST | Hardware Reset | NC? - Not Connected/GPIO? | 3.3 V | NOT 5 V TOLERANT | +| White | 6 - TP1 | Time Pulse 1/PPS | 12 - GPIO 18 | 3.3 V | NOT 5 V TOLERANT | +| Purple | 7 - TP2 | Time Pulse 2/PPS | NC? - Not Connected/GPIO? | 3.3 V | NOT 5 V TOLERANT | +| Green | 5 - RXD | UART Receive | 8 - UART Transmit | 3.3 V | NOT 5 V TOLERANT | +| Grey | 3 - TXD | UART Transmi t | 10 - UART Receive | 3.3 V | NOT 5 V TOLERANT | +| Orange | 1 - VCC_ANT | Antenna Power Supply | NC? Regulated Power Supply | 5.0 V Max 100 mA | MUST USE REGULATED POWER SUPPLY AND UNKNOWN 3 V TOLERANCE | ### Adafruit DS3231 Precision RTC Breakout **Pins are 2.54mm pitch** diff --git a/info-level-conf-huawaii/50-tty.rules b/info-level-conf-huawaii/50-tty.rules new file mode 100644 index 0000000..9c16d1e --- /dev/null +++ b/info-level-conf-huawaii/50-tty.rules @@ -0,0 +1,5 @@ +SUBSYSTEM=="pps[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="tty[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="tty[A-Z]*[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="i2c[A-Z]-*[0-9]*", GROUP="dialout", MODE="0660" +SUBSYSTEM=="rtc[0-9]*", GROUP="dialout", MODE="0660" \ No newline at end of file diff --git a/info-level-conf-huawaii/boot-firmware-config.txt b/info-level-conf-huawaii/boot-firmware-config.txt new file mode 100644 index 0000000..c7e991c --- /dev/null +++ b/info-level-conf-huawaii/boot-firmware-config.txt @@ -0,0 +1,12 @@ + +# Precision Timekeeping Fuckery Additions +## GPS PPS GPIO Signal +dtoverlay=pps-gpio,gpiopin=18 + +## GPS GPIO UART +enable_uart=1 +init_uart_baud=115200 + +## I2C Hardware RTC Overlay +dtoverlay=i2c-rtc,ds3231 +# End Precision Timekeeping Fuckery Additions \ No newline at end of file diff --git a/info-level-conf-huawaii/chrony.conf b/info-level-conf-huawaii/chrony.conf new file mode 100644 index 0000000..5f94109 --- /dev/null +++ b/info-level-conf-huawaii/chrony.conf @@ -0,0 +1,28 @@ +# SHM refclock is shared memory driver, it is populated by GPSd and read by chrony +# it is SHM 0 +# refid is what we want to call this source = NMEA +# offset = 0.000 means we do not yet know the delay +# precision is how precise this is. not 1e-3 = 1 millisecond, so not very precision +# poll 0 means poll every 2^0 seconds = 1 second poll interval +# filter 3 means take the average/median (forget which) of the 3 most recent readings. NMEA can be jumpy so we're averaging here +refclock SHM 0 refid NMEA offset 0.000 precision 1e-6 poll 0 filter 3 + +# PPS refclock is PPS specific, with /dev/pps0 being the source +# refid PPS means call it the PPS source +# lock NMEA means this PPS source will also lock to the NMEA source for time of day info +# offset = 0.0 means no offset... this should probably always remain 0 +# poll 3 = poll every 2^3=8 seconds. polling more frequently isn't necessarily better +# trust means we trust this time. the NMEA will be kicked out as false ticker eventually, so we need to trust the combo +refclock PPS /dev/pps0 refid PPS lock NMEA offset 0.0 poll 3 trust + +# allow local connections to ntp +allow 10.0.0.0/24 + +# manual +manual + +# tell clients im the big dog +local stratum 1 + +# Good Time Servers +pool time.cloudflare.com iburst diff --git a/info-level-conf-huawaii/gpsd b/info-level-conf-huawaii/gpsd new file mode 100644 index 0000000..3cadb5e --- /dev/null +++ b/info-level-conf-huawaii/gpsd @@ -0,0 +1,14 @@ +# USB might be /dev/ttyACM0 +# serial might be /dev/ttyS0 +# pps might be /dev/pps0 +DEVICES="/dev/ttyS0 /dev/pps0" + +# -n means start without a client connection (i.e. at boot) +# -s 9600 is to set baud to 9600 +GPSD_OPTIONS="-n -s 9600" + +# also start in general +START_DAEMON="true" + +# Automatically hot add/remove USB GPS devices via gpsdctl +# USBAUTO="true" diff --git a/info-level-conf-huawaii/grafana.ini b/info-level-conf-huawaii/grafana.ini new file mode 100644 index 0000000..75ddff0 --- /dev/null +++ b/info-level-conf-huawaii/grafana.ini @@ -0,0 +1,26 @@ +instance_name = "Precision Timekeeping" + +[server] +# Protocol (http, https, h2, socket) +protocol = http + +# The http port to use +http_port = 3000 + +[log] +# Either "debug", "info", "warn", "error", "critical", default is "info" +level = info + +# Either "console", "file", "syslog". Default is console and file +# Use space to separate multiple modes, e.g. "console file" +mode = console file + +[log.file] +# log line format, valid options are text, console and json +format = text + +# This enables automated log rotate(switch of following options), default is true +log_rotate = true + +# Max line number of single file, default is 1000000 +max_lines = 1000000 \ No newline at end of file diff --git a/info-level-conf-huawaii/hwclock-set b/info-level-conf-huawaii/hwclock-set new file mode 100644 index 0000000..35028d4 --- /dev/null +++ b/info-level-conf-huawaii/hwclock-set @@ -0,0 +1,2 @@ +#!/bin/sh +dev=$1 \ No newline at end of file diff --git a/info-level-conf-huawaii/influxdb.conf b/info-level-conf-huawaii/influxdb.conf new file mode 100644 index 0000000..deee3e2 --- /dev/null +++ b/info-level-conf-huawaii/influxdb.conf @@ -0,0 +1,21 @@ +# report usage statistics to influxdb company +reporting-enabled = false + +[meta] + # Where the metadata/raft database is stored + dir = "/var/lib/influxdb/meta" + +[data] + # The directory where the TSM storage engine stores TSM files. + dir = "/var/lib/influxdb/data" + + # The directory where the TSM storage engine stores WAL files. + wal-dir = "/var/lib/influxdb/wal" + + # Trace logging provides more verbose output around the tsm engine. Turning + # this on can provide more useful output for debugging tsm engine issues. + trace-logging-enabled = false + +[logging] + format = "auto" + level = "info" \ No newline at end of file diff --git a/info-level-conf-huawaii/root-crontab b/info-level-conf-huawaii/root-crontab new file mode 100644 index 0000000..434dc3a --- /dev/null +++ b/info-level-conf-huawaii/root-crontab @@ -0,0 +1,4 @@ +# m h dom mon dow command +# set hardware I2C RTC hourly +0 * * * * /bin/bash -c "/usr/sbin/hwclock -w 2>> /var/log/root-crontab.log" +@reboot /usr/share/customscripts/ifnet "/usr/share/customscripts/webhook bootup" 2>> /var/log/root-crontab.log diff --git a/info-level-conf-huawaii/telegraf.conf b/info-level-conf-huawaii/telegraf.conf new file mode 100644 index 0000000..5d2a382 --- /dev/null +++ b/info-level-conf-huawaii/telegraf.conf @@ -0,0 +1,22 @@ +[global_tags] +[agent] + interval = "10s" + round_interval = true + metric_batch_size = 10000 + metric_buffer_limit = 1000000 + collection_jitter = "0s" + flush_interval = "10s" + flush_jitter = "0s" + precision = "0s" + logfile = "/var/log/telegraf/telegraf.log" + # debug = true + +[[inputs.chrony]] + metrics = ["tracking"] + timeout = "5s" + +[[outputs.influxdb]] + urls = ["http://127.0.0.1:8086"] + database = "Chrony_Stats" + timeout = "5s" + # skip_database_creation = true diff --git a/installer2.sh b/installer2.sh index 3b3f997..5147eca 100644 --- a/installer2.sh +++ b/installer2.sh @@ -2,10 +2,10 @@ # set -e echo "Fully upgrading, this may take a while..." -sudo apt dist-upgrade -y 1>/dev/null 2>&1 +sudo apt dist-upgrade -y 1>/dev/null echo "Cleaning up..." -sudo apt autoremove -y 1>/dev/null 2>&1 +sudo apt autoremove -y 1>/dev/null echo "Installer2.sh complete" >> ./status.txt diff --git a/installer3.sh b/installer3.sh index 9cc3d31..2d59bee 100644 --- a/installer3.sh +++ b/installer3.sh @@ -28,7 +28,7 @@ fi # updoot echo "Getting new software lists..." -sudo apt update 1>/dev/null 2>&1 +sudo apt update # clean up echo "Disabling unneeded junk..." @@ -37,11 +37,11 @@ sudo update-rc.d -f fake-hwclock remove 1>/dev/null 2>/dev/null sudo systemctl disable fake-hwclock 1>/dev/null 2>/dev/null echo "Purging unneeded junk..." -sudo apt purge -y "bluetooth*" "usb*" "wireless*" "pci*" "fonts*" build-essential "bluez*" "alsa*" fake-hwclock 1>/dev/null 2>&1 +sudo apt purge -y "bluetooth*" "usb*" "wireless*" "pci*" "fonts*" build-essential "bluez*" "alsa*" fake-hwclock # install da packages echo "Installing packages, this may take a while..." -sudo apt install -y telegraf grafana influxdb pps-tools gpsd gpsd-clients chrony syslog-ng gh lynx btop htop iptraf iotop neovim netcat-traditional python3-smbus i2c-tools picocom 1>/dev/null 2>&1 +sudo apt install -y telegraf grafana influxdb pps-tools git gh gpsd gpsd-clients chrony syslog-ng gh lynx btop htop iptraf-ng iotop neovim netcat-traditional python3-smbus i2c-tools picocom # check if pps-gpio is in /etc/modules already grep -e "pps-gpio" /etc/modules @@ -56,7 +56,7 @@ else fi echo "Cleaning up..." -sudo apt autoremove -y 1>/dev/null 2>&1 +sudo apt autoremove -y if [ ! -z $SUDO_USER ]; then username=$SUDO_USER diff --git a/installer_auto.sh b/installer_auto.sh index 8f8a5b1..12fe90c 100644 --- a/installer_auto.sh +++ b/installer_auto.sh @@ -10,10 +10,10 @@ else fi echo "Updating Software Lists" -sudo apt update 1>/dev/null 2>&1 +sudo apt update -echo "Installing git and raspi-config" -sudo apt install git raspi-config -y 1>/dev/null 2>&1 +echo "Installing git" +sudo apt install -y git echo "Cloning Repo" cd /home/$username