Address
304 North Cardinal St.
Dorchester Center, MA 02124

Work Hours
Monday to Friday: 7AM - 7PM
Weekend: 10AM - 5PM

LuaRadio SDR – Goodbye GNURadio?

Since I haven’t gotten my SDR working correctly, one of my colleges recommended LuaRadio SDR as opposed to GNURadio

I had tried GNURadio off and on, but was never even able to get a basic hello world to work. Even tuning to basic FM radio stations in my area led to static or weird errors.

That said, it seemed that LuaRadio might be even easier, and finally let me see what my SDR could do.

Connection

First, I hooked up the device to my Macbook (yay dongles).

LuaRadio SDR - Connected

Installation

Once I had everything connected, it was time to install LuaRadio

Rays-MacBook-Pro:Downloads doyler$ brew install luaradio
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).

...

==> Installing dependencies for luaradio: luajit, fftw
==> Installing luaradio dependency: luajit





Rays-MacBook-Pro:Radio doyler$ luaradio test.lua
Warning: neither libliquid nor libvolk found. LuaRadio will run without acceleration.
luajit: [string "radio.blocks.sinks.gnuplotspectrum"]:0: gnuplot not found. Is gnuplot installed?
stack traceback:
  [C]: in function 'assert'
  [string "radio.blocks.sinks.gnuplotspectrum"]: in function 'initialize'
  [string "radio.core.composite"]: in function '_prepare_to_run'
  [string "radio.core.composite"]: in function 'start'
  [string "radio.core.composite"]: in function 'run'
  test.lua:17: in main chunk
  [C]: in function 'dofile'
  /usr/local/bin/luaradio:105: in main chunk
  [C]: at 0x0100fd7960
Rays-MacBook-Pro:Radio doyler$ brew install gnuplot

...

Errors, errors, errors

After (I thought) I had everything installed, it was time to create an FM receiver and listen to the radio!

Unfortunately, a few more errors occurred.

Rays-MacBook-Pro:Radio doyler$ vi rtlsdr_wbfm_mono.lua
Rays-MacBook-Pro:Radio doyler$ luaradio rtlsdr_wbfm_mono.lua
Warning: neither libliquid nor libvolk found. LuaRadio will run without acceleration.
Usage: rtlsdr_wbfm_mono.lua 
Rays-MacBook-Pro:Radio doyler$ luaradio rtlsdr_wbfm_mono.lua 95.3e6
Warning: neither libliquid nor libvolk found. LuaRadio will run without acceleration.
luajit: [string "radio.blocks.sources.rtlsdr"]:0: RtlSdrSource: librtlsdr not found. Is librtlsdr installed?
stack traceback:
  [C]: in function 'error'
  [string "radio.blocks.sources.rtlsdr"]: in function 'initialize'
  [string "radio.core.composite"]: in function '_prepare_to_run'
  [string "radio.core.composite"]: in function 'start'
  [string "radio.core.composite"]: in function 'run'
  rtlsdr_wbfm_mono.lua:34: in main chunk
  [C]: in function 'dofile'
  /usr/local/bin/luaradio:105: in main chunk
  [C]: at 0x0109407960
Rays-MacBook-Pro:Radio doyler$ brew install librtlsdr

...

After I had all the pre-requisites properly installed, I tuned to a local radio station.

I was still getting some issues with the audio, but the internet recommended installing pulseaudio as well.

Rays-MacBook-Pro:Radio doyler$ luaradio rtlsdr_wbfm_mono.lua 95.3e6
Warning: neither libliquid nor libvolk found. LuaRadio will run without acceleration.
Found Rafael Micro R820T tuner
Exact sample rate is: 1102500.002464 Hz
^C[RtlSdrSource] Block runtime error: [string "radio.blocks.sources.rtlsdr"]:0: rtlsdr_read_async(): -5
stack traceback:
  [C]: in function 'error'
  [string "radio.blocks.sources.rtlsdr"]: in function 'run'
  [string "radio.core.composite"]: in function <[string "radio.core.composite"]:0>
  [C]: in function 'xpcall'
  [string "radio.core.composite"]: in function 'start'
  [string "radio.core.composite"]: in function 'run'
  rtlsdr_wbfm_mono.lua:34: in main chunk
  [C]: in function 'dofile'
  /usr/local/bin/luaradio:105: in main chunk
  [C]: at 0x0107de4960
Rays-MacBook-Pro:Radio doyler$ brew install pulseaudio
==> Installing dependencies for pulseaudio: libtool, json-c, flac, libogg, libvorbis, libsndfile, libsoxr, speexdsp
==> Installing pulseaudio dependency: libtool

Success!

When it was all said and done, I was able to tune to a local radio station, and get an audio file!

Rays-MacBook-Pro:Radio doyler$ luaradio rtlsdr_wbfm_mono.lua 105.1e6
Warning: neither libliquid nor libvolk found. LuaRadio will run without acceleration.
Found Rafael Micro R820T tuner
Exact sample rate is: 1102500.002464 Hz
^C[RtlSdrSource] Block runtime error: [string "radio.blocks.sources.rtlsdr"]:0: rtlsdr_read_async(): -5
stack traceback:
  [C]: in function 'error'
  [string "radio.blocks.sources.rtlsdr"]: in function 'run'
  [string "radio.core.composite"]: in function <[string "radio.core.composite"]:0>
  [C]: in function 'xpcall'
  [string "radio.core.composite"]: in function 'start'
  [string "radio.core.composite"]: in function 'run'
  rtlsdr_wbfm_mono.lua:34: in main chunk
  [C]: in function 'dofile'
  /usr/local/bin/luaradio:105: in main chunk
  [C]: at 0x010410e960

Conclusion

That said, there were still a few issues with this method.

The first was that even though a number of local radio stations in my area, I was only able to get a handful of them clearly.

Additionally, I was unable to get the audio to actually stream, but rather output to a file.

Other than that, it was very exciting to get my SDR actually working.

I believe I may need an antenna of some sort to continue my experimentation, as that could be my issue.

Let me know if you have any other suggestions or ideas for things that I can try!

2 Comments

  1. You wrote: The first was that even though a number of local radio stations in my area, I was only able to get a handful of them clearly.

    I had the same problem, but found the reason quickly. By default, a very low gain value for the receiver is used and autogain is set to false.

    I solved the problem by enabling autogain inside the example script, like this:

    local source = radio.RtlSdrSource(frequency + tune_offset, 1102500, {autogain = true})

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.