This is a logger for ADS-B receivers that stores all received flights and basic flight information. To keep it lightweight, data such as aircraft locations are not stored.
- Logging of all flights detected by your ADS-B receiver, including flight number, registration, aircraft type, and timestamp of first contact
- Logging of record values such as highest altitude, highest speed, and longest distance from receiver
- Runs parallel to any installed feeders (e.g., Flightradar24, adsb.fi) and does not interfere
- Storage in a SQLite database that can be further processed, e.g., by Grafana for visualization
- Can be run as Linux systemd service or simply as python call
- Prints statistics such as total flights per day, most common airlines, or record values. Here is a shortened example:
STATISTICS PER DAY
+--------------------+-----------+-------------+-----------+---------+
| Day (local time) | Entries | Addresses | Flights | Types |
+====================+===========+=============+===========+=========+
| Database total | 319456 | 18246 | 34201 | 481 |
| Today until now | 2849 | 1764 | 2130 | 146 |
| Yesterday | 3945 | 2945 | 3217 | 143 |
+--------------------+-----------+-------------+-----------+---------+
MOST COMMON ENTRIES
+----------+---------+ +-----------+---------+ +----------------+---------+ +--------+---------+
| Flight | Count | | Airline | Count | | Registration | Count | | Type | Count |
+==========+=========+ +===========+=========+ +================+=========+ +========+=========+
| DLH123 | 76 | | DLH | 31670 | | D-ABCD | 432 | | A320 | 43621 |
| SWR456 | 73 | | UAL | 13792 | | OE-ABC | 419 | | B738 | 39125 |
| AUA123 | 68 | | UAE | 3498 | | HB-ABC | 384 | | A20N | 26457 |
+----------+---------+ +-----------+---------+ +----------------+---------+ +--------+---------+
RECORD VALUES
+---------------+------------+----------------+--------+----------+---------------------+
| Record | Value | Registration | Type | Flight | Time |
+===============+============+================+========+==========+=====================+
| alt_baro_max | 94300 | N12345 | A359 | UAL123 | 2023-10-24 05:00:47 |
| ias_max | 723 | D-ABCD | CRJ9 | DLH123 | 2023-10-06 14:07:11 |
| ias_min | 51 | D-EFGH | C172 | DEFGH | 2023-10-18 13:24:51 |
| mach_max | 0.9 | OE-ABC | GA6C | AUA123 | 2023-10-23 09:29:37 |
| r_dst_max | 264 | HB-ABC | A20N | | 2023-10-07 17:54:15 |
+---------------+------------+----------------+--------+----------+---------------------+
- As prerequisite for the ADS-B Logger, an ADS-B receiver is necessary that processes and broadcasts received flight information on the local network via JSON format (
aircraft.jsonfile). The ADS-B Logger has been developed for readsb, but may work with other decoders as well. - The
aircraft.jsonfile is continuously parsed for aircraft data provided by the ADS-B receiver. - Distinctive aircraft (ICAO HEX code) and flights (airline flight numbers) are stored in a database, along with the first time of contact, aircraft registration (if available) and aicraft type (if available).
- As default setting, a flight is considered unique for one hour from initial contact, allowing the detection of multiple flights by the same aircraft within one day. This is especially relevant for general aviation flights without specific flight number. The threshold of one hour can be configured in the settings.ini file as required.
- Information regarding currently seen flights and tracked recent flights are written to the service logs or screen in certain time intervals.
- The ADS-B Logger uses a lightweight SQLite database, and no database server is necessary.
- Other tools, such as Grafana, may be used to read the database and visualize received flight information.
- Flights are added to the database in certain time intervals to reduce the number of database writes.
- When the ADS-B Logger service terminates, all tracked flights in the cache are written to the database.
- When the ADS-B Logger service starts, recent flights (i.e., within the last hour per default) are read for tracking from the database, allowing the logger to continue when it is restarted.
- The ADS-B Logger stores record values for lowest/highest barometric/geometric altitude, ground speed, indicated airspeed, mach number, vertical speed, distance to the receiver, and other information.
- The record values are stored together with a timestamp and information about the flight/aircraft that set the respective record.
readsbADS-B decoder: https://github.com/wiedehopf/readsb- Wiedehopf's very helpful wiki on ADS-B receivers: https://github.com/wiedehopf/adsb-wiki/wiki
- Information on
aircraft.jsondata fields: https://github.com/wiedehopf/readsb/blob/dev/README-json.md#aircraftjson-and---json-port
All settings, such as the database path and the timeout for treating a flight as unique, are stored in the settings.ini file. The file can be adjusted by the user as necessary.
- Clone this repo to a local folder, e.g.,
/var/adsb-logger/:cd /var/ sudo git clone git@github.com:Griffsano/adsb-logger.git - Configure the settings.ini file as required, e.g.,
cd /var/adsb-logger/ sudo nano settings.ini
It is suggested to try variant 1 before setting up the service (variant 2) to ensure that the logger is working as intended.
- To simply run the ADS-B Logger in your terminal, run the main file:
python main_noservice.py - The ADS-B Logger can be stopped by pressing
CTRL + C.
-
Create a new user for the service:
sudo useradd -r -s /bin/false adsb_logger -
Ensure the new user has write access to this folder:
sudo chown adsb_logger:adsb_logger adsb-logger --recursive -
Create new serviced file:
sudo nano /etc/systemd/system/adsb-logger.service -
Copy the content of the adsb-logger.service file,and modify the service settings as required (e.g., paths). The
python3 -uis for the unbuffered Python mode to immediately show printouts in the journal log. The environmentPYTHONUNBUFFERED=1is redundant to the-uargument. -
Enable and start the new service:
sudo systemctl daemon-reload sudo systemctl enable --now adsb-logger.service sudo systemctl start --now adsb-logger.service -
Access the log files via
journalctl:sudo journalctl -u adsb-logger.service -f
ADS-B data does not contain the aircraft registration and aircraft type.
An additional database is necessary to provide this data based on the unique 24-bit ICAO identifier assigned to the aicraft.
The following adds the registration and aircraft type to aircraft.json.
The folder paths may have to be modified as required.
-
Download the aircraft database:
wget -O /usr/local/share/tar1090/aircraft.csv.gz https://github.com/wiedehopf/tar1090-db/raw/csv/aircraft.csv.gz -
Update the
readsbconfiguration:sudo nano /etc/default/readsbAdd the following setting to, e.g.,
JSON_OPTIONS:--db-file=/usr/local/share/tar1090/aircraft.csv.gzOptionally, you can also add
--db-file-ltfor adding the long aircraft type name in addition to the short ICAO aircraft type. -
Restart
readsb:sudo systemctl restart readsb.service -
Sources / further reading:
Print tables with statistics by calling the show_statistics.py file:
python3 show_statistics.py
The ADS-B Logger was inspired by:
- wesmorgan1's reddit post: https://www.reddit.com/r/ADSB/comments/rutot0/python3_script_to_profile_dump1090_output_and
- wiedehopf2342's comments for performance optimization
- nfacha's adsb-stats-logger, a similar project: https://github.com/nfacha/adsb-stats-logger
Thank you for your inspiration!