Scanning SSB frequencies in rtl_fm

williamGB

Member
Feed Provider
Joined
Oct 16, 2022
Messages
43
Location
Chester, UK
I'm currently using this command which tunes to Shannon Volmet and outputs the audio to an external speaker
Code:
rtl_fm -f 5505000 -s 11025 -g 30 -M usb -E direct2 - | aplay -r 11025 -f S16_LE -t raw -c 1
However, I'm trying to scan though multiple hf aero frequencies, Ive tried
Code:
rtl_fm -f 5450000 -f 89570000 -f 11309000 -s 11025 -g 30 -M usb -E direct2 -l 10 - | aplay -r 11025 -f S16_LE -t raw -c 1
and
Code:
rtl_fm -f 5450000:89570000:11309000 -s 11025 -g 30 -M usb -E direct2 -l 10 - | aplay -r 11025 -f S16_LE -t raw -c 1
but both commands only play the first frequency and thats it.. hopefully someone on here knows how to do it properly.

William
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
The issue you maybe having in second example is probably to do with the 2nd frequency given on command line:
  • -f 89570000 - This is 89.57mHz (and out of range for direct mode), I'm guessing you meant 8.957mHz

In the 3rd example, this way is used to set a frequency range to scan (Start:Stop:Step)
  • -f 5450000:89570000:11309000 - This is not valid as the end frequency (89570000) is wrong like the 2nd example (shown above)
  • The step frequency (11309000) is not really a step frequency (it's a frequency you want to scan). Even if it were a step frequency, it is greater than the frequency range anyway (when using 8.957mHz as end frequency)
 

williamGB

Member
Feed Provider
Joined
Oct 16, 2022
Messages
43
Location
Chester, UK
The issue you maybe having in second example is probably to do with the 2nd frequency given on command line:
  • -f 89570000 - This is 89.57mHz (and out of range for direct mode), I'm guessing you meant 8.957mHz

In the 3rd example, this way is used to set a frequency range to scan (Start:Stop:Step)
  • -f 5450000:89570000:11309000 - This is not valid as the end frequency (89570000) is wrong like the 2nd example (shown above)
  • The step frequency (11309000) is not really a step frequency (it's a frequency you want to scan). Even if it were a step frequency, it is greater than the frequency range anyway (when using 8.957mHz as end frequency)
Ohh I didn't see my typo, my mistake. So, If i try

-f 5450000 -f 5550000 -f 8957000

It should scan those frequencies?
 

williamGB

Member
Feed Provider
Joined
Oct 16, 2022
Messages
43
Location
Chester, UK
The issue you maybe having in second example is probably to do with the 2nd frequency given on command line:
  • -f 89570000 - This is 89.57mHz (and out of range for direct mode), I'm guessing you meant 8.957mHz

In the 3rd example, this way is used to set a frequency range to scan (Start:Stop:Step)
  • -f 5450000:89570000:11309000 - This is not valid as the end frequency (89570000) is wrong like the 2nd example (shown above)
  • The step frequency (11309000) is not really a step frequency (it's a frequency you want to scan). Even if it were a step frequency, it is greater than the frequency range anyway (when using 8.957mHz as end frequency)
Okay, I edited the command and added a few more frequencies

Code:
rtl_fm -f 5520000 -f 5547000 -f 5550000 -f 5583000 -f 5598000 -f 5616000 -f 5649000 -s 11025 -g 30 -M usb -E direct2 -l 10 | sox -t raw -r 11025 -e signed -b 16 -c 1 - -t wav - gain 20 | aplay

However, It is still just playing the first frequency listed, and not scanning through them.
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
The last command line you supplied seems to scan for me. (using the default repo rtl_fm source code)
The only difference is, I'm using Windows so I'm redirecting the piped output to SoX instead of aplay.

Either the squelch level is set to low or it is scanning and you just can't tell because rtl_fm gives no indication that it is doing it.
Also, it will not scan if you are always receiving something on a frequency.

If you are able, it pays to add some features to rtl_fm to make it more useful.
 

williamGB

Member
Feed Provider
Joined
Oct 16, 2022
Messages
43
Location
Chester, UK
The last command line you supplied seems to scan for me. (using the default repo rtl_fm source code)
The only difference is, I'm using Windows so I'm redirecting the piped output to SoX instead of aplay.

Either the squelch level is set to low or it is scanning and you just can't tell because rtl_fm gives no indication that it is doing it.
Also, it will not scan if you are always receiving something on a frequency.

If you are able, it pays to add some features to rtl_fm to make it more useful.
Hm okay. I'll mess around with the squelch and hopefully it'll work.

How did you install rtl_fm on windows? I cant find a way to do so.
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
How did you install rtl_fm on windows? I cant find a way to do so.
I compiled it with MinGW to create the exes/dlls.


Thanks! I got it installed and I can run rtl_fm.. however I hear no audio. Was this a problem for you?
You still need to pipe the audio from rtl_fm to an audio program like SoX.

An example when using SoX:
Code:
rtl_fm -f 5520000 -f 5547000 -f 5550000 -f 5583000 -f 5598000 -f 5616000 -f 5649000 -s 11025 -g 30 -M usb -E direct2 -l 10 - | C:\sox-14.4.2\sox.exe -q -V0 -b 16 -c  1 -e signed-integer -r 11025 -t raw - -t waveaudio default
NOTE: You will need to set the SoX path on the command line to where the SoX folder is.
If you set the path for SoX in the "Environment variables" - "PATH", then you won't need to do this every time.
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
With SoX, you can add HPF/LPF/BPF audio filters and even a basic audio AGC to the output audio to make it sound a little better.
 

williamGB

Member
Feed Provider
Joined
Oct 16, 2022
Messages
43
Location
Chester, UK
I compiled it with MinGW to create the exes/dlls.



You still need to pipe the audio from rtl_fm to an audio program like SoX.

An example when using SoX:
Code:
rtl_fm -f 5520000 -f 5547000 -f 5550000 -f 5583000 -f 5598000 -f 5616000 -f 5649000 -s 11025 -g 30 -M usb -E direct2 -l 10 - | C:\sox-14.4.2\sox.exe -q -V0 -b 16 -c  1 -e signed-integer -r 11025 -t raw - -t waveaudio default
NOTE: You will need to set the SoX path on the command line to where the SoX folder is.
If you set the path for SoX in the "Environment variables" - "PATH", then you won't need to do this every time.
I set the path in environmental variables, and ran it with
Code:
 rtl_fm -f 5520000 -f 5547000 -f 5550000 -f 5583000 -f 5598000 -f 5616000 -f 5649000 -s 11025 -g 30 -M usb -E direct2 -l 10 - | sox.exe -q -V0 -b 16 -c  1 -e signed-integer -r 11025 -t raw - -t waveaudio default

The output i got was

Found 1 device(s):
0: Nooelec, NESDR SMArt v5, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to 29.70 dB.
Enabled direct sampling mode, input 2
Enabled direct sampling mode, input 2/Q.
Tuned to 5770818 Hz.
Oversampling input by: 91x.
Oversampling output by: 1x.
Buffer size: 8.17ms
Exact sample rate is: 1003275.031911 Hz
Sampling at 1003275 S/s.
Output at 11025 Hz.

But still no audio.
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
If you set the squelch level to 1 (i.e. -l 1), do you at least hear the static/noise floor?

I've noticed that the audio level is really low using this command line.
You could try and add gain parameter to the SoX part as follows: (includes the lower squelch level)
Code:
rtl_fm -f 5520000 -f 5547000 -f 5550000 -f 5583000 -f 5598000 -f 5616000 -f 5649000 -s 11025 -g 30 -M usb -E direct2 -l 1 - | sox.exe -q -V0 -b 16 -c  1 -e signed-integer -r 11025 -t raw - -t waveaudio default gain 40
NOTE: Set you speaker volume low to start with when trying this gain value just in-case it's to high.
Of course with such a low squelch level, this won't scan but it should tell us if rtl_fm is passing something to SoX.
This is working fine for me. (I use a signal generator to test the tuned frequency as well)

Not sure what Windows version you are use but Win10/11 likes to block access to the audio line without tell you it's doing it.
It's in the permissions somewhere. This could be a problem as well.
 

williamGB

Member
Feed Provider
Joined
Oct 16, 2022
Messages
43
Location
Chester, UK
I got it working! I was using Windows Terminal instead of command prompt, so i tried that command in command prompt and i can hear static! Thanks for your help

Would I be able to run this?

Code:
rtl_fm -f 6535000 -f 3476000 -f 5616000 -f 8891000 -f 11279000 -f 5505000 -f 5520000 -f 5550000 -f 6577000 -f 6586000 -f 8893000 -f 8906000 -f 5547000 -f 6628000 -f 8906000 -f 11309000 -f 3491000 -f 4561000 -f 5583000 -f 5649000 -f 5803000 -f 6622000 -f 8879000 -f 5598000 -s 11025 -g 30 -M usb -E direct2 -l 10 - | sox.exe -q -V0 -b 16 -c  1 -e signed-integer -r 11025 -t raw - -t waveaudio default gain 40

Or is that just wayyy too many frequencies?
 
Last edited:

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
Try it and see what happens.
I don't see why it wouldn't.

rtl_fm has a frequency limit of 1000, whether the console allows a string of that length is another thing.

Problem with the standard rtl_fm is you don't know what frequency your on when scanning and you can change some of the parameter at run-time. Not to hard to add if you know how.
 

williamGB

Member
Feed Provider
Joined
Oct 16, 2022
Messages
43
Location
Chester, UK
It works! Thanks for your help! I have another question, an airport near me re broadcasts the AM signals on analogue UHF NFM, however, a business or something is using them frequencies with DMR, and occasionally when using my baofeng, i get blasted with the horrible DMR noise. Is there a way to use rtl_fm to cut out the DMR? Like if the signal goes over a certain amount, it will cut it out and not play it?
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
rtl_fm is quite simple and does nothing to filter out any adjacent frequencies that maybe active.
If the SDR is suffering front-end overload, other than reducing the gain (maybe), nothing will save the day.
 
Top