Help with Raspberry Pi Zero and RTL_FM

Status
Not open for further replies.

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
Hi guys,
I am at my wits end. I have been attempting to follow the instructions here: Raspberry Pi RTL-SDR Broadcastify - The RadioReference Wiki and am striking out. I was able to get my feed up and running once, but I have no idea how. Between the time I got the "Your feed has been seen for the first time" message and I decided that it wasn't working, I restarted my Pi, and it went down and I have no idea how to get it back.

I did notice is that my tune frequency doesn't match what I put into the configuration file. I am trying to tune to 424.1750Mhz, and it is tuning to 424.4270Mhz. I have no idea why or how to fix it.

To get the party started, I am entering each of the following individually:

sudo /usr/local/bin/rtl_fm -d 0 -M fm -f 424.175M -E pad |
sudo /usr/bin/lame -r -s 12 --resample 22.05 -m m -b 16 --cbr --lowpass 4 - - |
sudo /usr/bin/ezstream -c /etc/ezstream_bcfy.xml > /var/log/bcfy2.log 2>&1 &

Below is the output when I get RTL_FM running

pi@pizero:~ $ Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Tuner gain set to automatic.
Tuned to 424427000 Hz.
Oversampling input by: 42x.
Oversampling output by: 1x.
Buffer size: 8.13ms
Exact sample rate is: 1008000.009613 Hz
Sampling at 1008000 S/s.
Output at 24000 Hz.

Once I start EZSTREAM, I get the following, but nothing makes it to Broadcastify:

sudo /usr/bin/ezstream -c /etc/ezstream_bcfy.xml
ezstream: Connected to http://audio3.broadcastify.com:80/XXXXXXXX
ezstream: Streaming from standard input

Any help is greatly appreciated!
Mike
 

a417

Active Member
Joined
Mar 14, 2004
Messages
4,669
sudo /usr/local/bin/rtl_fm -d 0 -M fm -f 424.175M -E pad |
sudo /usr/bin/lame -r -s 12 --resample 22.05 -m m -b 16 --cbr --lowpass 4 - - |
sudo /usr/bin/ezstream -c /etc/ezstream_bcfy.xml > /var/log/bcfy2.log 2>&1 &
add a "-" after -E pad and before the pipe command
Code:
 /usr/local/bin/rtl_fm -d 0 -M fm -f 424.175M -E pad -

i've seen conflicting man-pages between distros that say omitting the trailing dash will dump data to stdout, but you don't have that. Try adding a trailing dash to force rtl_fm to standard out (which broadcastify states it is specifically looking for) from your first line of your command.

...and do you need to be running rtl_fm as superuser?
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
add a "-" after -E pad and before the pipe command
Code:
 /usr/local/bin/rtl_fm -d 0 -M fm -f 424.175M -E pad -

i've seen conflicting man-pages between distros that say omitting the trailing dash will dump data to stdout, but you don't have that. Try adding a trailing dash to force rtl_fm to standard out (which broadcastify states it is specifically looking for) from your first line of your command.

...and do you need to be running rtl_fm as superuser?

Thanks, I'll give that a shot. As far as running as a superuser...probably not. I'll try it without. Any idea why the frequency is not tuning correctly?

I also noticed that when I run the last line:
/usr/bin/ezstream -c /etc/ezstream_bcfy.xml > /var/log/bcfy2.log 2>&1 &
[1] 803

I get this:
pi@pizero:~ $ -bash: /var/log/bcfy2.log: Permission denied

Thanks!
 

a417

Active Member
Joined
Mar 14, 2004
Messages
4,669
the 'pi user doesn't apparently have write access to /var/log/. Log somewhere else. ~/bcfy.log

and as for the frequency issue, it's addressed in the first line of the FAQ.

FAQ said:
Q: Rtl_fm says it tunes to some other frequency instead of mine.

This is normal behavior, to dodge the DC spike present in E4000 tuners. The software tunes slightly off center and then corrects for the offset during demodulation.
 
Last edited:

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
I'm a complete novice when it comes to RPi functions. How does one grant write access?

I missed the FAQ. Thanks
 

a417

Active Member
Joined
Mar 14, 2004
Messages
4,669
Apologies, I edited it AFTER you read it.

Try logging somewhere else, it's much easier than changing system directory write permissions.

Code:
/usr/bin/ezstream -c /etc/ezstream_bcfy.xml > /home/pi/bcfy2.log 2>&

logging to your home directory will be much easier to accomplish, and read.

Remember, this is a linux function, not a RPi function. RPi has to play by the rules of the OS, in this case raspbian (a debian derivative).
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
Apologies, I edited it AFTER you read it.

Try logging somewhere else, it's much easier than changing system directory write permissions.

Code:
/usr/bin/ezstream -c /etc/ezstream_bcfy.xml > /home/pi/bcfy2.log 2>&

logging to your home directory will be much easier to accomplish, and read.

Remember, this is a linux function, not a RPi function. RPi has to play by the rules of the OS, in this case raspbian (a debian derivative).

Thanks for your help. It's feeding noise, but feeding nonetheless! Time to start tweaking some settings.
 

a417

Active Member
Joined
Mar 14, 2004
Messages
4,669
try tuning it to the local NOAA-All Hazards weather station and set the gain to max by adding "-g49.6" to your rtl_fm command line.

not sure where you are, but it'll be your best bet at a local source that's not "50,000 flamethrowing watts of TODAYS GREATEST HITS" and all that jazz.

NOAA - michigan
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
I'm definitely making progress. I have figured out how to get the audio to go to the web reliably, but it sounds like garbage. I've been tweaking the settings, but still not satisfactory.

I am all self-taught on the ways of RPi, so forgive if I ask a simple question. Is there a way for me to change the settings for rtl_fm without rebooting everytime?
 

a417

Active Member
Joined
Mar 14, 2004
Messages
4,669
you do not have to reboot every time. Why are you rebooting?
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
Thank you so much for all of the help that you have given me. I really appreciate it. Could you take a listen to my feed and let me know where to start looking next to fix the audio? There is a steady stream of audio, but it is completely unreadable. I have tweaked the squelch and gains but haven't found anything that makes a noticeable improvement. I'm thinking it has something to do with sampling rates or something, but this is all Greek to me. I am currently streaming the NOAA channel nearest me. West Bloomfield Township Fire Dispatch Live Audio Feed

Again, thank you so much for all of the help.

Mike
 

a417

Active Member
Joined
Mar 14, 2004
Messages
4,669
  1. What RTL_SDR dongle are you using? (lets verify it's one that most likely won't need to be heavily calibrated)
  2. Stop streaming until you have the local audio source dialed in. (walk before you can run)
  3. post all the commands you are using so others can see EXACTLY what you're working with. (full disclosure)
We'll get it sorted.
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
The dongle I am using just says DVB-T +DAB+FM Digital Voice Broadcasting on it. It comes up as Realtek, RTL2838UHIDIR. I used it years ago as an ADS-B receiver.

The commands I am issuing are:
/usr/local/bin/rtl_fm -d 0 -M fm -f 162.55M -l 65 -g 50 -s 12k |
/usr/bin/lame -r -s 12 --resample 22.05 -m m -b 16 --cbr --lowpass 4 - - |
/usr/bin/ezstream -c /etc/ezstream_bcfy.xml
 

a417

Active Member
Joined
Mar 14, 2004
Messages
4,669
Many dongles come up as the RTL2838UHIDR, from many vendors. It could be considered a generic, despite having Realtek's name on it.

Black plastic? Possibly a v1 then ,it might need some PPM adjustment. If you have SDR# or GQRX installed you can go to the local NOAA frequency and see visually exactly how far you are off tune (if any), and then dial it in with the PPM adjustment slider found in the GUI.

If it's not in an aluminum case, it's most likely NOT a V3 or V4 that usually have a temperature controlled local oscillator.

Lets verify that you are actually getting on frequency, so dont run the /usr/bin/lame line or the /usr/bin/ezstream until we get you receiving clean audio from rtl_fm.
 

a417

Active Member
Joined
Mar 14, 2004
Messages
4,669
rtl_fm -g 49.6 -f [NOAA freq here]M -M nbfm -s 180k -E deemp | play -r 180k -t raw -e s -b 16 -c 1 -V1 - lowpass 16k

that's from memory, but I think it should work.
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
Ok, here's what I have been working on. This setup is running on a headless Raspberry Pi Zero that I access via SSH. Running GQRX on it is a no go. So I installed a similar program on my regular PC and determined the PPM to be -18. I plugged that in to RTL_FM and there is no discernable change. I used your command above with -18 and there is no audio, aside from a few random pops. I have ordered a newer SDR (V3) from Amazon to see if that will make a difference.

The one thing I noticed when messing with the GQRX-like program is that the audio that I am getting almost sounds like a side band. When I started the program, it was switched to LSB rather than NFM and it was completely unreadable. Once flipped to NFM, it was crystal clear. Am I missing something in RTL-FM???
 

a417

Active Member
Joined
Mar 14, 2004
Messages
4,669
Oh, wait this is a PiZero?

Code:
rtl_test

let's see the output... (let it run for 30 seconds or so, it'll go indef. if you let it.) then hit it with a <CNTL+C>.

I have a couple of pi zeros I can spin up, to locally test if need be. I'm afraid things are getting apples-to-oranges with you flopping between regular PCs and then going to an SOC like a Pi Zero and MASSIVELY different CPU bandwith capabilities.
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
Here are the results of rtl_test

pi@pizero:~ $ rtl_test
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 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
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...
lost at least 188 bytes
^CSignal caught, exiting!

User cancel, exiting...
Samples per million lost (minimum): 0
pi@pizero:~ $
 

a417

Active Member
Joined
Mar 14, 2004
Messages
4,669
..and you're accessing this headless raspi zero via ssh? where are the speakers connected...to the PC you are using or the raspi zero?
 
Status
Not open for further replies.
Top