2

I have the following script that downloads and processes NOAA satellites. I'd really like some external LEDs to indicate the following;

  1. When the script is running, turn or blink red
  2. When the script is not running, turn or blink green
  3. When the script is within 1 hr of running, turn or blink yellow

I need some assistance in getting a traffic light working WHILE the script is running. I don't know if it's better to call certain other scripts or embed into the existing code (not sure where to do this). I have the LEDs on a breadboard and working fine. Any assistance would be appreciated...thanks.

Further Details on PI GPIO = Red 10, Yellow 9, Green 11

#!/bin/bash
# $1 = Satellite Name
# $2 = Frequency
# $3 = FileName base
# $4 = TLE File
# $5 = EPOC start time
# $6 = Time to capture
# reads and creates folder with current date / time (i.e 05-30-2019_07-48 *windows friendly*)
NOW=$(date +%m-%d-%Y_%H-%M)
mkdir /home/pi/weather/${NOW}
sudo timeout $6 rtl_fm -f ${2}M -s 60k -g 45 -p 55 -E wav -E deemp -F 9 - | 
sox -t wav - $3.wav rate 11025
PassStart=`expr $5 + 90`
if [ -e $3.wav ]
then
/usr/local/bin/wxmap -T "${1}" -H $4 -p 0 -l 0 -o $PassStart ${3}-map.png
#/usr/local/bin/wxtoimg -m ${3}-map.png -e ZA $3.wav ${3}.png
#/usr/local/bin/wxtoimg -m ${3}-map.png -e NO $3.wav ${3}.NO.png
#/usr/local/bin/wxtoimg -m ${3}-map.png -e MCIR $3.wav ${3}.MCIR.png
#/usr/local/bin/wxtoimg -m ${3}-map.png -e MSA $3.wav ${3}.MSA.png
fi

#CODE FROM https://forums.qrz.com/index.php?threads/weather-satellite script-help-raspbian.614971/page-7...added 1.17.2020
/usr/local/bin/wxtoimg -m ${3}-map.png -e ZA $3.wav ${3}.png
/usr/local/bin/wxtoimg -m ${3}-map.png -e NO $3.wav ${3}.NO.png
/usr/local/bin/wxtoimg -m ${3}-map.png -e MCIR $3.wav ${3}.MCIR.png
/usr/local/bin/wxtoimg -m ${3}-map.png -e MSA $3.wav ${3}.MSA.png
/usr/local/bin/wxtoimg -m ${3}-map.png -e HVCT $3.wav ${3}.HVCT.png
/usr/local/bin/wxtoimg -m ${3}-map.png -e therm $3.wav ${3}.Thermal.png
/usr/local/bin/wxtoimg -m ${3}-map.png -e JF $3.wav ${3}.JF.png
# copies files to the new folder and deletes the original ones
cp /home/pi/weather/*.png /home/pi/weather/${NOW}/
cd /home/pi//weather/${NOW}/
rm /home/pi/weather/${NOW}/*-map.png
rm /home/pi/weather/*.png
rm /home/pi/weather/*.wav
#END
dandspach
  • 21
  • 2
  • Hi @dandspach, Welcome and nice to meet you. Ah, let me see. Your NOAA satellite project is very interesting. Can you tell me the web link of the tutorial for writing your bash script? I think it is easier to do that in python which you can find loads of newbie tutorials blinking LEDs with something called "GPIO" . References: (1) NOAA: https://en.wikipedia.org/wiki/National_Oceanic_and_Atmospheric_Administration (2) NOAA Satellites - Wiki https://en.wikipedia.org/wiki/List_of_NOAA_Satellites, (3) Rpi GPIO Tutorial - PiMyLife https://pimylifeup.com/raspberry-pi-gpio/ – tlfong01 Jan 30 '20 at 01:35
  • Sure...I'm familiar with turning LEDs on and off in Python, but not inside of a script. I don't know if I can call a Python script from a bash script. I basically followed the directions in the following: [https://www.instructables.com/id/Raspberry-Pi-NOAA-Weather-Satellite-Receiver/) – dandspach Jan 30 '20 at 01:59
  • Also, some of my results are posted at: [http://www.ycars.org/] – dandspach Jan 30 '20 at 02:04
  • (1) You enclosed yacrs.org in square brackets and this confuses the forum software here. (2) I am not sure if python imbedded in bash script is the way to go, I would prefer to do the other way around, bash ("os" commands) inside a python script. If you already know how to turn on/off LED in python, then you can explore a little bit, and perhaps write you answer here. I guess many bash/python guys would love to help you along. – tlfong01 Jan 30 '20 at 02:40
  • I have not used SDR before, though I can do basic GPS, also catch satellites. I am googling reference to refresh my memory, to see if I can join in your python project. References: (4) Receiving NOAA Weather Satellites with an SDR and a Rasperry Pi - 52,591 views 33 People Made This Project! 2017jan08 https://www.youtube.com/watch?time_continue=5&v=jukobjB46gQ&feature=emb_logo (5) Building a quadrifilar helix antenna (QFH) for NOAA satellite reception with an RTL-SDR https://www.youtube.com/watch?v=KU75FSA6o2M&feature=youtu.be – tlfong01 Jan 30 '20 at 02:42
  • (6) Building a 3 Foot Tall Wooden Nutcracker Hearth Decoration #2 - Jim Haslett https://www.youtube.com/watch?time_continue=21&v=9nRKs3njhzw&feature=emb_logo (7) AliExpress SDR Dongle Catalog https://www.aliexpress.com/w/wholesale-sdr-dongle.html – tlfong01 Jan 30 '20 at 02:43
  • (8) Kebidumei DVB-T + DAB + FM RTL2832U + R820T2 digital USB 2.0 TV stick Mini video Dongle Support SDR Tuner receiver + antenna https://fr.aliexpress.com/item/32956742013.html?spm=a2g0o.productlist.0.0.36932626W386xZ&algo_pvid=f4d41225-f764-4660-8988-fac6b4f92f31&algo_expid=f4d41225-f764-4660-8988-fac6b4f92f31-7&btsid=ae34dab6-fb8f-4b66-aa3d-c7da40095096&ws_ab_test=searchweb0_0,searchweb201602_9,searchweb201603_53 (9) YCARS - The York County Amateur Radio Society http://www.ycars.org/ – tlfong01 Jan 30 '20 at 02:43
  • (10) Rpi UART to GPS Module Connection Problem - tlfong01 https://raspberrypi.stackexchange.com/questions/98840/rpi-uart-to-gps-module-connection-problem – tlfong01 Jan 30 '20 at 02:43
  • And I think this answer might help: (11) Running shell command in python https://raspberrypi.stackexchange.com/questions/58212/running-shell-command-in-python. Happy python/bash programming. Cheers. – tlfong01 Jan 30 '20 at 02:48
  • Ah, I forgot to introduce myself. "About me" is in the *third and fourth comments* of the follow question: "Using GPIO between two radio programs" https://raspberrypi.stackexchange.com/questions/99058/using-gpio-between-two-radio-programs.Cheers. – tlfong01 Jan 30 '20 at 02:56

1 Answers1

0

Got it. Very simple...in BASH

#Defines gpio pin direction
gpio -g mode 17 out #green
gpio -g mode 27 out #yellow
gpio -g mode 22 out #red

#Turns off GREEN led
gpio -g write 17 0

#Turns on RED led
gpio -g write 22 1
Greenonline
  • 2,448
  • 4
  • 18
  • 33
dandspach
  • 21
  • 2