A dirt cheap “spectrum analyzer” with an RTL-SDR dongle.

Update: There used to be an error in the schematic, R2 was missing. It is needed to work correctly.

Frequency response of the 137MHz filter

Frequency response of the 137MHz filter (don’t mind the spurs)

If you want to see the frequency response of a filter, a spectrum analyzer with a tracking generator will be the tool of the trade. There’s only one problem: I don’t have one. An alternative is to hook up an RF signal generator, measure the output power of the filter with a power meter at multiple frequencies, and plot the result manually. But here too I have a problem: I don’t have a signal generator. Or a power meter. Besides, it’s a lot of work. So when I wanted to test a 137MHz bandpass filter, at first I didn’t think it would be possible. Fortunately I found a way that works reasonably well, and cost me nothing.

Using an RTL-SDR dongle, you can sample a piece of the spectrum up to 2 or 3MHz wide at a time. That’s not really enough for use as a spectrum analyzer. However, what you can do is to make the dongle hop from one frequency to the next, and make a composite spectrum. There is software that does just that: rtlsdr-scanner. This is fine if you want to scan the bands to spot interesting frequencies, but I still can’t measure filters with it.

If only I had a transmitter that transmits at every frequency: I could pass it through the filter and see what remains at the other side! Something like a wideband noise generator. After asking Google, it turns out that generating such noise is quite easy: a diode, when operating at the reverse breakdown voltage, generates a fair amount of noise, hundreds of megahertz wide! Then it’s just a matter of blocking the DC voltage with a capacitor, and there you have it, you are now the proud owner of a noise source! You then send this noise through an amplifier stage, but I used the amplifier of the dongle instead (I can set the gain between -1 and +42dB). Not ideal, because there are lots of other signals picked up too, but changing a slider in software is much less work than making a wideband amplifier. I also added an extenal 6dB attenuator immediately after the noise source to get better impedance matching to 50Ω.

A current source (D1, D2, R1 and Q1) feeding a zener diode. Any diode will do really, just make sure the breakdown voltage is reached. R1 determines the current (there's a 0.6V drop over the resistor so i=V/R). R2 value is not critical, 10k-100k is fine.

A current source (D1, D2, R1 and Q1) feeding a zener diode. Any diode will do really, just make sure the breakdown voltage is reached. R1 determines the current (there’s a 0.6V drop over the resistor so i=V/R).
R2 value is not critical, 10k-100k is fine.

The setup is now ready for prime time. When I turn on the noise generator, the noise floor of the dongle increases by 30dB around 130MHz. So far so good. I set the start- and stopfrequencies to 125MHz and 150MHz, and do a sweep. I repeat the measurement with the filter in between, and save both sweeps. Then in Tools->Compare, I can subtract the two signals. This sets the noise level as the 0dB reference. The result is seen in the image at the top (the “difference” scale is at the right, the left scale is not used as the two individual plots are hidden).

Apart from the spurs, the technique works quite well! It sure has limitations, but so does a professional spectrum analyzer. The difference is that with this dongle, you bump into them a lot sooner. Well, ok, almost immediately. The biggest problem is the dynamic range. If your dongle measures 30dB of noise from the noise source, it means that after 30dB of attenuation, you have nothing left to measure. So while you can get accurate readings of the filter loss at the passband (2.5dB in this case), you’ll hit the noise floor of the receiver before you reach the stopband attenuation of the filter. Also, the ADC of the dongle is 8 bit, so the difference between the largest and the lowest possible sampled voltage (the dynamic range of the ADC) is 20*log(256) or 48dB. Even if you can increase the noise level, you are limited by this 48dB. You could start playing with changing the amplification of the LNA, a bit like High Dynamic Range Imaging. Maybe this could improve the range, maybe it will block the receiver. In any case, the first improvement should be to make the noise source better. Both the amplitude and the frequency range. at 100MHz I get roughly 30dB noise increase, but at 640MHz I only have 10dB left. that means that I have almost no dynamic range at that frequency.

Another problem is that the noise floor of the dongle isn’t flat. It’s more like the Alps. So the dynamic range varies, and you may see some bumps in the frequency response that aren’t really there, it’s just the noise of the receiver itself. If you have a dongle you can see the bumps yourself by setting full LNA gain and doing a large sweep with no antenna connected. You’ll see the power spectrum go up and down, and all kinds of spurs will show up. If you take a look at the FM broadcast band around 100MHz, you’ll see the signals leak through. This device is designed to do the job it’s meant to do at the lowest price point possible, not to have the best shielding and superb RF performance.

Nonetheless, there’s a lot to experiment with. What I’ve shown here is just the results of a few days of hacking. There’s definitely improvements that can be made, both in software and in hardware. So just make yourself a noise source and start playing!

Oh, and if you’re wondering what the filter is used for: it’s for improving NOAA weather satellite reception with a dongle. With these receivers it really helps a lot when the strong signals at other frequencies are removed first.

References:

14 thoughts on “A dirt cheap “spectrum analyzer” with an RTL-SDR dongle.

  1. Pingback: Measuring the Frequency Response of a Bandpass Filter with the RTL-SDR - rtl-sdr.com

  2. David

    Please provide actual part numbers for the parts you used for this design – so that others (like me) cab duplicate your findings. Thank You… David

    Reply
  3. hansvi Post author

    The short answer is: any generic type you happen to find in your junk box will do: For D1 and D2 I used a 1N4148 (I have a ton of those), for Q1 I used a BC 559 (as long as it’s a PNP transistor you’ll be fine), and for R1 I used 10k in series with a 100k variable resistor, so I could adjust the current in order to experiment. In the end I just set it to minimum resistance. I used a 1nF ceramic capacitor for C1, but haven’t experimented with the value. It’s not critical either. Then I tried some diodes, and settled for a 10V zener diode that was quite noisy. The entire thing is fed by 2 9V batteries in series to get 18V.

    I am preparing a new article that goes a bit more in-depth, it should be ready one of these days.

    Have fun, if you have any more questions feel free to ask. (Or if you have some results, that would be great too).

    Reply
  4. Ame

    You say that you “subtract the two signals”, however if you’re after the filter transfer function you should take the ratio the measured spectra: H(f) = Output(f)/Input(f)

    Reply
  5. PASCAL

    Hello in September 2013 I did a test of our sdr with my deck noise nuova electtronica lx1142k to view the setting of a filter duplexer uhf:
    he well, ca very well on with key cinercy and noise generator from 0 to 2 ghz. filter is installed between the elements 2.
    Is less than a well with professional analyzer ca optiontracking but allows to easily a first approach to filter settings with a low cost equipment.

    Kit noise generator lx1142k:
    http://www.nuovaelettronica.it/prodotti/kit/strumenti-laboratorio/generatore-di-rumore-2-ghz-1-1142
    With diagrams …
    http://f6exe83.free.fr/articles.php?pg=art111
    http://www.rogerk.net/forum/index.php?topic=41040.0

    73’S OF F1MIJ

    (Edited to undo the all caps – ON8VQ).

    Reply
  6. Rodrigo

    ola teria como sintonizar filtros de cavidades passa baixo, passa faixa, com essa sua grande descoberta, e como fazer?

    Reply
    1. hansvi Post author

      Google translate told me that you asked: hello would like tuning cavity filters low-pass, band, with this his great discovery, and how to do?

      Tuning filters is also on my list. Even without using the compare tool, you should be able to see the filter shape clearly. So you just connect the noise source, an attenuator for rough impedance matching, and your filter to the dongle. First do a wide sweep to locate the passband or cutoff frequency. Then you select the “continuous” setting in the rtlsdr-scanner utility. By moving fast (16ms setting), and only scanning the frequency range of interest, you may get a new sweep every 5-10 seconds. Then you tune your filter. When you are done, you can use the compare tool, as described in the article, to get a better view of the actual shape, the insertion loss etc.

      It will be slower than with a real-time spectrum analyzer, but I think it will still be acceptable.

      Good luck.

      Reply
  7. Charles

    This is great! I have it working now, just need the time to go to the repeater site and tune the multicouplers. I can also use a radio that I trust the TX freq with a step attenuator for rought tuning of the filters and to calibrate the dongle. Thanks for all your hard work.

    Reply
  8. Tom

    Hi Hans,

    really nice post and clever idea. I have a short question. I’m also planning to use my SDR dongle as a spectrum analyser. To what extent is it safe to connect signals (from your noise generator, RF oscillator, …) directly to the dongle antenna input? What is the maximum input voltage and current limits you used?

    Kind regards,

    Tom

    Reply
  9. hansvi Post author

    Hello Tom,

    Frankly, I have no idea. I doubt that a volt could do it any harm. I also think that at that voltage, the ADC will have reached clipping. But in the end, it’s a guessing game. Use attenuators to add protection.

    Good luck with your experiments,
    Hans.

    Reply

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>