Introduction: Part 1. ThinkBioT Autonomous Bio-acoustic Sensor Hardware Build
ThinkBioT aims to provide a software and hardware framework, designed as a technological backbone to support further research, by handling the minutiae of data collection, pre-processing, data transmission and visualization tasks enabling researchers to focus on their respective Classification and Bioacoustic metric collection undertakings.
This prototype is still in development and as such I would recommend waiting until all the tutorials in the ThinkBioT series are completed. :) For up to date news keep an eye on the ThinkBioT Github at https://github.com/mefitzgerald/ThinkBioT
Step 1: Collect Components
Collect the components listed in the Bill Of Materials file (attached). The core electronic components are listed with their respective brands names and are not interchangeable, the remainder including the case can be substituted for the generic equivalents.
Step 2: Collect Required Tools
To make this prototype please ensure you have at least the following tools;
- Power Drill with 24mm holesaw, and large plastic suitable bit set
- #1 Phillips head screwdriver
- Side cutters (or sharp scissors)
- Small Pliers (needle nose or standard)
- Safety Glasses
Please note: Pliers are optional and are only required for users who find the small components difficult to handle
Step 3: Prepare Enclosure
Wearing safety goggles, drill holes for the connectors in the enclosure.
You will need 3 holes
- USB waterproof panel mount connector - use hole saw or stepper drill bit.
- Microphone enclosure - use large drill bit
- SMA pass through connector (M-M)
If you are using the Evolution 3525 case we recommend drilling into the flat panel on the opposite side of the enclosure. However it really depends on how you intend to mount the unit, just ensure connectors are underneath the unit to protect from direct rain.
Once drilled you can insert the microphone into the mount and connect the SMA patch cable and USB patch cable(supplied with Voltaic V44).
Step 4: Install Stretch on the Raspberry Pi 3
Before being mounted in the prototype the Raspberry Pi 3 must be configured and have an operating system installed. In Raspberry Pi single board computers the operating system is stored on a removable SD card.
I used a Samsung Micro SD EVO+ 128GB.
To install Stretch onto your SD card;
- Download Raspbian Stretch from Raspbian Stretch. Please note: ThinkBioT is using Stretch as the Coral Edgetpu models are currently only tested up to version 1.13.0 of TensorFlow,which was not tested on Debian Buster.
- Ensure your SD card is formatted as Fat32 as per this guide.
Optionally, connect your raspberry HMDI port to a screen at this point.
Insert your SD card in the slot on the raspberry Pi and connect it to power. Initially we would recommend using an official Raspberry PSU to ensure no under power warnings occur during software installation..
Please note: I have selected the full version of Stretch) as opposed to the 'Lite' version as the initial wireless connection is easier to setup with a graphical interface. The additional features are disabled by ThinkBiot scripts when the device is in field mode so the GUI will not require a greater power overhead in the field.
Step 5: Connect to Your Local WIFI Network Via SSH
To set-up the prototype you will need to be able to connect to the Raspberry Pi to exchange commands and view set-up data. Initially you may find it easier to use the graphical desktop interface until you get your SSH connected. We would recommend that after initial set-up you connect via a SSH terminal directly to the command line, as outlined at the end of the tutorial.
- Follow the tutorial here to connect to our Raspberry Pi
- It is also recommended to install Winscp if you are a wndows user, as it is very
Notes: Depending on the reliability of your Wifi we have found it necessary to connect through our mobile phones hotspots. Setting this up also will enable you to communicate with your unit in the field where no external WiFi is present. But care must be taken that you do not exceed your data limits!
Step 6: Install Witty Pi 2
The witty Pi board is used to keep system time when your Raspberry Pi is powered doen and to turn it On and Off during the ThinkBioT operation cycle.
- Firstly open a terminal via your SSH connection or locally vis the Desktop option, for information on how to open and used the terminal session please click here.
- Follow the set up in the witty Pi documentation.
- Note: when asked "Remove fake-hwclock package and disable ntpd daemon? (recommended) [y/n] " reply y. When asked "Do you want to install Qt 5 for GUI running? [y/n] " reply n
- Once firmware is installed remove the Raspberry Pi from the power source and mount the board on the Raspberry Pi without using the screws yet.
- Plug the Raspberry Pi backinto power and using the instructions in the Wittty Pi documentation sync the time and shutdown the Raspberry Pi. To shutdown and start you can simply press the witty Pi button from now.
Step 7: Mount System Components in Internal Support Case
I used an inexpensive acrylic Raspberry Pi case to mount our core system components, you are welcome to change the order and mounting style. I used 2.5M mounting posts between each layer to allow for airflow and used the internal holes to mount the components.
- Mounting the raspberry Pi (and attached Witty Pi): Using the screws & mounts that are supplied with the Witty Pi affix it to one of the base plates
- Mounting the Google Coral: Using the 2 x adhesive cable tie mounts affix the Coral to the base plate via cable ties as per the images above
- Mounting the RockBlock: Carefully use one mounting post in the circuit board mounting hole and a hole in the base plate, then add a adhesive cable tie mount beneath the unit and a cable tie to stop the unit moving around. DO NOT over tighten the cable tie as you may damage the Rockblock. Ensure you choose a mount post of a similar height to the Rockblock resting on the cable tie mount.
- We recommend plugging in the RockBlock cable at this point as it can be awkward once the unit is put together.
- Trim any excess cable tie length carefully with your side cutters whilst wearing your safety glasses.
- Connect the individual case layers together with mounting posts, you may require pliers at this point depending on the size of your hands.
- Apply adhesive hook to the base level of the now complete component case.
- Do NOT plug in the RockBlock and the Google Coral at this point.
Step 8: Install TensorFlow Lite
1. Open a new terminal window, either on the Raspberry Pi Desktop or via SSH connection and enter the following commands line by line to ensure your Stretch installation is up to date. The first line collects the updates, the second line installs the updates and the third reboots the raspberry Pi to restart fresh with the new files.
sudo apt-get update<br>sudo apt-get upgrade sudo reboot
2. Now to install TensorFlow Lite 1.13.0 enter the following commands line by line. What is happening in this code snippet is that the requirements for TensorFlow Lite are installed, then any previous versions are uninstalled if they exist (to avoid conflicts) and a pre-compiled binary of TensorFlow Lite is downloaded from my repository and installed.
PLEASE NOTE: As some of these are quite large files it can take some time to install and requires a stable internet connection and good power supply. I found that my Australian broadband connection caused the process to throw errors so had to use a 4G connection via my mobile hotspot which worked perfectly.
sudo apt-get install -y libhdf5-dev libc-ares-dev libeigen3-dev<br>sudo pip3 install keras_applications==1.0.7 --no-deps sudo pip3 install keras_preprocessing==1.0.9 --no-deps sudo pip3 install h5py==2.9.0 sudo apt-get install -y openmpi-bin libopenmpi-dev sudo apt-get install -y libatlas-base-dev pip3 install -U --user six wheel mock sudo pip3 uninstall tensorflow wget <a href="https://github.com/mefitzgerald/Tensorflow-bin/raw/master/tensorflow-1.13.1-cp35-cp35m-linux_armv7l.whl" rel="nofollow">https://github.com/mefitzgerald/Tensorflow-bin/raw/master/tensorflow-1.13.1-cp35-cp35m-linux_armv7l.whl</a> sudo pip3 install tensorflow-1.13.1-cp35-cp35m-linux_armv7l.whl
3. Test your installation with the following script below, simply type python3 (in the terminal) to begin a python prompt (indicated by the >>>). Then you import TensorFlow (so you can use its methods) and use the version method whereby it return the version number if your installation was successful, you then use exit() to close the python prompt.
python3 >>> import tensorflow >>> tensorflow.__version__ 1.13.0 >>> exit()
Step 9: Install the Google Coral Edge TPU
The Google coral will be used for inferencing during the classification tasks and need to be set up with its own firmware. Akin to the Tensorflow setup this requires stable download environment so replicate your network connection from the previous step.
- Do not plug in the Google Coral usb yet, open a terminal (either locally on the raspberry Pi desktop or via SSH) .
- Follow the tutorial at https://coral.withgoogle.com/docs/accelerator/get-started/#set-up-on-linux-or-raspberry-pi to install and test the Google Coral firmware.
Step 10: Install ThinkBioT
1. Open a terminal windows either locally on your Raspberry Pi desktop or via SSH.
2. Enter the following line of code to download the ThinkBioT Installation script.
sudo wget -O installThinkBioT.sh https://github.com/mefitzgerald/ThinkBioT/raw/master/installThinkBioT.sh"
3. Now enter the code below to begin the installation.
sudo sh installThinkBioT.sh
4. Once the installation is complete please enter the following to safely reboot your Raspberry Pi
5. Now when you login to the raspberry Pi you should have a new file in your home menu, which is your database called tbt_database and a 2 new directories, the ThinkBioT directory containing all of the ThinkBioT scripts and the pyrockblock directory containing the rockblock library.
Step 11: Complete Construction
Now we are at the hardware completion phase, the actual physical layout of your device is dependent on your enclosure however a simple way to complete the project is below;
- Using adhesive hook and loop cover the power bank and the base your your raspberry pi enclosure. To ensure it lines up I found it best to fit both the hook and loop to the surface (so one adhesive layer is attached to the battery for example and the hook and loop layers are pressing against each other with the final adhesive layer bare) then press the whole lot onto the internal case surface.
- Now you should have both the case with the raspberry pi, the RockBlock and the Google Coral and the power bank attached inside your ThinkBioT enclosure. Now simply cut hook and loop and repeat the action for the SoundBlaster Play 3!.
- Tidy up cables, I have used extra adhesive cable mounts so that I can bundle the cables neatly with cable ties.
- No plug the battery into the witty Pi power socket.
- Carefully attached the SMA cable to the SMA connector on the rockblock.
- Plug the primo microphone into the SoundBlaster Play 3!
- You can also plug the Rockblock into raspberry Pi, but it is easier to keep it unplugged until you are familiar with the operation of the system.
Step 12: Waterproof Your Bioacoustic Sensor
Depending on where you are intending to use your device you may require waterproofing.
I have used to sugru to seal around the ports in the enclosure and the connector on the solar panel as pictured, but you may find silicon or marine grade sealant/silicon works just as well. I choose mold-able silicon glue as I didn't want any to get into the joints and potentially cause open circuits.
Step 13: Use Your Bioacoustic Sensor
Now you have completed your hardware build the software and usage is covered in the following tutorials;
Part 2. Tensorflow Lite Edge Models for ThinkBioT
Part 3. Operating ThinkBioT