B1N9's ADSB Scripts & Tools (GAIN_CHECK_v3.py) (STATSV2 not released)

let me do this for you a little better
the gains you want are in double quotes space deliminated so if you want to do gains 1, 5, 10 you would set it up like

gain_choice = “1 5 10”

if you want to do gains 1, 2, 3, 4, 5 it would be

gain_choice = “1 2 3 4 5”

as a note the standard SDR’s that people use can only use certain gains and those are all predefined in the variable gains_all_00

aka if you ask the SDR to gain 1 it will choose the gain that it can use closest to the choice you made aka 0.9

that is why i have the variables setup for you if you want to test all gains from 0 to 20 combine the 2 variables gains_00_10 and gains_10_20 like

gain_choice = “0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7”

# GAIN SETTINGS (DON'T CHANGE)
gains_step_5			= "12.5 15.7 20.7 25.4 29.7 36.4 40.2 44.5 49.6"
gains_step_10 			= "12.5 20.7 29.7 40.2 49.6"

gains_40_50				= "40.2 42.1 43.4 43.9 44.5 48.0 49.6"
gains_30_40				= "29.7 32.8 33.8 36.4 37.2 38.6 40.2"
gains_20_30				= "20.7 22.9 25.4 28.0 29.7"
gains_10_20 			= "12.5 14.4 15.7 16.6 19.7 20.7"
gains_00_10 			= "0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5"

gains_all_40 			= "40.2 42.1 43.4 43.9 44.5 48.0 49.6"
gains_all_30 			= "29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6"
gains_all_20 			= "20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6"
gains_all_10			= "12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6"
gains_all_00			= "0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6"

# REQUIRED SETTING
antenna_lat				= 52.24748
antenna_lon				= 0.71023
pass_duration			= 60
pass_number				= 5
gain_choice				= "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21"

Thankyou so much
i learned alot from your answers making it easy to work out what i wasnt didnt do
john

Do you see any errors that would prevent this from running on my Pi? Im still getting errors with BeautifulTable

pi@raspberrypi:~ $ sudo python3 gain_check_v3.py
Traceback (most recent call last):
File “gain_check_v3.py”, line 4, in
from beautifultable import BeautifulTable
File “/usr/local/lib/python3.5/dist-packages/beautifultable/init.py”, line 5, in
from .beautifultable import ( # noqa F401
File “/usr/local/lib/python3.5/dist-packages/beautifultable/beautifultable.py”, line 46, in
from .helpers import (
File “/usr/local/lib/python3.5/dist-packages/beautifultable/helpers.py”, line 293
raise Warning(f"Column header is not provided or invalid")
^
SyntaxError: invalid syntax

FYI …
My setup uses Airspy R2 hence i added line
gain_choice = “1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21”

2 Likes

@RdRocket16 your issue looks like you don’t have beautifultable installed so run the install stuff below 1 line at a time.

sudo apt update
sudo apt install python3
sudo apt install python3-pip
sudo pip3 install beutifultable

run each line individually and make sure all that they are successfull then you can run the script if you are in the same folder as follows and as I write this i notice that my run command in the first post doesn’t have the ./ in it so i will update that.

sudo python3 ./gain_check_v3.py

i see i didn’t know that airspy had different gain settings I will put that option in for future versions.

2 Likes

I followed that exactly.
I re did them anyway, still get a syntax error.

ahhh ha I see the issue.

beautifultable dropped support for Python 3.4, 3.5, 3.6 in its newest version so since you are running python 3.5 you need to update it to a newer version or need to downgrade beautifultable to a previous version.

let me get the commands to do the python update for you.

could you please run and paste the following

python3 –version

Ah! Ok.
Python 3.5.3
Old I’m sure.

1 Like

I believe all you need to do is the following as it works on mine but I already have 3.7 installed

sudo apt install python3.7 

however there may be more steps depending you can also install an older version of beautifultable if this doesn’t work like:

check the versions you can install:

sudo pip3 install beautifultable==

uninstall beautifultable

sudo pip3 uninstall beautifultable

install version 1.0.1

sudo pip3 install beautifultable==1.0.1
1 Like

Thanks! apparently Python 3.7 is a bridge too far (for now, planning on upgrading my pi with newer software, but I have a couple of packages running which are … delicate to say the least lol) but! beautifultable==1.0.1 worked perfectly and its showing up now! Thanks!!!Thanks!!!Thanks!!!Thanks!!!

1 Like

Can you tell me what other changes you made to get this to work with airspy? I am not using readsb. Here is what I changed…

REQUIRED SETTING

antenna_lat = 39.xxx
antenna_lon = -76.xxx
pass_duration = 10
pass_number = 5
gain_choice = “1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21”

AIRSPY_ADSB SD SETTINGS (comment out and uncomment other settings to switch)

host = ‘localhost’
port = 30004
config_file = ‘/etc/default/airspy_adsb’
config_setting = ‘GAIN=’
config_setting_after = ‘’
service_restart_cmd = ‘sudo systemctl restart airspy_adsb’

1 Like

I have run this script on my setup. Below is what it has given (I am still using the Nooelec NESDR Mini):
What should I do with this information? Asking for other novices.

Disregard, I was using wrong port.

glad to hear you got it sorry about the delay in my response there.

hey so since you don’t have a lot of planes around you at the time you ran this, I would ask you to run it again in general when you have more planes like 2-4 pm in your timezone. I would also suggest you run more passes or longer passes or both.

Like 30 seconds a pass and 10 passes on the gains.

This will allow the data to normalize better so the picture will be more clear.

However according to the data you got it looks like you should set your gain to 32 and turn off adaptive gain and burst.

Hi. Thank you so much for the response. For starters, allow me to state that I am a complete novice in this ADSB stuff so I may not understand much beyond setting my LAT, LOG and ELEVATION values :slight_smile:
So I will run this again as suggested (I have changed pass_duration to 30 and pass_number to 10) and I will run the script at around that time. BTW what data in there tells you that there are many planes around 2-4 pm? Pardon my ignorance.

I am yet to get a good RTL-SDB unit (coming in about 3 weeks) and a good antenna/positioning.
So, with the suggestion that I set my gain to 32 and turn off adaptive gain and burst, what I need to SET in /etc/defaults/dump1090-fa is:

RECEIVER_GAIN=32                   # This was set to 60 initially
ADAPTIVE_DYNAMIC_RANGE=no          # This was set to yes initially
ADAPTIVE_BURST=no                  #This was already the default

…and restart dump1090-fa.
But after doing that, does it still make sense to run the script, or should I wait to run the script around the suggested time and then only make changes after?

Hi. Here is the result of running longer passes:

Any recommendations?

What port did you use?

Trying as folows, but do not get any data:

#AIRSPY_ADSB SD SETTINGS (comment out and uncomment other settings to switch)
host = 'localhost'
port = 30005
config_file = '/etc/default/airspy_adsb'
config_setting = 'GAIN='
config_setting_after = ''
service_restart_cmd = 'sudo systemctl restart airspy_adsb'

I don’t suppose anyone has this working with the docker version of piaware, readsb or readsb-protobuf?
If you have would you mind sharing please.