Radio2pi Workshop content

 Radio2pi toolbox

A general workshop on radio broadcast with a pibox, that deconstructs all the tools used for the pibox, that can be of help to build another architecture, fork the pibox or understand better what's inside.

 SUMMARY

    1 installation of Raspbian system on R-pi
    2 PI_FM_RDS
    3 Fm_Transmitter
    4 Rpitx
    5 Gqrx
    6 Rtl-Sdr
    7 websdr
    8 Espeak
    9 Minimodem
    10 DUMP1090
    11 How to construct a playlist in bash, to broadcast through Raspberry-PI
    12 How to use the input on a usb soundcard to broadcast radio :
    13 create a stream with cat
    14 usefull tool for streaming

installation of Raspbian system on R-pi

start from scratch

Step 1: Install Raspbian system on the SDcard download the image on your computer https://www.raspberrypi.org/downloads/raspbian/ insert the sd card in your computer then follow the instructions here: https://www.raspberrypi.org/documentation/installation/installing-images/

Step 2 : connect to Raspberry on the same network introduce the SD card in the Raspberry pi connect ethernet cable then plug power To connect to Raspberry on the same network : Search devices connected to network on port 22 (default port for SSH connection) on macOSX : $ ifconfig You will get your network ip, ex. 192.168.1

Then with 'nmap', find devices connected to the network with port 22 open If you don't have nmap on MacOSX, you can get it here : https://nmap.org/dist/nmap-7.12.dmg

     $ nmap -p 22 --open 192.168.1.*

Then, find your Raspberry Pi ip on the nmap result and connect to your Raspberry on ssh
for example :

     $ ssh pi@192.168.0.49

Step 3. raspi-config, update/upgrade

   $ sudo raspi-config

Recommended

  1. change passwd (optional)
  2. international > language, timezone
  3. verify boot option B1 console user login

then update the system (1 mn)

   $ sudo apt-get update

and upgrade the system (can last a few minutes)

   $ sudo apt-get upgrade

step 4. LIBRAIRIES install utilitaries: libavtools (avconv) sox oggfwd libsndfile1-dev

   $ sudo apt-get install libav-tools sox oggfwd libsndfile1-dev

to see the documentation of each library:

   $ man sox
   $ man libav-tools ...

PI_FM_RDS

installation & test PiFmRds, explore the fonctions, test with a track mp3, wav, with a stream, listening on several frequencies (limit : 88 to 108 Mhz)

Step 1: Download PiFmRDS :

   $ mkdir /home/pi/downloads
   $ cd /home/pi/downloads
   $ wget https://github.com/ChristopheJacquet/PiFmRds/archive/master.zip
   $ unzip master.zip
   $ cd PiFmRds-master/src
   $ sudo make clean
   $ sudo make

try pifm_rds

   $ sudo ./pi_fm_rds -freq 108 -audio sound.wav

try a stream for ex. http://stream.p-node.org/billiejean.mp3
and adapt pi_fm_rds path to your pi it can be different

   $ avconv -i http://stream.p-node.org/billiejean.mp3 -f wav - | sudo ./pi_fm_rds -freq 108.0 -audio -

Step 3: Copy a file from your harddrive to play it

using scp

check manual

   $ man scp

basic syntax :

from your computer (open a new terminal):

the structure is : $ scp filepath user@ip:/path

example:

   $ scp /home/user/Desktop/sound.wav pi@192.168.1.132:/home/pi/downloads

be cautious when using it => it as it may erase files !

then from the pi terminal

    $ ls path _of_the_folder_where_your_file_is

About RDS broadcasting: https://github.com/ChristopheJacquet/PiFmRds

FM_Transmitter

Step 1: installation and test with fm_transmitter

   $ cd /home/pi/Downloads/
   $ sudo apt-get install make gcc g++
   $ wget https://github.com/markondej/fm_transmitter/archive/master.zip
   $ unzip master.zip
   $ cd fm_transmitter-master
   $ make

Step 2 : try

   $ sudo ./fm_transmitter -f 108 -r star_wars.wav

from a stream read by avconv

   $ sudo apt-get install libav-tools
   $ avconv -i http://stream.p-node.org:80/billiejean.mp3 -ac 1 -ar 22050 -f wav - | sudo ./fm_transmitter -f 108.0 -

FM Transmitter is more stable than PiFmRds, for streams broadcasting. There is a lot of others softwares like these ones. Let see an other one :

RPITX

installation and test rpitx

RPITX is able to broadcast on sstv, am fm etc .. from 130 kHz to 750 MHz. documentation : https://github.com/F5OEO/rpitx "all you need to do is plug in a wire antenna to Pin 12 (GPIO 18) on the GPIO port and run the PiTx software by piping in an audio file or image for SSTV."

prerequisite : libsndfile1-dev (already installed before)

install git

   $ sudo apt-get install git

then install ritpx

   $ cd /home/pi/Downloads/

   $ git clone https://github.com/F5OEO/rpitx

   $ cd rpitx

   $ ./install.sh

test riptx

FSQ mode

   $ sudo ./testfsq.sh

   $ sudo text fsq => change (nano testfsq.sh repalce test with helloworld for ex.)

FM Mode broadcast on 108

   $ sudo ./testfm.sh

AM Mode

   $ sudo ./testam.sh

etc ...

GQRX

http://gqrx.dk/

instlall Demo gqrx on Linux and on MacOSX > 10.9 and Raspbian or sdr# on Windows

or for MacosX <10.9 install RTL SDR https://github.com/2013-UQ-Communication-Systems/public/wiki/Installing-RTL-SDR-in-Mac-OSX

test precise frequency listening (talkie walkie, radio, strange signals..).

test GQRX for a frequencis hunting!

Airband Radio London Control Frequencies 118.050 > 136.600 [http://www.2e0jps.com/radio/airband/control/ http://www.pb-photos.com/radio.html http://www.wattisham.org.uk/genscan_feb_mar_2010.pdf](http://www.2e0jps.com/radio/airband/control/ http://www.pb-photos.com/radio.html http://www.wattisham.org.uk/genscan_feb_mar_2010.pdf)

London Center Radio Frequencies http://ukradioscanning.com/viewtopic.php?f=7&t=33

Citizen band list & more http://www.coastalcomms.org.uk/frequency_listings.htm

 RTL-SDR

download & installation of rtlsdr on raspbian. interception piFM via rtlsdr.

installation packets rtl-sdr // doc http://sdr.osmocom.org/trac/wiki/rtl-sdr

   $ sudo apt-get install rtl-sdr

blacklist the module to make it work

   $ sudo nano /etc/modprobe.d/raspi-blacklist.conf

add on the file content:

   blacklist dvb_usb_rtl28xxu
   blacklist rtl_2832
   blacklist rtl_2830

then

   $ sudo reboot

test listen FM band radio on various frequencies

for example

   $ rtl_fm -f 89100000 -M wbfm -r 48000 - | aplay -r 48k -f S16_LE

or

   $ rtl_fm -f 94900000 -M wbfm -r 48000 - | aplay -r 48k -f S16_LE

use rtl_fm to catch minimodem

   $ rtl_fm -f 108e6 -M wbfm -s 352k -A fast -r 44.1k -l 0 -E deemp | AUDIODEV=hw:0,0 play -r 44.1k -t raw -e s -b 16 -c 1 -V1 -

websdr

http://www.websdr.org

WebSDR at the University of Twente, Enschede, NL http://websdr.ewi.utwente.nl:8901/ JO32KF; 417 users 0.000 - 29.160 MHzMini-Whip WebSDR in C3 Ordino - ANDORRA PRINCIPALITY - ARDAM Ham Radio Association - RX 4 pcs FuncubePro+ http://sdr.radioandorra.org:8901/ JN02SN; 34 users7.008 - 7.200 MHzHalf wave Dipole.50.000 - 50.192 MHz2 elem. Moxon NE3.610 - 3.802 MHzHalf wave Dipole.14.043 - 14.235 MHz 160m, 60m, 80m, 40m and 17m SDR's from Nantwich in Cheshire http://hackgreensdr.org:8901/ IO83RA; 46 users1.804 - 1.996 MHz204 foot long double size G5RV3.600 - 3.792 MHz 5.237 - 5.428 MHz7.008 - 7.200 MHz14.130 - 14.322 MHz18.019 - 18.211 MHz HF WebSDR, South of Russia, Volgodonsk City. (op. RW6MIT) http://websdr.net/ LN17CM; 37 users3.458 - 3.842 MHzOCF Dipole Antennas6.908 - 7.292 MHz13.983 - 14.367 MHz20.816 - 21.584 MHz WebSdr in Santa Rita do Sapucai, MG, Brasil http://py4ve.qsl.br:50000/ GG77DR; 23 users

ESPEAK

installation

   $ sudo apt-get install espeak

you can check manual :

   $ man espeak

first test:

   $ espeak "hello world"

change pitch :

   $ espeak -p 100 "hello world"

broadcast voice on radio :

   $ espeak "hello" --stdout | avconv -i - -f wav - | sudo /home/pi/Downloads/fm_transmitter-master/fm_transmitter -f 108 -

MINIMODEM

installation minimodem

   $ sudo apt-get install minimodem

you can check manual :

    $ man minimodem

you have two configurations :

Tx => to transmit

Rx => to receive

first test (transmit):

   $ echo "my first test" | minimodem --tx 100

if it doesn't work, try before :

   $ pulseaudio --start

write ouput to a .wav file to transmit :

   $ echo "this is a test" | minimodem --tx 100 -f /tmp/testminimodem.wav 

listen the file you just wrote :

   $ aplay /tmp/testminimodem.wav 

decode sound with microphone connected to the sound card (the --tx and --rx must be the same value) :

   $ minimodem --rx 100

Broadcasting minimodem :

to broacast on radio using 'echo', 'minimodem' and pi_fm_rds (you need to use '&&' to execute one command after another.

play in loop

   $ echo "test" | minimodem -tx 100 -f /tmp/output.wav && sudo ./pi_fm_rds -freq 108 -audio /tmp/output.wav

play once

   $ echo "t aaaaaa e aaaaaa zzz" | minimodem --tx 100 -f /tmp/test.wav && sox /tmp/test.wav -t wav - | sudo ./pi_fm_rds -freq 108.0 -audio -

decode

with rtl-sdr piped to sox piped to minimodem, structure is: rtlsdr > sox > minimodem --rx 100 on 108MHzFM

examples:

   $ rtl_fm -f 108e6 -M fm -s 352k -A fast -r 44.1k -l 0 -E deemp | sox -t raw -r 44.1k -e s -b 16 -c 1 -V1 - -t wav - | minimodem -f 1 --rx 100
   $ rtl_fm -f 108000000 -M wbfm -r 48000 - | sox -t raw -r 48000 -e s -b 16 -V1 - -t wav - | minimodem -f - --rx 100D
   $ rtl_fm -f 108000000 -M wbfm -r 48000 - | sox -t raw -r 48000 -e s -b 16 - -t wav - | minimodem --rx 100 -f -

DUMP1090

Installation of cmake & lib-usb :

   $ sudo apt-get install cmake

   $ sudo apt-get install libusb-1.0-0-dev

sources downloading and installation of RTL2883U :

   $ git  clone  git://git.osmocom.org/rtl-sdr.git
   $ cd  rtl-sdr
   $ mkdir  build
   $ cd  build
   $ cmake  ../ -DINSTALL_UDEV_RULES=ON
   $ make
   $ sudo  make  install
   $ sudo  ldconfig

sources downloading and installation of the application dump1090 :

   $ cd
   $ cd Downloads
   $ wget https://github.com/MalcolmRobb/dump1090/archive/master.zip
   $ unzip master.zip
   $ cd dump1090-master/
   $ make

Run. :

   $ ./dump1090 --interactive

here you can see the flights transiting

check : http://flightradar24.com

same command

   $ ./dump1090 --interactive --net

then launch on chromium http://localhost:8080

COULOIR AÉRIEN by Cécile Babiole http://babiole.net/spip.php?article107

How to construct a playlist in bash, to broadcast through Raspberry-PI

prepare a folder with music, such as '/home/pi/musics'

nano = text editor


   $ man nano 

edit a bash file that will be our program for radio playlist

   $ nano playlist.bash 

GNU nano 2.2.6

File: /home/pi/playlist.bash

   while [ 1 ]
   do
       while read plst
       do
           echo "$plst"
           avconv -loglevel quiet -i /home/pi/panier-panio-mp3/2/"$plst" -f ogg - | sox -t ogg - -t wav - | sudo /home/pi/PiFmRds-master/src/pi_fm_rds -freq 108 -audio - > /dev/null 2>&1
       done < <(ls /home/pi/folder/2)
   done

when script is done

modification of the rc.local file insert bash program for execution at startup and insert some comment

GNU nano 2.2.6
File: /etc/rc.local

   #!/bin/sh -e
   #
   # rc.local
   #
   # This script is executed at the end of each multiuser runlevel.
   # Make sure that the script will "exit 0" on success or any other
   # value on error.
   #
   # In order to enable or disable this script just change the execution
   # bits.
   #
   # By default this script does nothing.

   # Print the IP address
   _IP=$(hostname -I) || true
   if [ "$_IP" ]; then
     printf "My IP address is %s\n" "$_IP"
   fi

   # this is a script of a radio broadcast playlist that be executed at boot
   /bin/bash /home/pi/playlist.bash &

   exit 0

How to use the input on a usb soundcard to broadcast radio :

First : plug your card To see if your device is recognized :

   $ dmesg
... [ 738.353160] usb 1-1.4: new full-speed USB device number 5 using dwc_otg [ 738.455413] usb 1-1.4: New USB device found, idVendor=0d8c, idProduct=000c [ 738.455440] usb 1-1.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0 [ 738.455458] usb 1-1.4: Product: C-Media USB Headphone Set [ 738.467788] input: C-Media USB Headphone Set as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.3/0003:0D8C:000C.0001/input/input0 [ 738.523553] hid-generic 0003:0D8C:000C.0001: input,hidraw0: USB HID v1.00 Device [C-Media USB Headphone Set ] on usb-3f980000.usb-1.4/input3 [ 738.994622] usbcore: registered new interface driver snd-usb-audio
   $ arecord -l

                List of CAPTURE Hardware Devices ****

card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]

 Subdevices: 0/1
 Subdevice #0: subdevice #0

What is interresting here is : 'card 1' 'device 0'

So to broadcast :

   $ arecord -r 44100 -D plughw:1,0 - | sudo /home/pi/Downloads/PiFmRds-master/src/pi_fm_rds -freq 108 -audio -

To see some devices compatible with Rasperry PI / Raspbian : http://elinux.org/RPi_VerifiedPeripherals

create a stream with cat

prerequisite : be on the same network select a wav file on your computer and stream the file on a distant computer by using the following command structure : $ cat path/to/the/file | netcat ip_adress_of_the_distant_computer port (any port > 1024)

example :

   $ cat /home/Downloads/sound.wav | netcat 192.168.1.127 9876

on mac netcat = nc

then listen to it on the computer

   $ netcat -l 9876 | aplay

With fm_transmitter we need only one channel :

   $ netcat -l 9876 | avconv -i - -ac 1 -f wav - | sudo ./fm_transmitter -f 108 -

OK with pifmrds :

   $ netcat -l 9876 | sudo Downloads/PiFmRds-master/src/pi_fm_rds -freq 108 -audio -

usefull tool for streaming

icecast2 (server) http://icecast.org/
butt (streaming client) http://www.danielnoethen.de/
other R-pi broadcasting resource: https://github.com/search?utf8=%E2%9C%93&q=pi+fm