nordic-dev-net / hydrophonitor

Hydrophonitor is a hydrophone array that records audio, gps and depth data.
MIT License
20 stars 1 forks source link

Hydrophonitor

A NixOS flake based operating system for Raspberry Pi 3 (tested on v1.2) and Raspberry Pi 4 (tested on 4B), configured for recording audio through hydrophones via a USB sound card, logging GPS data through a USB GPS dongle, and recording depth through a pressure sensor and an analog-to-digital converter (depth recording not implemented yet).

Overview

Module Description
audio-recorder Receive an audio signal from the DAC and write it on disk in .wav format.
gps-recorder Record position and time of the device in .json format.
*depth-recorder Record depth of the device and save it in .csv format.
real-time-clock Configure and use an RTC to update system time from hardware clock when not connected to the internet.
shutdown-button  Gracefully shut down the system using a button attached to the GPIO pin.
*device-controls Provide device control using physical buttons.

*) todo, not implemented yet

Data Formats

Type Output file format Output file name Output structure
Audio Data .wav <start-time-of-recording>.wav Each recorded batch will be written to its own file in /output/audio folder
GPS Data .json <start-time-of-recording>.json All data written to a single file in /output/gps

Notes on Modules and Configuration Options

Other Configurations

Enabling WiFi

Add the following to targets//default.nix where "SSID name" is replaced with the network name and "SSID password" is the network password:

  networking = {
    hostName = "kaskelotti";
    wireless = {
      enable = true;
      networks = {
        "SSID name" = {
          psk = "SSID password";
        };
      };
      interfaces = ["wlan0"];
    };
  };

Building the Image on Mac M1

Image has been built with UTM (virtualization for silicon Macs, now running on 2020 M1 Air) on Ubuntu 22.04 VM (with nix installed) with the following command:

nix build .#systems.raspberry-pi-4.config.system.build.sdImage --extra-experimental-features "nix-command flakes"

The result image has to be copied from the VM nix store path to the directory that was shared between the client and the host.

cp -rL result/sd-image/nixos-sd-image-23.11.20230908.db9208a-aarch64-linux.img .

Initially, image is flashed to the SD card with the following command (on the host)

diskutil list # check SD card, here /dev/disk4
diskutil unmountdisk /dev/disk4
sudo dd if=../UTM/hydrophonitor/nixos-sd-image-23.11.20230702.0fbe93c-aarch64-linux.img of=/dev/disk4 status=progress
diskutil eject /dev/disk4

After bootstrapping and connecting the Pi to the local network, deploy-rs can be used for deployments from UTM (update correct IP address to the deploy configuration):

nix run github:serokell/deploy-rs .#raspberry-pi-4

Notes