Raunak Singh
Published © MIT

WalrusEye: helping scientists count and protect walrus

Use the Sony Spresense to gather key sensor data and use custom-trained Object Detection ML model to detect and count walrus

AdvancedFull instructions providedOver 1 day132
WalrusEye: helping scientists count and protect walrus

Things used in this project

Hardware components

Spresense boards (main & extension)
Sony Spresense boards (main & extension)
×1
NVIDIA Jetson Nano Developer Kit
NVIDIA Jetson Nano Developer Kit
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Analog Accelerometer: ADXL335
Adafruit Analog Accelerometer: ADXL335
×1
SparkFun Electret Microphone Breakout
SparkFun Electret Microphone Breakout
×1
Temperature Sensor
Temperature Sensor
×1
Webcam, Logitech® HD Pro
Webcam, Logitech® HD Pro
×1
Zulkit Junction Box
×1
DC Power Supply for Jetson Nano
×1
USB Wireless Dongle
Make sure whatever dongle you get works with the Jetson Nano
×1
Anker 511 PowerHouse
×1

Software apps and online services

AWS S3
Amazon Web Services AWS S3
AWS Quicksight
Amazon Web Services AWS Quicksight
VS Code
Microsoft VS Code
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Drill / Driver, Cordless
Drill / Driver, Cordless

Story

Read more

Schematics

WalrusEye Spresense Schematics

Code

walruseye_sensor_code.ino

Arduino
arduino code to take the data from the sensors and output it in the serial monitor where it can be read by the Jetson Nano
/* 
 *  WalrusEye: Sensor Code
 *  
 *  code to get data from the Temp, GNSS, and Accelerometer 
 *  connected to the Spresense board and
 *  print it to the Serial Monitor
 *  
 *  created by Raunak Singh Inventor
 *  modified 22 Jul 2022
*/

#include <GNSS.h>
static SpGnss Gnss;

float temp;
int tempPin = A3;

int xOutPin = A0;
int yOutPin = A1;
int zOutPin = A2;

const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;

int micPin = A4;

void setup() {
    /* Setup serial output for printing. */
    Serial.begin(115200);

    /* Initialize GNSS. */
    Gnss.begin();
    Gnss.start();
}

void loop()
{
  /* Wait for an update. */
  if (Gnss.waitUpdate(-1))
  {
    /* Get navigation data. */
    SpNavData NavData;
    Gnss.getNavData(&NavData);

    /* Print position and satellite count. */
    Serial.print("LAT ");
    Serial.println(NavData.latitude, 6);
    Serial.print("LNG ");
    Serial.println(NavData.longitude, 6);
    
    temp = analogRead(tempPin);
    // read analog volt from sensor and save to variable temp
    temp = temp * 0.48828125;
    // convert the analog volt to its temperature equivalent
    Serial.print("TEMP ");
    Serial.print(temp); // display temperature value
    Serial.println();

    // read the  values for X, Y, Z
    int XValue = analogRead(xOutPin);
    int YValue = analogRead(yOutPin);
    int ZValue = analogRead(zOutPin);

    Serial.print("X ");
    Serial.print(XValue);
    Serial.println();
    Serial.print("Y ");
    Serial.print(YValue);
    Serial.println();
    Serial.print("Z ");
    Serial.print(ZValue);
    Serial.println();

    unsigned long startMillis= millis();  // Start of sample window
    unsigned int peakToPeak = 0;   // peak-to-peak level

    unsigned int signalMax = 0;
    unsigned int signalMin = 1024;

    // collect data for 50 mS
    while (millis() - startMillis < sampleWindow)
    {
       sample = analogRead(4);
       if (sample < 1024)  // toss out spurious readings
       {
          if (sample > signalMax)
          {
             signalMax = sample;  // save just the max levels
           }
           else if (sample < signalMin)
          {
             signalMin = sample;  // save just the min levels
          }
       }
    }
    peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
    double volts = (peakToPeak * 5.0) / 1024;  // convert to volts

    Serial.print("MIC ");
    Serial.println(volts);
    
    delay(1000); // update sensor reading each one second
  }
}

ADXL335_accelerometer_code.ino

Arduino
Example of using the ADXL335 Accelerometer
/*
 * ADXL335 Accelerometer Example
 * 
 * Shows how to read in analog input from the ADXL335 Accelerometer
 * 
 * Circuit for Adafruit version:
 *  Sensor Pin | Arduino Pin
 *  ------------------------
 *  Xout       | A0
 *  Yout       | A1
 *  Zout       | A2
 *  GND        | GND
 *  3Vo        | AREF
 *  Vin        | 5V
 *  
 * created by Raunak Singh Inventor
 * modified 22 Jul 2022
 */

// set the input pin for XOut, YOut, ZOut
int xOutPin = A0;
int yOutPin = A1;
int zOutPin = A2;
 
void setup() {
  Serial.begin(9600);
//  // set the voltage value at the top
//  // of the input range to 3.3V
//  // (the voltage being passed into the AREF pin)
//  analogReference(EXTERNAL);
}

void loop() {
  // read the  values for X, Y, Z
  int XValue = analogRead(xOutPin);
  int YValue = analogRead(yOutPin);
  int ZValue = analogRead(zOutPin);

  Serial.print("XValue: ");
  Serial.println(XValue);

  Serial.print("YValue: ");
  Serial.println(YValue);

  Serial.print("ZValue: ");
  Serial.println(ZValue);

  Serial.println();
  // delay(1000); 
}

adafruit_electret_mic_code.ino

Arduino
Example on how to use Adafruit Electret Microphone.
/****************************************
Example Sound Level Sketch for the 
Adafruit Microphone Amplifier
****************************************/

const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;

void setup() 
{
   Serial.begin(9600);
}


void loop() 
{
   unsigned long startMillis= millis();  // Start of sample window
   unsigned int peakToPeak = 0;   // peak-to-peak level

   unsigned int signalMax = 0;
   unsigned int signalMin = 1024;

   // collect data for 50 mS
   while (millis() - startMillis < sampleWindow)
   {
      sample = analogRead(4);
      if (sample < 1024)  // toss out spurious readings
      {
         if (sample > signalMax)
         {
            signalMax = sample;  // save just the max levels
         }
         else if (sample < signalMin)
         {
            signalMin = sample;  // save just the min levels
         }
      }
   }
   peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
   double volts = (peakToPeak * 5.0) / 1024;  // convert to volts

   Serial.println(volts);
}

WalrusEye Code & Links

Arduino code for WalrusEye and some links to the Kaggle datasets I created to house my WalrusEye-dataset and WalrusEye-deployment repos. I had to use Kaggle as my files were over github's size limit of 100 MB.

Credits

Raunak Singh

Raunak Singh

4 projects • 16 followers
I have a passion for tinkering, coding, and hardware. OPEN-SOURCE Rules!!!

Comments

Add projectSign up / Login