Stream Aircraft AM ATC to Broadcastify using RTL-SDR

Status
Not open for further replies.

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
Not sure what happened with the end of line formatting with my last post. The code should look like this:

sudo /usr/local/bin/rtl_fm -d 0 -M fm -f 482.863M -g 20 -p 19 -l 75 -t 10 -s 12k -E pad | \
/usr/bin/lame -r -s 12 --resample 22.05 -m m --cbr --lowpass 4 --highpass 0.241 - - | \
/usr/bin/ezstream -q -c /etc/ezstream_bcfy.xml > sudo reboot &
 

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
Found out what was happening with the copy and paste problems in the #50 post above. Using VNC with low resolution screen does strange things to text lines that are pasted from a remote computer if it doesn't fit inside the rpi's nano editing window. To over come the problem, I sliced up the line length by adding backslashes. Also created an executable file called "/etc/startstream.sh" and pasted the code into the new file as follows:

#!/bin/bash
sleep 20
sudo /usr/local/bin/rtl_fm -d 0 -M fm -f 482.863M \
-g 20 -p 19 -l 75 -t 10 -s 12k -E pad | \
/usr/bin/lame -r -s 12 --resample 22.05 -m m \
--cbr --lowpass 4 --highpass 0.241 - - | \
/usr/bin/ezstream -q -c /etc/ezstream_bcfy.xml > sudo reboot &

then just added one line to the default /etc/rc.local file near the end just before the 'exit 0' line:
sudo /etc/startstream.sh

Also had to set the file permissions for executable. At a command prompt type:

sudo chmod +x /etc/rc.local
sudo chmod +x /etc/startstream.sh

Now it seems to work. Can reboot and rpi automatically logs on and restarts the stream. Should also work to restart the stream if only the internet connection is lost but haven't confirmed that yet.

ps: The sleep 20 (seconds) line is to give the rpi time to establish a network connection and a safeguard against a headless infinite loop that could be hard to break out of with a remote control connection.
 
Last edited:

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
Would appreciate feedback from anyone else who has this working (rtl-sdr narrow band fm feed to broadcastify). I have this background hum of about 150Hz and I think it might be a difference signal artifact of mixing different encoder sample rates. I don't hear this hum with a windows computer using SDR# and scannercast. But it is possible that it's a channel artifact that is part of the transmission. Without feedback from someone else who has this working, I don't know. :)

For now I'm back online with the rpi3 and rtl-sdr USB stick only. I'm using the 'lame' high pass filter with a cutoff off of 250Hz to minimize the prominent 150Hz buzz but it cuts a lot of low audio frequencies and is not that good a solution:
Milpitas Police Dispatch
 
Last edited:

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
Using rtl-sdr USB for AM Air Traffic

Regarding the original topic of this thread, I tried to receive the local Air Traffic Control radio frequencies in my area with a RTL2832 compatible rtl-sdr USB with a 1/4 wave whip antenna. I'm pretty close to SFO and SJC airports in CA and both were flooded out by local 88-108 MHz commercial FM stations . Since the AM ATC voice frequencies are just above the commercial FMW radio band, the FM side freqs flood out the rtl-sdr receiver since it has no front end filtering. In my case the FM noise is about 30dB below saturation which is just below the level of the received ATC signals.

So if you're trying to make the Air Traffic Control AM voice frequencies work with a simple RTL2832 style sdr USB dongle and you see a high level of background noise, you might want to try this notch filter from the original rtl-sdr blog guys:

https://tinyurl.com/y8voo8ze

I haven't tried it myself yet but looks pretty slick and designed for this application. If anyone already has experience with this filter, feedback is appreciated :).
 
Last edited:

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
Update on using generic RTL2832 sdr with Raspberry Pi3

Was able to migrate two Milpitas CA channels to a single raspberry pi 3 and serve Broadcastify.

The only hardware required is one each Raspberry Pi 3 and two each 2832 compatible dongles.

rtl-fm can be run with multiple instances on the rpi3 and that is why it works :)...!

There may be some tuning involved to get the FD2 frequency working since they rarely transmit.
I was amazed that it is working so well so far :).

Feed 1: Milpitas Police Dispatch

Feed 2: Milpitas Fire Dispatch

PS: both channels have this 150 Hz audio artifact that I still have not figured out.
 
Last edited:

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
Update, I received the FM notch filter from the rtl-sdr group: https://tinyurl.com/y8voo8ze
It dropped the background noise by about 30 dB and am able receive 2 meter signals that were buried in noise before.

New question for anyone reading this: How do you set the RTL2832 USB stick to 250KHz bandwidth using the rtl-sdr software with linux/Rpi? AFAIK the rtl-sdr software uses an algorithm to determine the best bandwidth which calcs out to around 1.025MHz (in my case anyway).

With SDR# you can explicitly set the sticks bandwidth. Is there a way to do that with rtl-fm or some other rtl-sdr setting? The problem is that adjacent channels within the 1.025MHz band is causing interference. This can be solved by reducing the scan bandwidth of the rtl2832 usb stick.

TIA very much for anyone who replies. :)
 

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
New question for anyone reading this: How do you set the RTL2832 USB stick to 250KHz bandwidth using the rtl-sdr software with linux/Rpi? AFAIK the rtl-sdr software uses an algorithm to determine the best bandwidth which calcs out to around 1.025MHz (in my case anyway).

With SDR# you can explicitly set the sticks bandwidth. Is there a way to do that with rtl-fm or some other rtl-sdr setting? The problem is that adjacent channels within the 1.025MHz band is causing interference. This can be solved by reducing the scan bandwidth of the rtl2832 usb stick.

TIA very much for anyone who replies. :)

In the spirit of finding a solution and sharing, rtlsdrblog posted the solution here:
rtl-sdr.com • View topic - Setting RTL_2832 bandwidth
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,564
Location
Massachusetts
Would appreciate feedback from anyone else who has this working (rtl-sdr narrow band fm feed to broadcastify). I have this background hum of about 150Hz and I think it might be a difference signal artifact of mixing different encoder sample rates. I don't hear this hum with a windows computer using SDR# and scannercast. But it is possible that it's a channel artifact that is part of the transmission. Without feedback from someone else who has this working, I don't know. :)

For now I'm back online with the rpi3 and rtl-sdr USB stick only. I'm using the 'lame' high pass filter with a cutoff off of 250Hz to minimize the prominent 150Hz buzz but it cuts a lot of low audio frequencies and is not that good a solution:
Milpitas Police Dispatch

I am still following your trials and tribulations here, Jack. It will still be a while before I get to complete some testing. I just loaded up gqrx on a pi3 to get started. Things look hopeful, but I have seen that before...
 

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
Well, I made a lot more progress than expected tonight! I get all the way to the point of narrowing the band discussed in the above link. Where do I find the rtl_fm.c file to make the changes?

Thanks

Jim

Glad to hear you're still interested Jim.
The rtl_fm.c file location depends on what directory you download it to but in my case it's "/home/pi/rtl-sdr-keen1/rtl-sdr/src".

Just make sure you download the keenerd fork (which has the 0 padding) at https://github.com/keenerd/rtl-sdr
Once you make the change to set the minimum bandwidth, it has to be recompiled and installed of course. Also when you run rtl-sdr you want to explicitly point to the location of rtl_fm in the startup commands. e.g. "sudo /usr/local/bin/rtl_fm ...."

I'm still trying to get sox working that has a better filter to handle the 150Hz buzz. Any suggestions from anyone on that issue are welcome :).

Good Luck,
Jack
 
Last edited:

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,564
Location
Massachusetts
Glad to hear you're still interested.
The rtl-fm.c file location depends on what directory you download it to but in my case it's "/home/pi/rtl-sdr-keen1/rtl-sdr/src".

Just make sure you download the keenerd fork (which has the 0 padding) at https://github.com/keenerd/rtl-sdr
Once you make the change to set the minimum bandwidth, it has to be recompiled and installed of course. Also when you run rtl-sdr you want to explicitly point to the location of rtl-fm in the startup commands. e.g. "sudo /usr/local/bin/rtl_fm ...."

I'm still trying to get sox working that has a better filter to handle the 150Hz buzz. Any suggestions from anyone on that issue are welcome :).

Good Luck,
Jack
Good morning, Jack.

I made the changes to the rtl_fm.c file but it doesn't seem to change the sample rate.

Using keenerd fork:

[-E enable_option (default: none)]
use multiple -E to enable multiple options
edge: enable lower edge tuning
no-dc: disable dc blocking filter
deemp: enable de-emphasis filter
swagc: enable software agc (only for AM modes)
swagc-aggressive: enable aggressive software agc (only for AM modes)
direct: enable direct sampling
no-mod: enable no-mod direct sampling
offset: enable offset tuning
wav: generate WAV header
pad: pad output gaps with zeros
lrmix: one channel goes to left audio, one to right (broken)

Changes made to rtl_fm.c:

#define DEFAULT_SAMPLE_RATE 2500
#define DEFAULT_BUF_LENGTH (1 * 16384)
#define MAXIMUM_OVERSAMPLE 16
#define MAXIMUM_BUF_LENGTH (MAXIMUM_OVERSAMPLE * DEFAULT_BUF_LENGTH)
#define AUTO_GAIN -100
#define BUFFER_DUMP 4096
#define MAXIMUM_RATE 2400000

#define FREQUENCIES_LIMIT 1000

#define PI_INT (1<<14)
#define ONE_INT (1<<14)

static volatile int do_exit = 0;
static int lcm_post[17] = {1,1,1,3,1,5,3,7,1,9,5,11,3,13,7,15,1};
static int ACTUAL_BUF_LENGTH;
static uint32_t MINIMUM_RATE = 250000;


Command I am using to start it:

sudo /usr/local/bin/rtl_fm -d 0 -M fm -f 460.400M -g 20 -p 54 -l 75 -t 10 -s 12k -E pad | /usr/bin/lame -r -s 12 --resample 22.05 -m m --cbr --lowpass 4 --highpass 0.241 - - | /usr/bin/ezstream -q -c /etc/ezstream_ice.xml

Here is what is returned:

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to 19.70 dB.
Tuner error set to 54 ppm.
Tuned to 460652000 Hz.
Oversampling input by: 84x.
Oversampling output by: 1x.
Buffer size: 8.13ms
Exact sample rate is: 1008000.009613 Hz
Sampling at 1008000 S/s.
Output at 12000 Hz.

As you can see the sampling rate is still 1008000. Did I miss something?

Thanks

Jim
 

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
Hi Jim. Did you go through all the necessary steps to insure that you are pointing to the correct version rtl_fm? I had similar problems with multiple versions of rtl-sdr.

Did you complete all the steps to install the edited version of rtl_fm.c? i.e. all the steps from scratch to install a new app.
 
Last edited:

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,564
Location
Massachusetts
Hi Jim. Did you go through all the necessary steps to insure that you are pointing to the correct version rtl_fm? I had similar problems with multiple versions of rtl-sdr.

Did you complete all the steps to install the edited version of rtl_fm.c?

i.e. The instructions work here except download the Keenerd fork and edit the rtl_fm.c file before completing the install:
Raspberry Pi RTL-SDR Broadcastify - The RadioReference Wiki

I guess that I don't understand the steps needed to install the edited version...

Your link takes me back to the original wiki instructions. Are you saying that i need to reimage my SD card and start over? In that case I would think thst i would lose the edits to rtl_fm.c????
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,564
Location
Massachusetts
Hi Jim. Did you go through all the necessary steps to insure that you are pointing to the correct version rtl_fm? I had similar problems with multiple versions of rtl-sdr.

Did you complete all the steps to install the edited version of rtl_fm.c? i.e. all the steps from scratch to install a new app.

Okay, I stumbled through it and got the sample rate to 252000.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,564
Location
Massachusetts
Some limited success.

All that I could get was garbled garbage until I took the -g gain setting right out of the command line. That enables AGC and that got rid of the garbage.

Now it is understandable but the audio is choppy, like in a poor reception area. I am not in a poor reception area, get a very strong signal. I have tried adjusting the -l squelch setting but it doesn't seem to make a difference.

Here is the link to the feed:

Franklin County Fire and EMS Dispatch 1

Don't expect a lot of activity.
 

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
Gain and squelch settings are the trickiest thing to adjust right. Also if there is any frequency offset needed (p parameter) and fine adjustments to the center freq. The tuner's center freq and any offset should agree with what you see with gqrx gui but the ideal gain and squelch setting usually have to be experimented with for awhile to get working well.

With my setup, I have very strong signals (turns out it's a tower on a hill a couple of miles from me) so the gain is very low (-g 18) and the squelch works best about -l 75. If the gain is set too high it sounds like there is too much squelch.

My guess is since AGC is working best for you, it's probably a fairly weak signal. I would try a gain of 43 or so with 0 squelch and then reduce it gradually until it gets bad. Then experiment with the squelch once you find the optimum gain.

BTW, I'm listening to your channel now so if you're using an sdr stick for the receiver, it sounds better than mine so far. I'm back on the HP mini pc until I work out the buzzing problem and channel interference.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,564
Location
Massachusetts
Gain and squelch settings are the trickiest thing to adjust right. Also if there is any frequency offset needed (p parameter) and fine adjustments to the center freq. The tuner's center freq and any offset should agree with what you see with gqrx gui but the ideal gain and squelch setting usually have to be experimented with for awhile to get working well.

With my setup, I have very strong signals (turns out it's a tower on a hill a couple of miles from me) so the gain is very low (-g 18) and the squelch works best about -l 75. If the gain is set too high it sounds like there is too much squelch.

My guess is since AGC is working best for you, it's probably a fairly weak signal. I would try a gain of 43 or so with 0 squelch and then reduce it gradually until it gets bad. Then experiment with the squelch once you find the optimum gain.

BTW, I'm listening to your channel now so if you're using an sdr stick for the receiver, it sounds better than mine so far. I'm back on the HP mini pc until I work out the buzzing problem and channel interference.

Last evening I swapped back to the scanner feed as i will be away for a couple weeks.
 

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
Oh, ok. Have a good trip.

PS I re-read your post above and you said you have a strong signal, so it's possible the p parameter is not optimized. It was off by 2 with one of my sdr's (19 with SDR# and 17 with rtl-fm). That's also a critical setting to optimize. The TCO sticks I have are all 0 -p settings but the first one I bought is not TCO and has a frequency offset.
 
Last edited:

JACK26

Member
Joined
Dec 7, 2016
Messages
298
Location
Milpitas, CA
After revisiting this issue, most likely it's not a freq or oscillator offset problem and refer back to post 117 above. Gain and squelch settings are critical and not very intuitive. One of the rtl-fm coders admits that they are very sensitive settings and it's trial and error. Try setting the gain at around -g 15 with a squelch of about -l 72. If you don't hear noise, tweak on the gain in increments of 1 or 2. If you hear noise increment -l by 1.
May have to go back and forth a bit juggling those parameters to get acceptable audio.

PS: The non-intuitive aspect of the gain and squelch settings is that the audio feedback does not fit the definition of discretely changing gain and squelch.
So using the audio feedback has limited usefulness to find the optimum parameters for -l and -g.
 
Last edited:
Status
Not open for further replies.
Top