For Beginners - How to Set / Change Gain

CASE-1

Piaware SD Card image written to microSD card

(Piaware Image downloaded from PiAware - build your own ADS-B ground station for integration with FlightAware - FlightAware )

(a) In this example gain is set to 30. Instead of 30 use the gain value you want to set
(b) Gain is set to 29.7 instead of 30 as shown in last line. This is due to fact that dongle cannot be set to any value, but to one of the permissible values nearest to the value you specify in the gain setting command.

Step-1:
Set gain to value 30 by giving following command:

pi@piaware:~$ sudo piaware-config rtlsdr-gain 30

#The above command will output following:
Set rtlsdr-gain to 30 in /boot/piaware-config.txt:60

.
Step-2:
Restart dump1090-fa to implement the newly set gain value
pi@piaware:~$ sudo systemctl restart dump1090-fa

.
Step-3:
Verify that the new value of gain is actually implemented
pi@piaware:~$ sudo systemctl status dump1090-fa -l

Last line of output of above command
piaware dump1090-fa[1254]: rtlsdr: tuner gain set to 29.7 dB

.

CASE-2

Raspbian image written to microSD card, then Piaware Add-on Package and dump1090-fa Add-on package installed

(Raspbian image downloaded from Raspberry Pi OS ā€“ Raspberry Pi
Piaware and dump1090-fa Add-on packages installed as per instructions on PiAware - dump1090 ADS-B integration with FlightAware - FlightAware )

(a) In this example gain is set to 30. Instead of 30 use the gain value you want to set
(b) Gain is set to 29.7 instead of 30 as shown in last line. This is due to fact that dongle cannot be set to any value, but to one of the permissible values nearest to the value you specify in the gain setting command.

Step-1:
Open file /etc/default/dump1090-fa in nano to edit it
sudo nano /etc/default/dump1090-fa

Above command will open file /etc/default/dump1090-fa which has following content:

# dump1090-fa configuration
# This is read by the systemd service file as an environment file,
# and evaluated by some scripts as a POSIX shell fragment.

# If you are using a PiAware sdcard image, this config file is regenerated
# on boot based on the contents of piaware-config.txt; any changes made to this
# file will be lost.

RECEIVER_OPTIONS="--device-index 0 --gain -10 --ppm 0 --net-bo-port 30005"
DECODER_OPTIONS="--max-range 360"
NET_OPTIONS="--net --net-heartbeat 60 --net-ro-size 1000 --net-ro-interval 1 --net-ri-port 0 --net-ro-port 30002 --net-sbs-port 30003 --net-bi-port 30004,30104 --net-bo-port 30005"
JSON_OPTIONS="--json-location-accuracy 1"

.
Step-2:
In the line starting with RECEIVER_OPTIONS, change the gain value from -10 to the required value. In this example it will be changed to 30.

Line before change:
RECEIVER_OPTIONS=ā€œā€“device-index 0 ā€“gain -10 --ppm 0 --net-bo-port 30005ā€

Line after change:
RECEIVER_OPTIONS=ā€œā€“device-index 0 ā€“gain 30 --ppm 0 --net-bo-port 30005ā€

After changes are made as above, save changes (Ctrl+o) and close file (Ctrl+x)

Step-3:
Restart dump1090-fa to implement the newly set gain value
pi@raspberrypi:~ $ sudo systemctl restart dump1090-fa

.
Step4:
Verify that the new value of gain is actually implemented
pi@raspberrypi:~ $ sudo systemctl status dump1090-fa -l

The last line of output of above command will show gain actually set
piaware dump1090-fa[1254]: rtlsdr: tuner gain set to 29.7 dB

13 Likes

I used ā€˜Case 2ā€™ above because i installed piaware & dump1090-fa using apt-get etc. Is that correct?

Setting gain to 29.7 is what i did. But is the change from -10 to +29.7 thatā€™s a change of 40dB. Is that going to cause problems? Should i set it to some other value?

Iā€™m using a FA Pro dongle, an RPi3, and a 1/4 wave ground plane antenna set by the window indoors.

Thanksā€¦

1 Like

Yes, you used the correct case.

Whenever you want to check if you have used correct method and the gain has actually set to the desired value, give following command and read the LAST line of output. It will show what gain value is actually set.

sudo systemctl status dump1090-fa -l
.

.

  1. The dongle gain can only be set to a value between 0 and 49.6
  2. The dongle does NOT accept any negative (-) value of gain.
  3. The gain value -10 is a special number. It does NOT sets gain to -10 . It SWITCHES dongle into AGC mode (Automatic Gain Control mode). In this mode the dongl dynamically adjusts gain according to received signal strength.

The -gain 30 given in the ā€œHow Toā€ was an example only, and did not mean you adjust your dongle to it. The gain value to be used varies over a wide range, depending on antenna, location, dongle, amplifier etc. The optimum value for any setup is to be determined by trial and error i.e. try different values of gain and watch performance for each value of gain.

For your setup with 1/4 wave ground plane antenna indoors, the best is to keep it at the default setting of AGC (i.e. at --gain -10)

3 Likes

Is there any case where auto gain mode is better than setting it manually?
I am in area with lot interference. I have a blue pro stick plus with FA antenna and external filter as well.

1 Like

It leads to gain value of around 55, which is higher than anything you can set directly (a bug, if you like), so if you need or want the highest possible gain value, it is the right choice.

AGC would work with a TV signal which is constantly transmitted, but does not with the many short and different ads-b signals.

3 Likes

What gain are you at currently?

If you have really strong transmissions i can imagine that the ProStick is not performing well even with a filter. (External LNAs are usually better at handling strong interfering signals than the ProStick)

Anyway if you are blocked by houses all around and the antenna is not above them then there is little you can do.

Currently I am at 48 and definitely blocked by lot buildings.

Most likely you wonā€™t get good range anyway because of the buildings.
It might be beneficial to reduce gain quite a bit further if you want to receive all the close-in signals.

See this thread for some advice on the topic: Thoughts on optimizing gain - #2 by wiedehopf
(the first post of the linked thread is some more explanation on the topic)

1 Like

Thanks, one of my feeder is at 18%, will try optimizing and lowering it

I followed the guidelines in the mentioned thread(s) to reduce the gain but what should be the target maximum RSSI? I am under a flight path for Boston Logan inbound so there are jets coming over around 15,000 ft at an offset of less than a mile. I was losing track of these so I changed from -10 AGC and ended up at 30 to get the max RSSI to about -3 (range is now down to -39 for distant signals). Should I go higher than -3 for the strongest? My ā€œPercentage of strong messagesā€ is about 0.2 at this point but I am definitely seeing more local traffic, including takeoffs and landings at the local airport (KFIT, about 3 miles away as the crow-without-ADS-B flies but not quite line of sight).

Iā€™d go higher, maybe -1.5.
Basically you increase gain until the local traffic gets worse and then you go back down one or two steps.

Ok, it does look like the local traffic is about -1.5 and the overhead jets go up to -5 or so. Iā€™m getting over 80 flights, some close to 200 mi away so Iā€™m happy and will leave it like this for a while. Iā€™m running a RPi 3 B with the Pro Stick Plus and the FA green antenna in the peak of my attic.

1 Like

If you want all the local traffic you will have to sacrifice some range.
This can be especially true for an antenna in the attic as the attenuation differs by direction.

1 Like

Yup, and thatā€™s ok. Seems to be enough coverage in general, so the local contribution is a bonus.

Thanks.
Before reading this how to, I did not realize that there are 2 different methods, one for piaware sd card image, and other for raspbian image with package install.

1 Like

For me as beginner this explanation was very helpful. Thanks.

Also how to check the optimation on Thoughts on optimizing gain - #2 by wiedehopf was interesting.

But for impatient people waiting after each change at least 5 minutes are quite long. So I found a workaround, not very exact, quick and dirty.

First, check the actual 1090 data, for example http://your-adsb-ip/dump1090/ or http://your-adsb-ip/tar1090/ and note the number of planes.
Then change the values, reload the page and re-check the number of planes.
The difference is a good indice if a optimation is necessesary and if you move in the right direction.
In my case with -10 gain I saw around 80 planes, with 30 gain there were only 4 planes left. Also gain 20, 10 and 0 marked less planes on the 1090 page. With -10 it was okay again.
So no optimation is necessary.
It looks that with a wrong optimation the results are even worse, so it is not necessary for all installations.

Thatā€™s just for the rough adjustment.
After that you just check the percentage the next day and adjust one step.

What is the percentage displayed for you at gain of -10?

Thatā€™s explainable, because 20, 10 and 0 means usually less planes as itā€™s less than 30

-10 in reality is higher than 49.6 which marks the maximum gain to be set manually.
Means, you need to step from -10 to 49.6 or lower to reduce gain, not to improve it.

After one week, the command
awk ā€œ$(cat /run/dump1090*/stats.json| grep total | sed ā€˜s/.accepted":[([0-9]).strong_signals":([0-9]).*/BEGIN {printf ā€œ\nPercentage of strong messages: %.3f \nā€ , \2 * 100 / \1}/ā€™)ā€
marks
Percentage of strong messages: 0.274

My station is far away from a airport with a lot of traffic.
10 km away is Bern-Belp (LSZB) with low traffic.
1 km from my station is the hospital where ambulance-helicopters come to bring and get patients.
You can see my traffic on https://de.flightaware.com/adsb/stats/user/ChristopherRobert .

Should I try to optimize gain, or does it look like this will be worse?
If I should change, which setting do you propose?

Thanks, best regards from Switzerland
Christopher

No need to reduce gain with that percentage.
As written in the ā€œThoughts on gainā€ thread iā€™d normally increase gain with below 1 percent and reduce gain for values above 5 percent.
But as you canā€™t increase gain, no need to change anything.

What antenna are you using?
If you have magnetic base antenna, iā€™d recommend this thread: How to improve performance of whip antenna of DVB-T

1 Like