commit 6e2dd2a5abf885c55f29758936e8ee73e1f2974a Author: Nico Rey Date: Mon Sep 10 23:15:04 2018 -0300 First commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..66e9da9 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# NOAA Automated capture using Raspberry PI +Most of the code and setup stolen from: [Instructables](https://www.instructables.com/id/Raspberry-Pi-NOAA-Weather-Satellite-Receiver/) +### New Features! + - Nginx webserver to show images + - Timestamp and satellite name over every image + - WXToIMG configured to create several images (HVC,HVCT,MCIR, etc) + +### Manual work + - sudo apt-get install imagemagick nginx predict libusb-1.0 cmake + - Install [rtlsdr](https://github.com/keenerd/rtl-sdr.git) + +### Important notes +- I tried to run this on a Raspberry PI Zero Wifi, no luck. Seems like it's too much load for the CPU. Running on a Raspberry PI 2+ is ok. +- Code was a bit updated on how it handles the UTC vs timezone times. \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..dd07893 --- /dev/null +++ b/index.html @@ -0,0 +1,3 @@ +

WX reception server

+Images +audio diff --git a/nginx.cfg b/nginx.cfg new file mode 100644 index 0000000..b5f79e6 --- /dev/null +++ b/nginx.cfg @@ -0,0 +1,12 @@ +server { + listen 80 default_server; + root /home/pi; + index index.html index.htm index.nginx-debian.html; + autoindex on; + + server_name wx.home wx.reyni.co; + + location / { + try_files $uri $uri/ =404; + } +} diff --git a/receive.sh b/receive.sh new file mode 100644 index 0000000..fe4c2a6 --- /dev/null +++ b/receive.sh @@ -0,0 +1,20 @@ +#!/bin/bash +if pgrep "rtl_fm" > /dev/null +then + exit 1 +fi +# $1 = Satellite Name +# $2 = Frequency +# $3 = FileName base +# $4 = TLE File +# $5 = EPOC start time +# $6 = Time to capture +start=`date '+%d-%m-%Y %H:%M'` +timeout $6 rtl_fm -f ${2}M -s 60k -g 50 -p 55 -E wav -E deemp -F 9 - | sox -t raw -e signed -c 1 -b 16 -r 60000 - /home/pi/audio/$3.wav rate 11025 + +PassStart=`expr $5 + 90` +/usr/local/bin/wxmap -T "${1}" -H $4 -p 0 -l 0 -o $PassStart /home/pi/map/${3}-map.png +for i in ZA MCIR MCIR-precip MSA MSA-precip HVC-precip HVCT-precip HVC HVCT; do + /usr/local/bin/wxtoimg -o -m /home/pi/map/${3}-map.png -e $i /home/pi/audio/$3.wav /home/pi/image/$3-$i.png + /usr/bin/convert /home/pi/image/$3-$i.png -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "$1 $start" /home/pi/image/$3-$i.png +done diff --git a/schedule.sh b/schedule.sh new file mode 100644 index 0000000..62c3b89 --- /dev/null +++ b/schedule.sh @@ -0,0 +1,14 @@ +#!/bin/bash +#wget -qr https://www.celestrak.com/NORAD/elements/weather.txt -O /home/pi/predict/weather.txt +grep "NOAA 15" /home/pi/predict/weather.txt -A 2 > /home/pi/predict/weather.tle +grep "NOAA 18" /home/pi/predict/weather.txt -A 2 >> /home/pi/predict/weather.tle +grep "NOAA 19" /home/pi/predict/weather.txt -A 2 >> /home/pi/predict/weather.tle + +#Remove all AT jobs +for i in `atq | awk '{print $1}'`;do atrm $i;done + + +#Schedule Satellite Passes: +/home/pi/schedule_sat.sh "NOAA 19" 137.1000 +/home/pi/schedule_sat.sh "NOAA 18" 137.9125 +/home/pi/schedule_sat.sh "NOAA 15" 137.6200 diff --git a/schedule_sat.sh b/schedule_sat.sh new file mode 100644 index 0000000..5a9720d --- /dev/null +++ b/schedule_sat.sh @@ -0,0 +1,25 @@ +#!/bin/bash +PREDICTION_START=`/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" | head -1` +PREDICTION_END=`/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" | tail -1` + +var2=`echo $PREDICTION_END | cut -d " " -f 1` + +MAXELEV=`/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" | awk -v max=0 '{if($5>max){max=$5}}END{print max}'` + +while [ `date --date="@${var2}" +%D` == `date +%D` ]; do + START_TIME=`echo $PREDICTION_START | cut -d " " -f 3-4` + var1=`echo $PREDICTION_START | cut -d " " -f 1` + var3=`echo $START_TIME | cut -d " " -f 2 | cut -d ":" -f 3` + TIMER=`expr $var2 - $var1 + $var3` + OUTDATE=`date --date="TZ=\"UTC\" $START_TIME" +%Y%m%d-%H%M%S` + if [ $MAXELEV -gt 19 ] + then + echo ${1//" "}${OUTDATE} $MAXELEV + echo "/home/pi/receive.sh \"${1}\" $2 ${1//" "}${OUTDATE} /home/pi/predict/weather.tle $var1 $TIMER" | at `date --date="TZ=\"UTC\" $START_TIME" +"%H:%M %D"` + fi + nextpredict=`expr $var2 + 60` + PREDICTION_START=`/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" $nextpredict | head -1` + PREDICTION_END=`/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" $nextpredict | tail -1` + MAXELEV=`/usr/bin/predict -t /home/pi/predict/weather.tle -p "${1}" $nextpredict | awk -v max=0 '{if($5>max){max=$5}}END{print max}'` + var2=`echo $PREDICTION_END | cut -d " " -f 1` +done