In part one of this guide it became clear that a Raspberry Pi with a 700 mm long wire on pin 7, running a variant of the PiFM software is an easy way to make a nuisance of yourself. We might not be broadcasting kilowatts of power and realistically, you are not going to be knocking planes out of the sky, but the Pi is a dirty old man when it comes to broadcasting and we need to clean up its act.

The obvious way to do that is to put a filter between the Pi’s output and the aerial. If the design considerations and analysis of the filter’s performance don’t interest you, skip to the end for circuit diagrams, construction instruction and purchase info (possibly).

As always, these posts are for educational use only. Do not use your Pi as a transmitter unless it is legal for you to do so, which is highly unlikely. Using a filter will not make it any less illegal for you to use your Pi as a transmitter.  Always brush your teeth before bedtime and be nice to people.

To recap, this is typically the sort of thing that comes out of your Pi when you use it as an FM transmitter:

There’s a lovely spike around the 144 MHz mark, which is the amateur radio 2m band. There are probably not many radio hams near me that like the sort of music I listen to. Come to think of it, some times I’m not sure I do either. In general, it’s a broad splattering of crap all over the spectrum. And the Pi’s transmitted output is just as bad, ho ho ho. Ahem. This is the sort of thing we need:

You might notice R1 there. The GPIO pins are not designed to drive inductive or capacitive loads, so we need to make the filter input a bit more friendly. The easiest way is to put a resistor between the Pi and the filter’s inductor. I’ve tried it and it works, but it does reduce the range of the transmission. If you want to try it without R1, don’t blame me if you fry your Pi. There’s about 5 dB loss with this design, which might be fine for you. For me, it reduced the range just enough that the signal was fading out if I stood in the wrong part of the kitchen. The solution was either to avoid using the fridge or to amplify the output a bit.

I’m not an expert with RF circuits (although I probably know more than you), so I used the interwebs to find a design that would

You can probably tell what my priorities were. This was the prototype:

Those with a keen eye have probably already spotted that it looks shit. Bear in mind that it’s already been bodged around a bit, and it looked worse than that by the time I’d finished experimenting with the poor thing. It is a single stage class C amplifier with a low pass filter on the output. The 2N4427 transistor is old and cheap; I bought 5 from China for about £3. Everything else (apart from the variable capacitors) is bog standard and the coils are easy to wind. The variable capacitors are stupidly expensive – there is about £20 worth of them in that photo, so they had to be replaced with fixed ones that cost pennies.

The end result was this circuit:

Pi Hat Filter – click to enlarge.

It’s cheap, simple and it works quite well. This is the finished hat installed and working:

This is the output with the filter hat on:

Out of band signals are attenuated by at least 20 dB, which means they are 1/100th the power of when it was hatless. There is even a little bit of gain at our broadcast frequency, which also amplifies the in-band harmonics, unfortunately. It’s not exactly BBC quality but it should stop you annoying the neighbours. If you want to get the absolute maximum performance out of the filter, use 5-95pF variable capacitors instead of C7, C8, C13 and C16 and keep tweaking them until it becomes apparent that you aren’t really having any effect.

The design files are here.  If you would be interested in a kit of parts or a ready made hat, leave a note in the comments and I’ll look into it.

I’ll leave you with a comparison of the filtered (orange) Vs. unfiltered (blue) Pi:

Good, eh?

12 Responses

  1. Hi,

    I’m a volonter in a French local broadcast station and we’d like to try adding RDS to our broadcast (for now the old and trusty system we’ve got doesn’t have any). We’d like to start with a prototype centered around the Pi and PiFMRDS (https://github.com/ChristopheJacquet/PiFmRds). We’d be glad to have a kit of parts or at least a PCB since we don’t have the means to do one (but we surely can solder).

    Cheers,

    Jo

  2. Hello. Thanks gor the article, I’ve found it on Hackaday.
    You may want to check your wordpress plugins: when I visited this page from iPhone I was redirected to a scam website. It typically happens when you’ve got a malicious plugin installed.

    1. BTW I was able to reproduce the issue that Volodymyr Smotesko mentioned. I was forwarded to spam when I viewed this page in Safari’s “Responsive Design Mode”. It only did it on the first load. After that, I was able to reproduce again on my iPhone on wifi and then the same iPhone on cellular. It appears to only do it once per browser/ip combo.

  3. I’d be interested to buy it in kit. I don’t know how to handle Gerber files, but I can solder components if I have an image telling me where to solder what on a PCB.

  4. (re-sending my comment, maybe there was an issue with my email or website’s domain being non-ASCII)

    Given that that 50 MHz is likely to be smack dab in the middle of the 6 meter amateur band, it might be wise to use a band-pass filter instead. It doesn’t look like there’s very much of it down there, but it never hurts to be a better neighbor 🙂

    For the prospective pirate out there: if you get more than enough power out of this, consider making the filter even more aggressive by adding a few turns on L5/L6 and upping the capacitance of C14/C15 proportionately. Of course in the end you’re mostly polishing a turd when it comes to PiFM-type transmitters

  5. I like the idea of band pass. I’d like to adapt it toward amateur radio use. how difficult to get to lower frequencies, like 3800, 7000, 14000khz, etc?

  6. with all those armonics I would not directly apply raspberry output to a Class C amplifier without a good filtering. But the test worth it to be done