How to build a Raspberry Pi Radio Transmitter

Originalartikel

Backup

<html> <p>The Raspberry Pi can be used pretty much for any conceivable application &#8211; as well as a radio transmitter. Frequencies from 1Mhz to 250Mhz can be used, including the usual radio frequencies between 88 and 108Mhz.<br/> Depending on the position and antenna, the signal can be transmitted up to 100 meters.</p> <p>In this tutorial, I will show what you need for it and how to set up the radio station on the Raspberry Pi.</p>

<h2>Required Hardware Parts</h2> <p>I have used the following hardware parts:</p> <ul><li><a href=„https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&amp;field-keywords=Raspberry+Pi+3&amp;tag=754u-20“ target=„_blank“ rel=„noopener“>Raspberry Pi 3</a></li> <li><a href=„https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&amp;field-keywords=USB+sound+card&amp;rh=i%3Aaps%2Ck%3AUSB+sound+card&amp;tag=754u-20“ target=„_blank“ rel=„noopener“>USB sound card</a></li> <li><a href=„https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&amp;field-keywords=pin+Jumper+cable&amp;rh=i%3Aaps%2Ck%3Apin+Jumper+cable&amp;tag=754u-20“ target=„_blank“ rel=„noopener“>Jumper cable</a> (possibly a stronger antenna, depending on the application)</li> </ul> <div class=„c10“><ins class=„adsbygoogle c9“ data-ad-format=„fluid“ data-ad-layout=„in-article“ data-ad-client=„ca-pub-7500567011943156“ data-ad-slot=„4770162299“/></div> <h2>Software</h2> <p>The basis is the library piFM. With this, it is possible to &#8220;misuse&#8221; GPIO 4 (pin 7) of the Raspberry as a transmitter. An antenna (either a real antenna or a simple wire) must be connected to it.</p> <p>Firstly we load the software and compile it.</p> <pre class=„“> git clone https://github.com/rm-hull/pifm &amp;&amp; cd pifm make </pre> <p>Now that you&#8217;ve connected the antenna to pin 7 (the 4th pin from the top of the inner side), you&#8217;re ready to go. To do this, piFM must be started as root and a file specified (.wav format) to be played. In addition, the transmission frequency can be specified optimally (standard 103.3Mhz) and the audio sampling rate (in Hz).</p> <p>An example call would be the following:</p> <pre class=„“> sudo ./pifm sounds/star-wars.wav 103.3 22050 stereo </pre> <p>Now, if you are looking for this frequency on your radio, you should hear the Star Wars melody and the previous noise should stop. At the end of the song, it will be played again from the beginning.</p> <p>In addition, the library can be easily integrated into Python:</p> <div id=„crayon-5b488d37d2986215970508“ class=„crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate c15“ data-settings=„ no-popup minimize scroll-mouseover“> <div class=„crayon-toolbar crayon-tools c11“ data-settings=„ show“> <div class=„crayon-button crayon-nums-button crayon-button-icon“ title=„Toggle Line Numbers“/> <div class=„crayon-button crayon-wrap-button crayon-button-icon“ title=„Toggle Line Wrap“/> <div class=„crayon-button crayon-expand-button crayon-button-icon“ title=„Expand Code“/> Python</div> <div class=„crayon-info c12“/> <div class=„crayon-plain-wrap“/> <div class=„crayon-main“> <table class=„crayon-table“><tr class=„crayon-row“><td class=„crayon-nums“ data-settings=„show“> <div class=„crayon-nums-content c13“> <div class=„crayon-num“ data-line=„crayon-5b488d37d2986215970508-1“>1</div> <div class=„crayon-num crayon-striped-num“ data-line=„crayon-5b488d37d2986215970508-2“>2</div> </div> </td> <td class=„crayon-code“> <div class=„crayon-pre c14“> <div class=„crayon-line“ id=„crayon-5b488d37d2986215970508-1“>import PiFM</div> <div class=„crayon-line crayon-striped-line“ id=„crayon-5b488d37d2986215970508-2“>PiFm.play_sound(„path/sound.wav“)</div> </div> </td> </tr></table></div> </div>

<div class=„c10“><ins class=„adsbygoogle c9“ data-ad-format=„fluid“ data-ad-layout=„in-article“ data-ad-client=„ca-pub-7500567011943156“ data-ad-slot=„4770162299“/></div> <h2>Live speaking</h2> <p>More interesting than just playing music is probably the opportunity to speak live. This is relatively easily possible&#160;with&#160;

arecord

. All you need to do is connect a microphone via the USB sound card.</p> <p>Here we start a recording and pass it directly as input for piFM via pipeline:</p> <pre class=„“> arecord -f S16_LE -r 22050 -twav -D plughw:0,0 - | sudo ./pifm - </pre> <p>These&#160;<a href=„http://linuxcommand.org/man_pages/arecord1.html“ target=„_blank“ rel=„noopener“>

arecord

</a> parameters worked best for me. If you are getting only bad sound, you would have to adjust the parameters if necessary. Instead of

plughw:<strong>0</strong>,0

&#160;it can also be&#160;

plughw:<strong>1</strong>,0

. That&#8217;s why it&#8217;s the best to call</p> <pre class=„“> amixer </pre> <p>The connected audio devices should be displayed.</p> <p>During testing, I have noticed that no signal was sent after I wanted to listen to my recording via&#160;

aplay

. The same thing can happen if the default audio settings have been changed (

/etc/modprobe.d/alsa-base.conf

). In this case, the settings should be reset (if changed) and restarted. If the problem persists&#160;

sudo apt-get update &amp;&amp; sudo apt-get upgrade

or a new Raspbian image will help. But as I said, usually just a reboot is enough.</p> <div class=„c16“/> </html>