V-2 - definitive step by step installation guide

From ∏ node
Jump to: navigation, search

PiBox V-2

What is the PiBox ?

The PiBox is a modular system of radio/streaming broadcast, composed of multiplers inputs and outputs. The box aims to provide a multi-functional and easy-to-use micro-fm streaming station. The PiBox has been developed within the collective ∏-node.org. The system is open source, and based on open source software / open hardware.

Diagram

DiagramA-PiBox.png

Usage

A PiBox allow different possibilities and configurations :

  • Broadcast on the FM band from various inputs (streams, files, live inputs)
  • Stream on internet from various sources (streams, files, live inputs), with the help of a icecast server
  • Multiply the combinations of the above possibilities
  • Send text messages on the RDS system
  • Record the input and store the recording on the sd drive, as a file in opus format

What the PiBox do not do

  • Broadcast on other radio frequencies than the FM band
  • Stream when not have access to internet !
  • Stream without icecast support !

& many other things ! check the section 3/ Usage to know the exact features of the PiBox

Hardware prerequisites

REQUIRED HARDWARE

  • raspberry pi 3B (it works with Raspberry Pi <3 - with raspbian 8.0 jessie)

https://www.kubii.fr/raspberry-pi-3-2-et-b/1628-raspberry-pi-3-modele-b-1-gb-kubii-640522710850.html

  • micro SD card (SDHC class10)

https://www.kubii.fr/carte-sd-et-stockage/1795-carte-microsd-64go-classe-10-sandisk-kubii-619659161507.html?search_query=sd&results=112

  • power plug 5v 2.1A, (don't use USB phone chargers, as 1A is not powerfull enough)

https://www.kubii.fr/14-chargeurs-alimentations-raspberry/1631-alimentation-raspberry-pi-5v-25a-pour-raspberry-pi-3-couleur-noir-kubii-640522711000.html


RECOMMENDED HARDWARE

  • USB sound card (built-in output sound is crapy and there is no input sound by default on Raspberry Pi)

https://www.kubii.fr/convertisseurs-adaptateurs-raspberry/2055-carte-son-externe-usb-vers-35mm-jack-adaptateur-audio-kubii-3272496009158.html?search_query=carte+son+usb&results=16

  • WiFi USB dongle (2 WiFi USB dongles if you have a version of Raspberry Pi < 3) to connect to internet without ethernet cable

https://www.kubii.fr/claviers-et-peripheriques-usb/64-module-wi-fi-usb-wi-pi-pour-raspberry-pi-kubii-3170111000385.html

  • Radio antenna to expand the FM broadcast


OPTIONAL HARDWARE

  • battery for mobile streams, or solar panels

https://www.kubii.fr/14-chargeurs-alimentations-raspberry/1670-power-bank-li-polymer-15-000-mah-555-wh-kubii-3272496005013.html

  • sound recorder (type zoom H4) or microphones, to broadcast soundscapes


REQUITED FOR THE INSTALLATION PHASE

  • monitor + HDMI + keyboard
  • a computer
  • internet

STEP BY STEP INSTALLATION

PRELIMINARIES

Download Raspbian image

If you have a raspberry pi 3B then download Raspbian stretch lite : https://downloads.raspberrypi.org/raspbian_lite_latest

For older models raspberry pi 2B or lower, prefer jesse : http://downloads.raspberrypi.org/raspbian/images/raspbian-2017-07-05/


Writing Raspian image to an SD card

Install image disc (.img) by following carefully https://www.raspberrypi.org/documentation/installation/installing-images/README.md

You will need to use an image writing tool to burn the image you have downloaded on your SD card.


burn on Linux / Windows / Mac

Use etcher : Etcher is a graphical SD card writing tool that works on Mac OS, Linux and Windows, and is the easiest option for most users. Etcher also supports writing images directly from the zip file, without any unzipping required. To write your image with Etcher:

  • Download Etcher and install it.
  • Connect an SD card reader with the SD card inside.
  • Open Etcher and select from your hard drive the Raspberry Pi .img or .zip file you wish to write to the SD card.
  • Select the SD card you wish to write your image to
  • Review your selections and click 'Flash!' to begin writing data to the SD card.


an other way to burn on Linux / Mac

following https://www.raspberrypi.org/documentation/installation/installing-images/linux.md

get the name of the partition of the sd card

   $ df -h

eject the sd card and redo the command

   $ df -h

For example: sdd, sdb, mmcblk0

then we're ready to use dd. Be careful to indicate the exact address of the SD card, or you will lose all the data on the hard drive if you provide the wrong device name. Make sure the device name is the name of the whole SD card not just a partition.

export the image to the SD card with a terminal

   $ sudo dd if=2018-04-18-raspbian-stretch.img of=/dev/sdb status=progress bs=1M

(mac users, use a small m for the bs instruction bs=1m or bs=4m)

when done

   $ sudo sync

then eject the SD card and plug it into a raspberry pi, with a keyboard and hdmi monitor

Configuration of Raspbian

Connect a monitor and a keyboard to the Raspberry Pi. Connect the Raspberry Pi to internet with an ethernet cable.

Switch on the raspberry pi

Default login and password : pi / raspberry

enter the command

   $ sudo raspi-config

go to 1. Change User Password

=> remember your password !

go to 5. interfacing and enable ssh

=> by selecting "Yes"

you can also change the timezone and the language settings if necessary

=> then exit by selecting "Finish"

INSTALLATION AND CONFIGURATION

Once Raspbian Lite (Jessie or Stretch) is installed and configured.

   $ sudo apt-get update
   $ sudo apt-get upgrade

download git, sox et libav-tools oggfwd

   $ sudo apt-get install git sox libav-tools oggfwd python3-pip

install pip3 w/ beautifullsoup 4

   $ sudo pip3 install bs4

download sources with git

   $ cd
   $ git clone http://git.rybn.org/rybn/pibox_V2.git

extra libraries to install to control the pibox through wifi : hostapd & dnsmasq

   $ sudo apt-get install hostapd dnsmasq

stop services hostapd and dnsmasq

   $ sudo systemctl stop dnsmasq
   $ sudo systemctl stop hostapd

then create the file /etc/hostapd/hostapd.conf

   $ sudo nano /etc/hostapd/hostapd.conf

add the following in the file (you can customize the ssid with youn own value, for example change "myssid" with "myPibox")

   interface=wlan0
   driver=nl80211
   ssid=myssid
   hw_mode=g
   channel=7
   wmm_enabled=0
   macaddr_acl=0
   auth_algs=1
   ignore_broadcast_ssid=0

configure the file /etc/default/hostapd

   $ sudo nano /etc/default/hostapd

then modify the following line

   #DAEMON_CONF=""

for

   DAEMON_CONF="/etc/hostapd/hostapd.conf"

then, configure the file /etc/dnsmasq.conf

   $ sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf_back
   $ echo "" | sudo tee /etc/dnsmasq.conf
   $ sudo nano /etc/dnsmasq.conf

put

   interface=wlan0      
   # Use the require wireless interface - usually wlan0
   dhcp-range=192.168.100.2,192.168.100.10,255.255.255.0,24h

then change wlan0 parameters in : /etc/dhcpcd.conf

   $ sudo nano /etc/dhcpcd.conf

add to the end of the file

 interface wlan0
 static ip_address=192.168.100.1/24
 nohook wpa_supplicant

continue with

   $ sudo systemctl restart dhcpcd
   $ sudo systemctl start hostapd
   $ sudo systemctl start dnsmasq

open the rc.local

   $ sudo nano /etc/rc.local

and add just before the line "exit 0" :

  /usr/bin/python3 /home/pi/pibox_V2/go.py 2> /home/pi/pibox_V2/error_log.txt >/dev/null &

you should get :

   #!/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
   
   /usr/bin/python3 /home/pi/pibox_V2/go.py 2> /home/pi/pibox_V2/error_log.txt >/dev/null &
   
   exit 0

HIGHLY RECOMMENDED : ADD A USB WIFI KEY TO GET INTERNET ACCESS (WITH OR WITHOUT WIRED ACCESS)

To be sure your wifi dongle will work as expected whatever the brand and the driver used (some wifi dongle won't let builtin wifi named wlan0 with the latest Raspbian Stretch like the TP-LINK TL-WN725N that use the driver r8188eu), to avoid any problem do this :

create rules

   $ sudo nano /etc/udev/rules.d/70-persistent-net.rules

type

   ACTION=="add", SUBSYSTEM=="net", DRIVERS=="r8188eu", NAME="wlan1"

save and shutdown the Raspberry Pi

   $ sudo halt

ASSEMBLAGE

hardware assemblage

Now before to restart, put all elements together.

Plug the additional USB WiFi dongle and the USB sound card. And plug the antenna.


Dipole antenna building

To make the dipole : ∏-Box antenna http://p-node.org/doc/index.php/%E2%88%8F-Box_antenna

Connect the dipole antenna to the pin 4 (modulation) and 5 (ground)


Power

Now, just plug the power, or the battery, to run the PiBox.


Optional and experimental

∏-Case

DIY_power_DIY_Solar_Power

ADMINISTRATION

TO BROADCAST IN FM, PUT AN ANTENNA

On the GPIO 4 as described on the image below : the forth on the left starting from the top Rasppische-fm-transmitter.jpg

PLUG THE EXTERNAL SOUNDCARD

To be able to broadcast an external sound source, plug the external sound card in a USB port and plug a minijack into the input (Mic symbol) of the external soundcard

CONNECT TO THE ADMINISTRATION INTERFACE

Check the WiFi around and connect to the WiFi called "pibox" (or myssid depending on how you set it up)

then, open a browser and open the address 192.168.100.1

the page will ask you to enter a login and a password : it should be by default : pibox / pnodeaccesspass

then, you're in to change the settings ! here what looks like the interface

Interface pibox.png


INTERFACE

The upper side of the interface shows the ip adress of the device, and which device provides internet (if connected).

The lower side is divided in two modes : Online mode (with internet access) or Offline mode (without internet access).


UPPER PART

WIFI CONNECTION FIELD : you can enter a SSID and a password to connect to your favorite WiFi network. Ideal for connecting outside on a telephone that shares its connection.

In case the info is wrong, the PiBox will search to create a connection on Ethernet (eth0), and in the case none of those options works, will enter the offline mode

UPLOAD FILE FIELD: allows you to select a file on your hardware and put it on the storage spot of the PiBox.

The files are stored in the following folder : /home/pi/Pibox_V-2/sounds/

Removal or renaming of files can be done either through ssh, by connecting to the pi with a keyboard and a monitor, or by inserting the SD card in your computer, and from your desktop.


ONLINE MODE

INPUTS: choose an input from the following

  • input from FILES, stored on the SD card, with a 'play in random order' option
  • input from STREAM: can be your favorite webradio, a stream from another PiBox, etc ...
  • input from LINE IN: connect any sound device on the sound card : record player, tape player, mp3 player, computer, etc...


OUTPUTS: select the output of your transmissions

All outputs can be associated simultaneously, and freely !

  • LINE OUT: plug a mini-jack to the sound card, to connect the PiBox to a speaker,
  • STREAM: enter the icecast server address to stream
    • server address : p-node one is : http://stream.p-node.org/
    • user : can be PIBOXnn (choose a number)
    • password : can be 107MHz** replace the 2 stars by the name of the band on which you are broadcasting in capital (don't think too much, it's very simple, or see below :)
    • mountpoint : can be piboxnn.ogg
    • port : p-node one is 80
    • bitrate : 128 for example
    • metadata name, genre, ...
  • FM: tune the frequency to broadcast on the FM band, from 88 MHz to 108MHz (actually pifmrds allows to broadcast from 76MHz, but you will need a rtl-sdr to listen, or adequate equipment).


OFFLINE MODE

The PiBox in offline mode is fully functional, except for the sources that comes from internet and necessitate a connection, same for the broadcast.

INPUTS: choose an input from the following

  • input from FILES, stored on the sd card, with a 'play in random order' option.
  • input from LINE IN: connect any sound device on the sound card : record player, tape player, mp3 player, computer, etc...


OUTPUTS: choose a output mode, all outputs can be associated freely

  • LINE OUT: plug a mini-jack to the sound card, to connect the PiBox to a speaker,
  • FM: tune the frequency to broadcast on the FM band, from 88MHz to 108MHz


OPTIONS

Change SSID name

edit the file /etc/hostapd/hostapd.conf

   $ sudo nano /etc/hostapd/hostapd.conf

change the SSID by entering youn own value

     interface=wlan0
     driver=nl80211
     ssid=myssid
     hw_mode=g
     channel=7
     wmm_enabled=0
     macaddr_acl=0
     auth_algs=1
     ignore_broadcast_ssid=0

then

   $ sudo reboot

Change ssh password

by entering the following

   $ sudo raspi-config

then

   $ sudo reboot

UPDATE YOUR PIBOX

To update / upgrade the PiBox to the latest version, connect in ssh and git pull the last version from the repository.

$ cd pibox_V2/
$ sudo git pull

if you get an error, because of the file configuration.conf, do :

$ rm -rf configuration.conf

WISH LIST OF FUTURE OPTIONS

  • playlist/file manager
  • pirate box mode = captive portal when connected to pibox wifi, with access to file deposit
  • rtl-sdr input ! frequency, squelch, filter, ...
  • minimodem mode in input and output
  • mesh network ! with file propagation within the network
  • to test pifm 1MHz 250MHz

KNOWN BUGS

  • reboot: daily reboot seems blocked sometimes by pifm
  • automatic switch to files when ping to google fail: there is a 5 seconds timeout to check if internet is ok, opening google.com web page, but on my pibox (b01), it keeps switching whereas internet is ok, I tried to put a 30 s timeout but it doesn't seem to have solve the pb