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
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.

I'm getting really close, but now I introduced a new problem. The NOAA frequency was on VHF and the channel I want to stream is on UHF. I found a local PD that has is near the frequency of the frequency of the FD that I want to stream, and the PPM setting is completely wrong and I am getting nothing but a high pitch squeal anytime someone talks.

Back to the drawing board!
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
..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?

That's why I was opening the stream every time. There are no speakers. I'd make an adjustment, then relaunch the live stream and listen to the output. Definitely not an ideal setup.
 

vagrant

ker-muhj-uhn
Premium Subscriber
Joined
Nov 19, 2005
Messages
3,141
Location
California
This should work for you. Copy and paste as-is. Do not start another command each time, just once. That is one long command line below. The problem may be is that you are not "|" piping it to the next which is what the instructions say to do. I do not run a stream on Broadcastify, but this command should get it going based on what I read of the instructions, your needs and configuration in this thread.

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


1. I presume you already played with your squelch, so I kept your -l 65 setting in the rtl_fm path. Adjust that yourself as needed.
2. You noted your offset is -18, so it is in there -p -18. Notice how it is negative -18 and not just 18 because you noted "-18".
3. I'm pretty sure the gain automatically adjusts. Setting it to -g 50 may be too much. (50 was not a result in the rtl_test, so it goes down to the next one, 49.6, which may still be too much.) Just avoid -g 50 or whatever, unless your desired RX signal is very low.

If that command line with everything in it does not sound clear, I would try removing the "-p -18" and see what you get. It may be close enough without it, but definitely try it if that was the result.

*** Please note, when you receive that RTL-SDR V3 from Amazon, it has a TCXO, so you definitely want to remove the "-p -18" from the command. With the TCXO it will be close enough. I have several RTL-SDR v3 dongles and they're all fine. I do not use an offset with any of them.

You will use this string when you switch from the current dongle to the RTL-SDR v3. I simply removed the -p -18.

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

vagrant

ker-muhj-uhn
Premium Subscriber
Joined
Nov 19, 2005
Messages
3,141
Location
California
Update on point #3 - The gain does not auto adjust. Still, leave it off at first, or set it in the middle and work your way up or down if needed using the gain options you posted from rtl_test. I use rtl_fm with Direwolf for APRS and it is Direwolf that can adjust gain to some degree, thus my confusion.

I forgot what the default rtl_fm gain is, if it is listed somewhere.
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
I am up and running. The new dongle arrived today, plugged it in, and we are off to the races. I ended up changing the department that I was going to stream, just because there is a lot more traffic on the new one. If you have a chance to listen, let me know your thoughts.

Thanks to everyone that provided help, especially @a417 !

Mike
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
Hi guys. It's been a while, and thought I'd share an update. I am still struggling a bit. I have been successful with tuning in the local NOAA channel, but getting a good feed for the dispatch that I am trying to feed has been elusive. If I turn the squelch up to the point where no static is heard (-l 67), I don't get any sound other than the occasional pop. I've tried various gain settings, and have even tried setting it to automatic, but no change.

I think I am understanding how RTL_FM works, but have no idea about lame. Any input is greatly appreciated.

Here is what I am currently running:

/usr/local/bin/rtl_fm -d 0 -M fm -f 155.805M -l 67 -s 12k -F 0| /usr/bin/lame -r -s 12 --resample 22.05 -m m -b 16 --cbr --lowpass 4 - - | /usr/bin/ezstream -c /etc/ezstream_bcfy.xml
 

vagrant

ker-muhj-uhn
Premium Subscriber
Joined
Nov 19, 2005
Messages
3,141
Location
California
I have questions below, but try this first and see if it works. Let's just jump to the solution if we can. Copy and paste it as-is starting from sudo to the last ampersand at the end.

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

-- If the line above works, forego answering my questions below as they will have been answered --
Why did you introduce "-F 0"?
Why did you remove "-E pad"? You are using squelch, so why is this missing? Did something change with rtl_fm? I do not use squelch, so it may have.
Why are you not using "> /home/pi/bcfy2.log 2>&1 &" at the end? ... I know why I may not choose to use that, but I am wondering if you're doing it for the same reason. As long as you know why you're good on that part. I think you do, but I should ask.
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
I have questions below, but try this first and see if it works. Let's just jump to the solution if we can. Copy and paste it as-is starting from sudo to the last ampersand at the end.

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

-- If the line above works, forego answering my questions below as they will have been answered --
Why did you introduce "-F 0"?
Why did you remove "-E pad"? You are using squelch, so why is this missing? Did something change with rtl_fm? I do not use squelch, so it may have.
Why are you not using "> /home/pi/bcfy2.log 2>&1 &" at the end? ... I know why I may not choose to use that, but I am wondering if you're doing it for the same reason. As long as you know why you're good on that part. I think you do, but I should ask.

When I run the above (after correcting the "/user/bin/lame" entry, I get the following and I am offline:

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

Using device 0: Generic RTL2832U OEM
usb_claim_interface error -6
Failed to open rtlsdr device #0.
WARNING: libsndfile may ignore -r and perform fseek's on the input.
Compile without libsndfile if this is a problem.
Assuming raw pcm input file
LAME 3.100 32bits (LAME MP3 Encoder)
Resampling: input 12 kHz output 22.05 kHz
Using polyphase lowpass filter, transition band: 4001 Hz - 4268 Hz
Encoding <stdin> to <stdout>
Encoding as 22.05 kHz single-ch MPEG-2 Layer III (22x) 16 kbps qval=3

To answer your questions,
-F 0 was recommended on one of the instructions I found online. I have no idea what it does.
-F pad was removed because on the same page that recommended -F 0, it said that -F pad was not functional
I removed the "bcfy2.log" entry because I had permission errors earlier and didn't think it was needed.
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
When I run the above (after correcting the "/user/bin/lame" entry, I get the following and I am offline:

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

Using device 0: Generic RTL2832U OEM
usb_claim_interface error -6
Failed to open rtlsdr device #0.
WARNING: libsndfile may ignore -r and perform fseek's on the input.
Compile without libsndfile if this is a problem.
Assuming raw pcm input file
LAME 3.100 32bits (LAME MP3 Encoder)
Resampling: input 12 kHz output 22.05 kHz
Using polyphase lowpass filter, transition band: 4001 Hz - 4268 Hz
Encoding <stdin> to <stdout>
Encoding as 22.05 kHz single-ch MPEG-2 Layer III (22x) 16 kbps qval=3

To answer your questions,
-F 0 was recommended on one of the instructions I found online. I have no idea what it does.
-F pad was removed because on the same page that recommended -F 0, it said that -F pad was not functional
I removed the "bcfy2.log" entry because I had permission errors earlier and didn't think it was needed.

Standby, I rebooted and re-ran what you suggested and it seems to be back online. I'll let you know if it works.

One question. How do you terminate the entire process? I have been using Ctrl-C but I don't think that kills everything.
 
Last edited:

a417

U+0000
Joined
Mar 14, 2004
Messages
4,617
If you have no idea what it was...why put it in?

IIRC your logging issues were related to logging in /var/log, logging in your home directory should work just fine.
 

vagrant

ker-muhj-uhn
Premium Subscriber
Joined
Nov 19, 2005
Messages
3,141
Location
California
Good catch on my directory misspelling.

Use this page as your rtl_fm guide.
-F and whatever number after it tells it not to use the default filter. I would say get things working first, then experiment with -F, or don't.
-E pad could have been removed, but it was there to pass data when squelched to keep the stream open. I could be wrong on this.
As for permission errors, that log should be in your directory and should be fine. Still you may need to touch the file first...Then run the command line.
touch /home/pi/bcfy2.log

It probably failed to open the device as it was already running....okay I see you posted an update. Yeah, it was running when you ran the command I posted and then not running after a reboot, so now it should be working and logging correctly. (You no longer need to run that "touch" command, as you probably created the directory when you ran the command to start things up.)

To terminate you run the kill command, plus whatever depending on what you want to do. A simple way would be to first run "top" and look for what you started up. In particular the Process ID "PID" of whatever. In this case it would be rtl_fm. The name of the processes are on the right and the PID is on the left. Make sure you use the right ID. Another way to obtain a specific PID would be to run
ps aux | grep rtl_fm

This will kick out some info. The first will be the username that ran it, probably "pi". The next column would the PID. I would recommend you do both, run top and note the PID of rtl_fm. Hit Cntl-C and then run the ps aux command I noted to confirm the PID. (You do not want to kill in error)

You then run the kill command and the corresponding PID. For example

kill -9 28170
I'm old and my Unix is older. I took a quick look and there is an easier way to do it and avoid having to lookup the PID

killall rtl_fm
You probably will need to run killall lame and killall ezstream too.

Okay, I hear your stream online and noise so I presume you removed the squelch. I do not hear vocal audio yet.
 
Last edited:

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
Okay, I hear your stream online and noise so I presume you removed the squelch. I do not hear vocal audio yet.

It seems that with the settings you gave me have rendered the squelch inoperable. I have it set to 70 and there is just white noise. Any ideas?
 

vagrant

ker-muhj-uhn
Premium Subscriber
Joined
Nov 19, 2005
Messages
3,141
Location
California
Perhaps try again but remove the -E pad.

I may just get this going on a Pi myself and see what settings work or not.
 

vagrant

ker-muhj-uhn
Premium Subscriber
Joined
Nov 19, 2005
Messages
3,141
Location
California
I hear communication on the stream, so that's good. I may have time on Thursday to install the latest flavor of Raspbian and the other stuff to get this going. I'll see about providing a stream to Broadcastify today, so that it's ready tomorrow, or whenever to test. Does Broadcastify have a test account? Ahh...I'll find out shortly.
 

a417

U+0000
Joined
Mar 14, 2004
Messages
4,617
@freema22 a couple of us are going to try to replicate your setup.

Just to be sure, lets get everything out in the open.

It's a headless raspi zero-w with an RTL-SDR, accessing it via ssh, and your only audio out is via a broadcastify stream? Which version of raspbian are you running? The most recent i see out on the repos is Feb 2020, and I'd like to make sure that i'm doing apples to apples here.
 

theconqueror

Newbie
Joined
Feb 20, 2015
Messages
8
Let me preface this with: I have no solutions.
I was running into a similar issue as you and found out that changing the sampling from -s 12k to -s 32k changed the audio from a hiss to actual audio.

I didnt get a chance to play around with it before my SD card ran out of room. I noticed it after trying to listen to a broadcast FM stream with the commands here Rtl_fm Guide: Updates for rtl_fm overhaul
rtl_fm -f 89.1M -M fm -s 170k -A fast -r 32k -l 0 -E deemp | play -r 32k -t raw -e s -b 16 -c 1 -V1 - and it worked just fine. You won't be able to use the play command there because you dont have a headphone jack, but it might send you in the right direction. I managed to mess up the commands some how and got everyone to sound like mickey mouse on my stream. The new SD card comes tomorrow and I'll try again.
 

freema22

Member
Feed Provider
Joined
Sep 22, 2003
Messages
175
Location
Michigan
@freema22 a couple of us are going to try to replicate your setup.

Just to be sure, lets get everything out in the open.

It's a headless raspi zero-w with an RTL-SDR, accessing it via ssh, and your only audio out is via a broadcastify stream? Which version of raspbian are you running? The most recent i see out on the repos is Feb 2020, and I'd like to make sure that i'm doing apples to apples here.

@freema22 a couple of us are going to try to replicate your setup.

Just to be sure, lets get everything out in the open.

It's a headless raspi zero-w with an RTL-SDR, accessing it via ssh, and your only audio out is via a broadcastify stream? Which version of raspbian are you running? The most recent i see out on the repos is Feb 2020, and I'd like to make sure that i'm doing apples to apples here.

Headless - yes
RTL_SDR - yes
Accessing via SSH: Not anymore. Using VNC (same difference)
Raspian Buster version: Just ran apt-get update/upgrade so it should be good to go
 

vagrant

ker-muhj-uhn
Premium Subscriber
Joined
Nov 19, 2005
Messages
3,141
Location
California
Okay, I'll whip up the same on a zero-w I have and see what's what as well.
 
Status
Not open for further replies.
Top