Install

From ∏ node
Jump to: navigation, search

How to install a pibox

A pibox is based on a raspberry Pi computer and consists of several layers :

  • a stream player
  • a stream sender
  • a pifm software to produce a FM signal with GPIO4
  • an audio output to send audio to a classical FM transmitter
  • a sound card with audio input to get a mic or audio mixer signal
  • a wifi card to create a hotspot and allow wifi sonification
  • a piratebox system to allow one to upload files on the box
  • a rtl_sdr usb key to listen to FM
  • a minimodem software to transform files into sound
IMG 20140802 111936.jpg

Install Raspbian on an SD card

Several ways to do it : see http://www.raspberrypi.org/downloads/

In a terminal on linux :

umount /dev/sdb1
sudo dd bs=4M if=2014-06-20-wheezy-raspbian.img of=/dev/sdb

First config steps

  • plug the SD card in the Pi, plug the Pi to a switch with RJ45 cable
  • plug a linux computer on the same switch (that must be connected to internet threw DHCP)
sudo ifconfig

to see which is your local IP adress

 sudo nmap -sP 192.168.50.0/24

adapt the IP above to your IP class

Nmap scan report for 192.168.50.223
Host is up (-0.10s latency).
MAC Address: B8:27:EB:BE:72:1E (Raspberry Pi Foundation)

log-in to the PI with ssh :

ssh pi@192.168.50.223

launch raspi-config to expand filesystem

sudo raspi-config
  • Internationalisation option
  • Set up language and regional settings to match your location : Change Locale to FR-UTF8
  • Change Timezone
  • Change Keyboard Layout
  • Expand_FS (or not)
  • overclock to medium 900 MHz (or not)

reboot

Upgrade the system

sudo apt-get update
sudo apt-get upgrade

additionnal config

#!/bin/bash 
sudo service ntp stop
sudo service triggerhappy stop
sudo service dbus stop
sudo killall console-kit-daemon
sudo killall polkitd
sudo mount -o remount,size=128M /dev/shm
killall gvfsd
killall dbus-daemon
killall dbus-launch
echo -n performance | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

/!\ somes services are necessary for usb devices

PiBox Software

sudo apt-get install sox tcpdump oggfwd nload htop netcat mplayer lsof libav-tools minimodem opus-tools tshark ecasound espeak

For jackd :

PirateBox Layer

Install the software

sudo apt-get -y install lighttpd
sudo /etc/init.d/lighttpd stop
sudo update-rc.d lighttpd remove
sudo apt-get -y install dnsmasq 
sudo /etc/init.d/dnsmasq  stop
sudo update-rc.d dnsmasq remove 
sudo apt-get -y  install hostapd
sudo /etc/init.d/hostapd  stop
sudo update-rc.d hostapd remove 
sudo apt-get -y install iw

After this you can install piratebox:

wget  http://downloads.piratebox.de/piratebox-ws_current.tar.gz
tar xzf piratebox-ws_current.tar.gz
cd piratebox
sudo mkdir -p  /opt
sudo cp -rv  piratebox /opt
cd /opt/piratebox

activate the link to piratebox in init.d

sudo ln -s /opt/piratebox/init.d/piratebox /etc/init.d/piratebox  

After this you have can enable it with

sudo /etc/init.d/piratebox start  

PirateBox post config

change user in server

sudo nano /opt/piratebox/conf/lighttpd/lighttpd.conf
server.username             = "pi"
server.groupname            = "pi"
sudo nano /opt/piratebox/conf/piratebox.conf
# Check if interface exists
#  should be set to yes if you use a USB wifi card
PROBE_INTERFACE="yes"

change essid

sudo nano /opt/piratebox/conf/hostapd.conf
ssid=∏-node
#------------------------ Additional configuration for lighttpd 
LIGHTTPD_USER=pi
LIGHTTPD_GROUP=pi


sudo chmod 777 /opt/piratebox/tmp/
sudo chmod 777 /opt/piratebox/share/Shared

change the default upload directory :

sudo rm -rf /opt/piratebox/share/Shared/
sudo ln -s /home/pi/sound/ /opt/piratebox/share/Shared

rtl_sdr layer

install fm player with rtl_sdr

sudo apt-get install cmake
sudo apt-get install libusb-1.0-0-dev
git clone https://github.com/keenerd/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../
make
sudo make install
sudo ldconfig
cmake ../ -DINSTALL_UDEV_RULES=ON
sudo cp ../rtl-sdr.rules /etc/udev/rules.d/rtl-sdr.rules

blacklist the module

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

ajouter

blacklist dvb_usb_rtl28xxu
blacklist rtl_2832
blacklist rtl_2830

Reboot !

Additionnal config

sudo apt-get remove --purge pulseaudio

Test rtl_fm

Test :

rtl_fm -f 108e6 -M fm -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 -

Tentative feedback

rtl_fm -f 100e6 -M fm -s 352k -A fast -r 44.1k -l 0 -E deemp - | avconv -i - -ac 1 -ar 22050 -b 352k -f wav - | sudo ./pifm - 100.0

Dirty Feedback

rtl_fm -f 100e6 -M fm -s 352k -A fast -r 44.1k -l 0 -E deemp - | sudo ./pifm - 100 44100

Minimodem

Install last version of minimodem

install minimodem 0.19 on RPI

wget http://www.whence.com/minimodem/minimodem-0.19.tar.gz
tar -xzvf minimodem-0.19.tar.gz
sudo apt-get update
sudo apt-get install libfftw3-dev libasound2-dev libsndfile1-dev libpulse-dev
cd minimodem-0.19/
./configure
make
sudo make install

Use minimodem

To transmit :

$ ./minimodem2fm_emt.sh PATH_OF_FILE_TO_SEND FM_FREQUENCY

minimodem2fm_emt.sh

#!/bin/bash
 
##########################################################################
# minimodem2fm_emt.sh pass any type of document to binary and then to fm #
##########################################################################
# usage: ./minimodem2fm_emt.sh PATH_TO_FILE FM_FREQUENCY      `          #
##########################################################################
echo $(basename "$1") | minimodem -q -8 -R 22050 --tx 100 -f "/tmp/audioname_minimodem.wav"
# aplay -c 1 -r 22050 -q "/tmp/audioname_minimodem.wav" | pifm - $2 22050
pifm "/tmp/audioname_minimodem.wav" $2 22058
sleep 1
cat "$1" | minimodem -q -8 -R 8000 --tx 200 -f "/tmp/audio_minimodem.wav"
# aplay -c 1 -r 8000 -q "/tmp/audio_minimodem.wav" | pifm - $2 22050
pifm "/tmp/audio_minimodem.wav" $2 8000
exit 0

To receive : you have to launch the receiver first

$ ./minimodem2fm_rcv.sh

minimodem2fm_rcv.sh

#!/bin/bash
 
######################################################################
# minimodem2fm_rcv.sh receive sound for textfile_name and data       #
######################################################################
 
minimodem --rx 100 -q -8 -R 22050 --rx-one > /tmp/name_textfile.txt
name="$(cat /tmp/name_textfile.txt)"
minimodem --rx 200 -q -8 -R 8000 --rx-one > "$name"

Test carte son

Test entrée audio carte son externe > sortie carte son interne : la carte son utilisée : http://www.ebay.fr/itm/HAMA-CARTE-SON-USB-7-1-SURROUND-/141158874429?pt=FR_GH_Informatique_Composants_Cartes_Son&hash=item20ddb97d3d

arecord -f S16_LE -D plughw:1,0 -r 44100 - | aplay -D plughw:0,0 -

donne à entendre l'entrée micro de la carte son sur la sortie de base de la Pi, il s'avère que l'entrée de cette carte son est mono !

Test speech reco

s'inscrire sur la liste de dév de chromium puis https://console.developers.google.com/project/

AIzaSyCGWZIJUyMdw8ci0kqcK2pH_aanM9kGnqY
#!/bin/bash
arecord -D "plughw:1,0" -q -f cd -t wav | ffmpeg -y -i - -ar 16000 -acodec flac file.flac
wget -q -U "Mozilla/5.0" --post-file file.flac --header "Content-Type: audio/x-flac; rate=44100" -O - "http://www.google.com/speech-api/v2/recognize?lang=en-us&client=chromium&key=AIzaSyCGWZIJUyMdw8ci0kqcK2pH_aanM9kGnqY" | cut -d\" -f12 >stt.txt
rm file.flac

Wifi sonification

Installation airmon-ng

svn co http://svn.aircrack-ng.org/trunk aircrack-ng
cd aircrack-ng/scripts/
chmod +x airmon-ng
sudo cp airmon-ng /usr/sbin/

test :

sudo airmon-ng start wlan0
Found 6 processes that could cause trouble.
If airodump-ng, aireplay-ng or airtun-ng stops working after a short period of time, you may want to kill (some of) them!
PID	Name
1736	ifplugd
1743	ifplugd
1777	ifplugd
1806	wpa_supplicant
1937	wpa_cli
1977	dhclient
Process with PID 1743 (ifplugd) is running on interface wlan0
Process with PID 1806 (wpa_supplicant) is running on interface wlan0
Process with PID 1937 (wpa_cli) is running on interface wlan0
Interface	Chipset		Driver
wlan0		Atheros AR9271	ath9k - [phy0]

(monitor mode enabled on mon0)

tcpdump sonification

sudo tcpdump -xx -vvv -s 0 -i mon0 | aplay -D plughw:0,0 -i - -t raw --buffer-size=64
sudo tcpdump -A -vvv -s 1500 -i mon0 | aplay -i - -t raw --buffer-size=1048

buffer underrun

Webcast

then you have to connect to the pibox threw the piratebox layer : wifi essid ∏-node and then http://piratebox.lan/webcast/

IMG 20140802 111949.jpg