How to Track Satellite Fly-Bys with Raspberry Pi

How to Track Satellite Fly-Bys with Raspberry Pi
(Image credit: Tom's Hardware)

With SpaceX’s Starlink being made available in my area, I became curious about just how many satellites were overhead at any given time. Fortunately, the US Space Command tracks and makes available data for tracking the live positions of objects in orbit. We can download this data, and use a Raspberry Pi and some speakers to announce when a particular satellite is making an overhead pass. You can also get an SMS message sent to your phone in addition to the audio

What You’ll Need For This Project 

How to make a Raspberry Pi Satellite Tracker 

Before you get started, make sure that you have your Raspberry Pi OS set up. If you haven’t done this before, see our article on how to set up a Raspberry Pi for the first time or how to do a headless Raspberry Pi install (without the keyboard and screen).

1. Install git, which will allow us to clone the code from github.com

sudo apt-get update && sudo apt-get install -y git

2. Clone the repository and descend into the directory created.

git clone https://github.com/rydercalmdown/pi_satellite_announcer.git
cd pi_satellite_announcer

3. Run the installation command. It will take care of installing a virtual environment, any necessary low level dependencies, and the python requirements.

make install

4. Visit space-track.org and create a new account. This will let us download two-line element (TLE) data tracked by  the US Space Command. The code will update data from this website once per day, and store it locally to minimize stress on their servers.

(Image credit: Tom's Hardware)

5. Once registered, return to your raspberry pi and edit your environment.sh file - replace the template values with your space-track username and password. 

nano environment.sh

# Your spacetrack credentials
# export SPACETRACK_USERNAME=youremail@example.com
# export SPACETRACK_PASSWORD=your_spacetrack_password

6. Retrieve your home latitude and longitude values from Google maps by right clicking on the map and selecting the first option.

(Image credit: Tom's Hardware)

7. Copy your latitude and longitude values into environment.sh, and set your desired radius in kilometers. For example, a radius of 20 kilometers would only report satellites overhead if their position on the ground is less than 20 kilometers away from you - they could be at any altitude. 

(Image credit: Tom's Hardware)

8. Plug in speakers to the 3.5mm audio port on your raspberry pi, and test that you can hear them with the following command. I’m using a megaphone, but any speakers with a 3.5mm audio input will work.  You may need to increase the volume with the alsamixer command. If you run into trouble, try configuring your audio in the raspi-config menu. 

# Test speakers
espeak -a 200 "this is a test" --stdout | aplay
# Adjust volume
alsamixer

(Image credit: Tom's Hardware)

 9. Set up a twilio account. We’ll use this to send a text message when a satellite appears overhead. If you don’t wish to use twilio, you can edit app.py and set the ‘use_twilio’ variable to False.

10. Follow the setup instructions for a twilio account. Detailed instructions can be found on Twilio’s site here. You will need to create a phone number, and get your account credentials to perform the send actions.

11. Once you have your credentials and phone number, Add them to the environment.sh file.

nano environment.sh

# Twilio credentials
export TWILIO_ACCOUNT_SID=your_account_id
export TWILIO_AUTH_TOKEN=your_account_token

# the number you purchased with twilio
export TWILIO_NUMBER_FROM=+10000000000

# your phone number
export TWILIO_NUMBER_TO=10000000000

12. Run the code with the following command. It will connect to space-track, download the latest TLE data, and immediately start reporting satellites over the latitude, longitude, and radius provided in the environment.sh file.

make run

(Image credit: Tom's Hardware)

13. Play around with the code. Right now it only announces satellites that are not considered debris, but this can be adjusted easily. You can also filter down by constellation, or only announce satellites with names that are interesting to you, like the international space station (ZARYA). 

Ryder Damen
Freelance Writer

Ryder Damer is a Freelance Writer for Tom's Hardware US covering Raspberry Pi projects and tutorials.

  • daveer7551
    sorry, noob:
    pi@custompi:~/pi_satellite_announcer $ make run
    /bin/sh: 1: .: environment.sh: not found
    make: *** Error 2
    pi@custompi:~/pi_satellite_announcer $ ls
    deployment env environment.sh Makefile README.md src
    Reply
  • jridder
    I got the same error.
    Reply
  • nkverma
    change your environment.sh path in makefile like this
    @. env/bin/activate && . /home/neo/pi_satellite_announcer/environment.sh && cd src && python app.py
    Reply
  • Jon P
    Looks like it's not announcing many of the satellites. I'm interested in the ham satellites but when they pass overhead only a few are occasionally announced. When the program is first run it notes that it only loaded 22867 of 47495 satellites, so perhaps for some reason it's eliminating the satellites of interest. Any way to alleviate this issue?

    Interesting - this time when I reran it loaded 45k of the satellites after a message that it was saving the TLE cache and saving metadata. Perhaps there was some initialization problem. I'll monitor it later.
    Reply
  • PI-Builder
    I tried install and running the satellite tracking program and running it. Was not successful when I got to "make run."

    The error I am getting then "make run." Does anyone have any ideas how to fix the problem?

    Error:

    pi@raspberrypi:~/pi_satellite_announcer $ make run
    /bin/sh: 1: .: environment.sh: not found
    make: *** Error 2

    Makefile information:

    .PHONY: run

    run:

    @. env/bin/activate && . environment.sh && cd src && python app.py

    .PHONY: install

    install:

    @CD deployment && bash install.sh
    Reply
  • ajcroteau
    Any chance this could be run on a mac or pc? Possibly within a docker container?

    Thanks
    AJ
    Reply