Skip to content
This repository was archived by the owner on Dec 13, 2021. It is now read-only.

Raspberry Pi installation

Arnold Andreasson edited this page May 28, 2016 · 4 revisions

CloudedBats on Raspberry Pi - installation

Some notes on this installation guide:

  • This installation guide describes how to install the CloudedBats software on the minimal version of Raspbian called "Raspbian Jessie Lite". Basic knowledge of how Linux is handled via a terminal window is a prerequisite.

  • If you already have a running Raspberry Pi, just skip to the sections "Python, install modules", "Download and install CloudedBats" and "Start the CloudedBats web server".

  • This installation guide is for development and test in a local network only. To deploy a Django web server in a secure and reliable way please follow the instructions here: https://docs.djangoproject.com/en/1.9/howto/deployment/

  • Tested on Raspberry Pi 2 B and Raspberry Pi 3 B, but may work on other version.

  • If multiple units should be used it is possible to install everything on one Raspberry Pi first and then make clones of the SD cards. It is also recommended to have backup SD cards since the card can be corrupt in case of power failure during a write access.

  • This is my first Raspberry Pi project. Please contact me at info@cloudedbats.org if you know better ways to do the installation.

Raspbian

Download RASPBIAN JESSIE LITE from: https://www.raspberrypi.org/downloads/raspbian/

Install the operating system image on a Micro SD card. Follow the instructions here: https://www.raspberrypi.org/documentation/installation/installing-images/README.md

Insert the Micro SD card into the Raspberry Pi.

Startup and login

Alternative 1: Connect the Raspberry Pi via HDMI to a monitor or TV. Connect keyboard and mouse via USB. Power up the Raspberry Pi. Wait until started and log in. User: pi, Password: raspberry.

Alternative 2: This alternative works if you have a computer with support for Bonjour in your local network. Connect the Raspberry Pi to the local network via the Ethernet port. Power up the Raspberry Pi. Open a terminal window on some computer in the local network. Log in by typing:

ssh pi@raspberrypi.local
Password: raspberry

Update and upgrade

Always try to keep your Raspberry Pi software up to date:

sudo apt-get update
sudo apt-get upgrade

Raspberry Pi configuration

To configure the Raspberry Pi run the following command:

sudo raspi-config 
  • Run: "Expand Filesystem". This is important since the Raspbian SD Card image is adjusted to fit the smallest SD card size that can contain everything.
  • Run: "Change User Password".
  • Run: "Internationalisations Options". Change timezone. Correct time is important when working with bats.
  • Run: "Advanced Options". Change hostname if there are more than one Raspberry Pi in the network. For example "wurb-1"

If the hostname is changed don't forget to use the new name when accessing the Raspberry Pi via ssh after next reboot, e.g:

ssh pi@wurb-1.local

WiFi

Set up the Raspberry Pi to connect to your wireless networks.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add this at the end of /etc/wpa_supplicant/wpa_supplicant.conf. Select the part that match your type of network and replace the ssid name and password. A high priority number is used to select that network if multiple networks are available.

Important note: Use tab, not spaces, for indentation on each row:

network={
	ssid="my-open-network"
	key_mgmt=NONE
	priority=70
}
network={
	ssid="my-secure-network"
	psk="password"
	priority=80
}
network={
	ssid="my-hidden-network"
	scan_ssid=1
	psk="password"
	priority=90
}

Reboot and check if WiFi is up and running. If it is, then you can remove the Ethernet cable and continue over WiFi.

sudo reboot # Wait and login after reboot.
ifconfig wlan0

USB memory or USB disk

If you want to store files on a USB memory or disk you need to mount that media. The commands below should be done once. Run the first command row without and with the USB memory/disk. In my setup I noticed that it was named "sda1". Use that for mount and unmount commands later.:

ls -l /dev/disk/by-uuid/
sudo mkdir /media/usb
sudo chown -R pi:pi /media/usb/

To mount the USB memory/disk at startup you need to edit this file:

sudo nano /etc/rc.local

Add this before "exit 0":

sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi

Commands to mount/unmount the USB media. If you always shut down the Raspberry Pi before you remove the USB media you don't need those commands if the mount is automatically done at startup.:

sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi
sudo umount /dev/sda1

Python, install modules

Python 2.7 should already be installed on your Raspberry Pi. Install additional python modules:

sudo apt-get install python-numpy python-matplotlib python-scipy
sudo apt-get install subversion # For checkout/update from GitHub.
sudo apt-get install python-setuptools
sudo easy_install pip
sudo pip install django # Django web framework.
sudo pip install pytz # Timezones.

The latest version of PyAudio is not available via apt-get. Install using pip instead.

sudo apt-get install python-all-dev
sudo apt-get install portaudio19-dev
sudo pip install pyaudio

Download and install CloudedBats

Create a new directory for the webserver part of CloudedBats. Download the source code from CloudedBats. I'm using Subversion (SVN) since it is a little bit easier to use if you only want to check out something from a git repository.

Create a new settings.py file from the template version. This means that next time you update the code your settings.py file will not be modified, just the template version. Sometimes there will be important additions in the template version, but I will try to mention that in the release log when it happens.

cd /home/pi
mkdir cloudedbats
mkdir cloudedbats/wurb_webserver
cd cloudedbats/wurb_webserver

svn checkout https://github.com/cloudedbats/cloudedbats/trunk/django_cloudedbats_wurb

cd django_cloudedbats_wurb
cp django_cloudedbats_wurb/TEMPLATE_settings.py django_cloudedbats_wurb/settings.py # Copy the default settings file.
python manage.py migrate # Create the database tables.

Configure CloudedBats

Editing the settings.py file can configure the CloudedBats web server. Replace all places where you find the text string "REPLACE". Also modify other parts like time zone etc.

sudo nano /home/pi/cloudedbats/wurb_webserver/django_cloudedbats_wurb/django_cloudedbats_wurb/settings.py

Update the CloudedBats software

This should be done when you want to download the latest stable version of CloudedBats.

cd /home/pi/cloudedbats/wurb_webserver
svn update django_cloudedbats_wurb

Start the CloudedBats web server

The Django development kit contains a lightweight web server to be used during development and test. Commands to start the web server:

cd /home/pi/cloudedbats/wurb_webserver/django_cloudedbats_wurb/
python manage.py runserver 0.0.0.0:8000

When the web server is running it can be accessed from a web browser. Enter the web address, or use another name if you changed hostname earlier. Use IP number if your computer doesn't support Bonjour. Some possible for web addresses:

 http://raspberrypi.local:8000
 http://wurb-1.local:8000
 http://10.0.1.99:8000

If you want CloudedBats to be started directly when the Raspberry Pi i powered on you need to add some rows to /etc/rc.local.

sudo nano /etc/rc.local

Add this before "exit 0" to let the user 'pi' run the web server:

sudo -u pi python /home/pi/cloudedbats/wurb_webserver/django_cloudedbats_wurb/manage.py runserver 0.0.0.0:8000 &

Start using the WURB

Connect the microphone and the USB memory. Reboot the WURB.

sudo reboot

Most external USB sound card should work. I have tested with Pettersson M500-384, SAMSON Go Mic and iMic from GRIFFIN. The iMic, or similar, can be used to record the heterodyne (HET), frequency division (FD) or time expanded (TE) signal from an ordinary Bat Detector.

Use a web browser in the same network to access the WURB. One of these style of addresses should work depending on support for Bonjour and your settings.

 http://raspberrypi.local:8000
 http://wurb-1.local:8000
 http://10.0.1.99:8000

Go to the Setup page. An example setup is as follows:

  • WURB name : WURB-1
  • Recording type: FS-384: Full spectrum, 384 kHz.
  • Sound source: Pettersson M500-384kHz USB Ultr: Audio (hw:1,0)
  • ADC resolution: 16 bits
  • Channels: Mono
  • Each record length: 10 min
  • Total record length: 15 h
  • Directory for files: /media/usb/wurb-1
  • Latitude (DD): 59.327
  • Longitude (DD): 18.072

Go to the Control page. Now you can control your WURB.

This release only contains basic recording functionality. More features will come in future releases. Please check the timeline document (TBD).

Some useful commands on Raspberry Pi

Some useful commands to be used when accessing the WURB via ssh and a terminal window:

sudo shutdown  # After 1 minute
sudo shutdown -h now # Immediate. 
sudo halt # Also immediate.
sudo reboot

df #Check disk space.
df -h # -h is for humans.

cd /media/usb/wurb-1
ls -l

sudo apt-get update
sudo apt-get upgrade

hostname -I 
ifconfig
ifconfig wlan0