Projet: Création d’une balise FT8 autonome et automatique avec raspberrby pi et QDX – Digital Transceiver
1.Raspberry pi zero 2w
2.Écran sur Raspberry pi zero 2 w
Écran 3.2″ waveshare gpio pin connection:
Les pins NC restent utilisable pour autre chose.
/boot/config.txt
1 |
dtoverlay=waveshare32b:rotate=90 |
3.GPS
atgm336h-5n31
Connexion sur pin :
VCC => 3.3v
GND => GND
TX => UART RX
PPS => GPIO4
1 2 |
sudo apt install -y pps-tools gpsd chrony sudo systemctl enable gpsd.service |
/etc/modules
1 2 3 4 5 |
# /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. pps-gpio |
/etc/default/gpsd
1 2 3 4 5 6 7 8 9 |
# Devices gpsd should collect to at boot time. # They need to be read/writeable, either by user gpsd or the group dialout. DEVICES="/dev/ttyS0 /dev/pps0" # Other options you want to pass to gpsd GPSD_OPTIONS="-n" # Automatically hot add/remove USB GPS devices via gpsdctl USBAUTO="false" |
/boot/config.txt
1 2 3 |
enable_uart=1 init_uart_baud=9600 dtoverlay=pps-gpio,gpiopin=4 |
/etc/chrony/chrony.conf
1 2 3 4 5 6 7 8 9 10 |
refclock PPS /dev/pps0 refid PPS precision 1e-9 poll 3 trust lock GPS refclock SHM 0 refid GPS precision 1e-1 poll 3 trust offset 0.139 keyfile /etc/chrony/chrony.keys driftfile /var/lib/chrony/chrony.drift #log tracking measurements statistics logdir /var/log/chrony maxupdateskew 100.0 hwclockfile /etc/adjtime rtcsync makestep 1 3 |
tests
1 2 3 |
sudo ppstest /dev/pps0 watch -n 1 chronyc sources watch -n 1 chronyc tracking |
4.Modules d’Alimentation
Module MP1584 réglage 5v pour raspberry pi zero sur pin GND et 5V en dessous du connecteur pwr et 9v pour QDX – Digital Transceiver.
MP1584 => 1.5mhz de hachage donc mélanges hors bandes et filtré par les filtres passe bandes.
5.Buzzer
Ajout d’un buzzer 5v avec pin de commande sur GPIO0.
Utilisation d’un DTC114EE in sur GPIO0, GND vers GND out vers GND du buzzer.
/usr/local/bin/beep
1 2 3 4 |
#!/bin/sh echo 1 > /sys/class/gpio/gpio0/value sleep 0.1 echo 0 > /sys/class/gpio/gpio0/value |
6.Logiciels
1 2 3 4 5 6 7 8 9 10 11 12 13 |
cd ~ apt install git libasound2-dev git clone https://github.com/F4HTB/gcFT8 cd gcFT8 make touch QSO.log touch Call_Table.log cd ~ git clone https://github.com/larsks/gpio-watch.git cd gpio-watch make sudo make install |
7.Scripts tweaks
/etc/rc.local
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi /usr/local/bin/FStart & exit 0 |
/usr/local/bin/FStart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
#Set pull up internal resistor for gpio input /usr/bin/raspi-gpio set 18 pu /usr/bin/raspi-gpio set 23 pu /usr/bin/raspi-gpio set 24 pu #For tty switching echo 3 > /tmp/.witchtty /usr/bin/chvt 3 while ! $(/sbin/service "getty@tty3" status | grep -q "Active: active (running)") ; do sleep 1; done; sleep 1 #Print start message setsid sh -c 'exec clear <>/dev/tty3 >&0 2>&1' sleep 1 setsid sh -c 'exec clear <>/dev/tty3 >&0 2>&1' echo " ______ _ _ _ _ _______ ____ __ " >/dev/tty3 echo " | ____| || | | | | |__ __| _ \ _ \ \ " >/dev/tty3 echo " | |__ | || |_| |__| | | | | |_) | (_)______| |" >/dev/tty3 echo " | __| |__ _| __ | | | | _ < |______| |" >/dev/tty3 echo " | | | | | | | | | | | |_) | _ | |" >/dev/tty3 echo " |_| |_| |_| |_| |_| |____/ ( ) | |" >/dev/tty3 echo " |/ /_/" >/dev/tty3 #Set Buzzer gpio echo 0 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio0/direction #Beep on startup with beep script (/usr/local/bin/beep;/usr/local/bin/beep;/usr/local/bin/beep)& #wait gps and time sync and getGridSquare echo 0 > /tmp/.GridSquare s='-\|/' i=0 #wait gpsd service runing while ! $(/sbin/service "gpsd" status | grep -q "Active: active (running)") do i=$(( (i+1) %4 )) printf "\rWait GPSD Service...${s:$i:1}" <>/dev/tty3 >&0 2>&1 sleep 1 done printf "\rGPSD Service...\e[1;32mOk\e[0m\n" >/dev/tty3 #wait while gps fixed echo '?WATCH={"enable":true,"json":true}' | netcat localhost 2947 | nawk -W interactive -v ss=$s -v i=$i '{if(/"mode":0|"mode":1/) { i=(( (i+1) %4 )); gg=substr(ss,i,1); printf "\rWait Gps Sync...%s",gg; fflush(stdout) } else if (/"mode":2|"mode":3/) {exit 0} }' >/dev/tty3 printf "\rGps Sync...\e[1;32mOk\e[0m\n" >/dev/tty3 #wait chrony runing while ! $(/sbin/service "chrony" status | grep -q "Active: active (running)") do i=$(( (i+1) %4 )) printf "\rWait Chrony Service...${s:$i:1}" <>/dev/tty3 >&0 2>&1 sleep 1 done printf "\rChrony Service...\e[1;32mOk\e[0m\n" >/dev/tty3 #wait time is sync while ! $(timedatectl status | grep -q "System clock synchronized: yes") do i=$(( (i+1) %4 )) printf "\rWait Time Sync...${s:$i:1}" <>/dev/tty3 >&0 2>&1 sleep 1 done printf "\rTime Sync...\e[1;32mOk\e[0m " >/dev/tty3 a=$(chronyc tracking | grep "Ref time (UTC)") printf "\e[1;34m${a:17}\e[0m\n" > /dev/tty3 printf "\rGet Grid Square for locator..." >/dev/tty3 a=$(/usr/local/bin/getGridSquare | tee /tmp/.GridSquare) printf "\rGet Grid Square for locator...\e[1;32mOk\e[0m \e[1;34m$a\e[0m\n" >/dev/tty3 #Setup log print in tty5 printf "\rStarting view QSO log..." >/dev/tty3 setsid sh -c 'exec clear <>/dev/tty5 >&0 2>&1' tail -n 10 /home/pi/gcFT8/QSO.log | awk -W interactive -F ' ' '{print $1 " " $2 " " $3 " " $4 " " $5 " " substr($6,0,2) "Mhz" }' | cat >/dev/tty5 tail -n 0 -f /home/pi/gcFT8/QSO.log | awk -W interactive -F ' ' '{print $1 " " $2 " " $3 " " $4 " " $5 " " substr($6,0,2) "Mhz" ; system("/usr/local/bin/beep &") }' | cat >/dev/tty5 & printf "\rView QSO log daemon...\e[1;32mOk\e[0m\n" >/dev/tty3 #Set mode for waveshare screen button K1, K2, K3 /usr/bin/gpio-watch 18:switch 23:switch 24:switch & printf "\r\e[1;32mInit completed!\e[0m\n" >/dev/tty3 #Beep for end of init (/usr/local/bin/beep;/usr/local/bin/beep;)& # Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "IP address:\n\e[1;34m" >/dev/tty3 hostname -I | tr " " "\n" >/dev/tty3 printf "\033[<1>\e[0m\n" >/dev/tty3 fi exit 0 |
/etc/gpio-scripts/18
1 2 3 4 5 6 7 8 9 10 |
#!/bin/bash VAR1=$(cat /tmp/.witchtty) if [ "$VAR1" = "3" ]; then /usr/bin/chvt 5 echo 5 > /tmp/.witchtty else /usr/bin/chvt 3 echo 3 > /tmp/.witchtty fi |
/etc/gpio-scripts/23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#!/bin/bash VAR1=$(cat /tmp/.GridSquare) VAR1=$(echo ${VAR1:0:4}) /usr/bin/chvt 3 echo 3 > /tmp/.witchtty echo "Try lunch gcFT8" > /dev/tty3 if [ "$VAR1" != "0" ]; then ps -eaf | grep -v grep | grep -v tail | grep gcFT8 >/dev/null if [ $? -eq 1 ] then #setsid sh -c 'cd /home/pi/gcFT8 && ./gcFT8 -d plughw:CARD=Transceiver,DEV=0 -C F4HTB -L $VAR1 -S /dev/ttyACM0 -b -F 14074000 <>/dev/tty1 >&0 2>&3' & (cd /home/pi/gcFT8 && (screen -L -Logfile /dev/tty3 -S gcFT8 -dm ./gcFT8 -d plughw:CARD=Transceiver,DEV=0 -C F4HTB -L $VAR1 -S /dev/ttyACM0 -b -F 14074000)) else echo "gcFT8 already running!" > /dev/tty3 fi else echo "Gps not sync!" > /dev/tty3 fi |
/etc/gpio-scripts/24
1 2 3 4 5 6 7 |
#!/bin/bash /usr/bin/chvt 3 echo 3 > /tmp/.witchtty echo "Kill gcFT8." > /dev/tty3 pkill -9 gcFT8 > /dev/tty3 echo -e -n 'RX;' > /dev/ttyACM0 |