Rtlrecorder v1.0 – Record your i/q stream at given date/time for n. minutes (RTL-SDR)

Hi!
Today i wanna present you a little script i wrote last year.

This script will let you automate the i/q recording without writting each time a long linux cli command.
It’s usage is very very very simple, run the script with date/time,minutes and filename.
Of course, you must edit the script to match your setup and frequency to record.
Once you’ve recorded the stream, you can re-play it in GQRX.

I use this script to record the ISS passes (145.800Mhz) with my RaspberryPI that’s always powered on since 2012 (or 2013…cannot remember).

Let me explain a bit this script with an example.

You’ve an rtl dongle and wanna record 145.800Mhz at 18:46 of 26 April 2015 for 8 minutes and put the output file on /media/stream01.out for later reply with GQRX.

Edit the script and look at it carefully.
You’ve to change the “freq”,”donglenum”,”gain”,”ppm”,”dest” AND the -X PARAMETER.

freq=145800000   (that’s the ISS downlink freq.)
donglenum=the number of the dongle you wanna use, starting from 0, i use my second dongle in the example
gain=your desidered gain
ppm=your dongle ppm value
dest=where you want the script to record the i/q stream

If you do not use my fork of rtl-sdr package, REMOVE the -X in the script commands (7th row starting from the bottom of the script). The -X is required if you wanna use the RTL AGC that you can find only in my modded package.

Save the script and call it with these parameters:

./sdrrecorder 18:46 04/26/2015 8 stream01

What will happen then? You’ll return to the command prompt…
The script will create another script (that will be automatically deleted) on the /dest folder.
That script contain all the commands required to record and convert the stream.
The script will be scheduled at 18:46 04/26/2015, it’ll record for 8 minutes on 145.800Mhz (then convert it to a readable format by GQRX).
Remember….do not record a lot of minutes….it’ll require a LOT of disk space (my /media is a shared folder on my NAS).

Once you’ve recorded the stream, you can replay using GQRX, so let’s fire up GQRX and change the “device string” to:

file=/home/michele/Scrivania/stream01.out,freq=145800000,rate=1200000,repeat=false,throttle=true

and “Sample rate” to 1200000

Where “file=/….” is the EXACT position of your recorded i/q stream.
Now center the spectum at 145800000+300000 (=146100000) and in “Receiver Options” you must read “0.000kHz”.
The spectrum must be centered to 146100000 because the script will record at a shifted frequency of +300kHz to avoid overlapping with DC.
So, due to the fact that we’re recording at a samplerate of 1.2M, we’ll see our desidered frequency at 25% of the entire screen.
That’s really easy to understand…think of your screen that’s 1200000 pixel wide, divide it by 2, you’ll get the first half portion of the screen (600000 pixels wide) , substract 300000 (our shift) and you’ll get  again 300000 (that’s half of 600000).
I know my english isn’t good…but i hope you’ll get the point.
I would suggest to create different copies of the script, giving them an unique name (like iss.sh, afsk.sh,aereal.sh and so on).

You can now play your stream by cliccking on the “Power button” in GQRX.

Here’s the script:

#########################################################
#                                                       #
# rtlrecorder v1.0 by MichelinoK                        #
#                                                       #
# Let you record i/q stream and reencode it to be used  #
# in gqrx                                               #
#                                                       #
# ./rtlrecorder hh:mm mm/dd/yyyy mins filename          #
#                                                       #
# example:                                              #
#                                                       #
# ./rtlrecorder.sh 12:52 12/21/2014 6 primo             #
#                                                       #
#=======================================================#
# REMOVE '-X' if not using MichelinoK's modded packages #
# MichelinoK's moddem package can be found here:        #
#                                                       #
#       https://github.com/michelinok/rtl-sdr/          #
#                                                       #
# It adds the ability to enable RTL AGC on rtl_sdr      #
#########################################################

#!/bin/bash
freq=145800000          # ...so gqrx center must be on 146100000   ( i use  145800000 for iss)
fwshift=300000          # this is freqtuned-yourfreq (will tune to freq+fwshift) (i use 300000Hz as shift)
samprate=1200000        # recording samplerate
donglenum=1             # dongle number to be used
gain=0                  # gain to be used , i use auto
ppm=15                  # ppm correction
dest=/media             # destination folder

let samplestorec=$3*60*$samprate
let tuneto=$freq+$fwshift

#shbuilt=$4.sh          #maybe not needed....need to check!

echo '#!/bin/bash' > $dest'/'$4.sh
echo 'rtl_sdr -f '$tuneto ' -d '$donglenum ' -s '$samprate ' -p '$ppm ' -g '$gain ' -n '$samplestorec ' -X '$dest'/'$4 >> $dest'/'$4.sh
echo 'sox -t raw -r '$samprate' -b 8 -c 1 -e unsigned-integer '$dest'/'$4' -t raw -r '$samprate' -c 1 -e float '$dest'/'$4'.out' >> $dest'/'$4.sh
echo 'rm '$dest'/'$4 >> $dest'/'$4.sh
echo 'rm '$dest'/'$4'.sh' >> $dest'/'$4.sh
chmod a+x $dest/$4.sh
at $1 $2 -f $dest/$4.sh

 

If you like this article, please consider donating by clicking on the Paypal button on the top right.

This entry was posted in Radio. Bookmark the permalink.

Leave a Reply

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