cloudedbats / cloudedbats_wurb_2020

CloudedBats-WURB. The DIY bat detector.
MIT License
21 stars 3 forks source link
asyncio bats chiroptera cloudedbats detector diy openapi3 raspberry-pi

CloudedBats - WURB 2020

Welcome to CloudedBats-WURB, the DIY bat detector.

Note: This is a new version of the WURB bat detector. The old version can still be found here: https://github.com/cloudedbats/cloudedbats_wurb

WURB-2020 CloudedBats - WURB 2020. CloudedBats.org / CC-BY

Introduction

This is what you need to build your own bat detector; an ultrasonic USB microphone, a Raspberry Pi computer with SD card, power supply and this CloudedBats-WURB 2020 open source software. Optional parts that are recommended are USB memory sticks, an USB GPS receiver and a Power bank for single night sessions. For the v0.9.0 release you will also need headphones with a 3.5 mm jack for audio feedback.

Functional features, from the earlier CloudedBats-WURB:

Added features in CloudedBats-WURB 2020:

Release v0.8:

Release v0.9:

Other characteristics

Drawbacks

User manuals:

Software notes, for developers:

This is valid for the CloudedBats-WURB 2020 version.

Hardware

Any Raspberry Pi model with WiFi. (RPi Zero W works if auto detection and audio feedback is turned off). Raspberry Pi 4 is recommended if you want high speed transfer of recorded files over internet.

Most SD cards seems to work but faster ones are recommended. Personally I mostly use U3 (UHS Speed Class U3), for example Toshiba Exceria Pro.

Note: For some strange reason both M500 and M500-384 have problems if connected directly to a Raspberry Pi 4 at startup (RPi3B+ works fine). Workarounds are to use an extra USB 2.0 Hub (passive is ok), or attach the M500 or M500-384 microphone after startup.

Installation

Note: This installation guide is updated to match the Ansible installation guide that is used for more automated installations. If you are familiar with Ansible, then please have a look here: https://github.com/cloudedbats/ansible-playbooks

Main workflow, overview

The main steps during the installation are:

Install the Raspberry Pi OS

Use the Raspberry Pi Imager to install the Raspberry Pi operating system.

Then make these setting, to be used as an example. It will also work with an Ethernet cable connected to the Raspberry Pi, and then the WiFi (wireless LAN) part can be omitted.

Note that the username must be pi in this version of the WURB bat detector.

Finally write to the SD card. When finished remove the SD card.

If you have many detectors, then be sure that you use different hostnames. Otherwise there will be problems when they are connected to the same network if more than one is identified as, for example, "wurb99.local".

Start the Raspberry Pi

Insert the SD card into the Raspberry Pi and power it up.

The Raspberry Pi should now be connected to your local network, either via WiFi or an Ethernet cable depending on your configuration above.

Start a terminal window and connect with SSH. For Windows users Putty is a well known alternative.

ssh pi@wurb99.local

It is also possible to attach a screen and keyboard/mouse directly to the Raspberry Pi instead of using ssh. No graphical user interface will be available, only command line mode.

Basic configurations

Update the Raspberry Pi software.

sudo apt update
sudo apt upgrade

Make some configurations. Most of them are already made when running Raspberry Pi Imager above, but the last two must be done here. Later modification can be done whenever you want by running raspi-config.

sudo raspi-config

Check or change this (example for Swedish users):

Mandatory:

A reboot is needed to expand the file system.

sudo reboot

Hint: WiFi networks can be changed via raspi-config. Another alternative is to edit the wpa_supplicant.conf file and change SSID and password for the network. Even a list of networks can be added in this file if the detector is used at different places.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Install Linux packages

Install needed software packages.

sudo apt install git python3-venv python3-dev libatlas-base-dev udevil

To make it work with the "Bookworm" release of the Raspberry Pi OS these installations must be done. Note that "numpy" and "scipy" now is removed from the "requirements.txt" file used by "pip install". The command for creating virtual environments for python is also modified to accept numpy and scipy when they are not created inside the virtual environment. The package "pyalsaaudio" is not available in the 64 bits version, and we have to stay with the 32 bits version of the operating system.

sudo apt install pulseaudio python3-numpy python3-scipy

Pettersson M500 (500kHz)

The Pettersson M500 microphone (the 500kHz version) differ in communication format compared to M500-384, u256, and u384. Some udev rules must be setup to allow the detector to communicate with it.

# Create a file with udev rules:
sudo nano /etc/udev/rules.d/pettersson_m500_batmic.rules

# Add this row in the new file. 
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="pi"

Install the CloudedBats WURB-2020 software

Clone the software from the GitHub repository and install Python related packages.

git clone https://github.com/cloudedbats/cloudedbats_wurb_2020.git
cd cloudedbats_wurb_2020/
python -m venv --system-site-packages venv
source venv/bin/activate
pip install -r requirements.txt 

Note: When installing packages most of them are pre-prepared in something called "wheels". The main source for wheels for Raspberry Pi can be found here, with an example for SciPy: https://piwheels.org/project/scipy/ If that build has failed, then it is possible to use an older version. The installation process may find a working version automatically with a lot of warnings during the installation process. Then it is possible to edit the requirements.txt file to speed up the installation process. In the SciPy case the row can be changed from "scipy" to "scipy<1.9.0" if there are problems with version 1.9.0.

Run the detector software as a service

Install the service and enable it. Enable means that the service will start automatically when the Raspberry Pi is started.

sudo cp wurb_2020.service /etc/systemd/system/wurb_2020.service
sudo systemctl daemon-reload
sudo systemctl enable wurb_2020.service
sudo systemctl start wurb_2020.service

Adjust sound level

Set the headphone volume used for audio feedback.

amixer set 'PCM' 100%
# Other useful commands if there are problems:
aplay -L
amixer scontrols
alsamixer -c0

And finally, restart the detector

sudo reboot

RaspAP, optional installation

If you want to use the detector away from computer networks, then the RaspAP software can help. Read more here: https://raspap.com

Note that the built-in WiFi module will be used by RaspAP to provide a WiFi access point. That means that the previously used WiFi connection to the local wireless network will not work when RaspAP is installed. When internet access is needed you have to connect an Ethernet cable. Another option is to use a 4G/LTE modem, like the HUAWEI E3372, and then the detector also can be used as a WiFi access point for internet access.

Download and install RaspAp.

curl -sL https://install.raspap.com | bash

# It is ok to select "Y" on all steps during the installation.
# OpenVPN and Wireguard are not used, you can press "N" for them.

Restart the detector.

sudo reboot

Connect to the wifi network named raspi-webgui. Password: ChangeMe.

Start a web browser and go to: http://10.3.141.1.

If the detector is using an Ethernet cable the web address "http://wurb99.local/" will work from any computer in the network (if the hostname is wurb99).

Login for the administration page: Username: admin, password: secret.

Change the defaults settings from:

Change to (example for Swedish users):

Run the detector

There are different ways to turn the Raspberry Pi detector off (power off only is not recommended since there is a small risk of corrupted SD card or USB memory sticks):

More than one USB memory stick can be used. They will be filled up with wave files in alphabetic order. When the last USB memory stick is full, then it will continue on the SD card. It will stop when there is less than 0.5 GB left on the SD card.

If files are stored on the SD card then they can be downloaded and/or removed by using for example FileZilla. Connect with SFTP to http://10.3.141.1 with user "pi" and password "chiroptera". Path to files on the SD card: "/home/pi/wurb_recordings".

It is also possible to download files by using FileZilla, or similar, from the USB memory stick during an ongoing recording session. The path to the USB memory is then "/media/pi/".

Note: Some mobile phones complains if the "wifi4bats" network not is connected to internet. If that happens, then tell it to forget the network, connect to i again and answer the question if you want to connect to it anyway.

The MIT license

This software is released under the MIT license that means that you are free to use it as you want; use it, share it, cut it into pieces, extend it, or even sell it for money. But you are not allowed to remove the MIT license clause (just change my name to yours in the copyright row for modified code files), and it comes "as-is" with no warranties at all.

Contact

Arnold Andreasson, Sweden.

info@cloudedbats.org