Sound Location Part 2 with the Qwiic Sound Trigger and the u-blox ZED-F9x

Pages
Contributors: PaulZC
Favorited Favorite 3

Now, The Good News

Thanks for sticking with us. The good news is that we’ve written more Python code to do that math for you!

The GitHub Hardware Repo contains two examples for the Sound Trigger. You can run these in the Arduino IDE. The second example is the crowd pleaser! It runs on the MicroMod Data Logging Carrier Board together with the Artemis Processor Board but it should work just fine with any of our processor boards. It communicates with our ZED-F9P Breakout and the Qwiic Sound Trigger to capture sound events and log them to SD card as u-blox UBX TIM_TM2 messages.

SparkFun MicroMod Artemis Processor

SparkFun MicroMod Artemis Processor

DEV-16401
$14.95
SparkFun MicroMod Data Logging Carrier Board

SparkFun MicroMod Data Logging Carrier Board

DEV-16829
$21.50
1

Once you have your three sound event UBX TIM_TM2 files, our Sound_Trigger_Analyzer_2D.py will process the files for you and calculate the location of the sound events!

  • Copy the TIM_TM2.ubx file from the SD card from the first system. Rename the file so you know which system it came from. You might want to call it TIM_TM2_A.ubx.
  • Do the same for the TIM_TM2.ubx files from the second and third systems. Again, rename them so you know which system they came from.
  • Place all three files in the same folder / directory as the Sound_Trigger_Analyzer_2D.py Python file

Run the Python code by calling:

language:python
python Sound_Trigger_Analyzer_2D.py TIM_TM2_A.ubx TIM_TM2_B.ubx TIM_TM2_C.ubx 8.0 6.0 10.0 20.0
  • Replace TIM_TM2_A.ubx with the name of the file from the first system (A)
  • Replace TIM_TM2_B.ubx with the name of the file from the second system (B)
  • Replace TIM_TM2_C.ubx with the name of the file from the third system (C)
  • Replace the 8.0, 6.0 and 10.0 with the distances between your sound triggers in metres
    • You must enter them in the correct order: A-B then A-C then B-C
  • The 20.0 is optional. It is the temperature in Celcius (Centigrade). Change this to your actual temperature for added accuracy

The Python code will calculate and display the (x,y) coordinates of any valid sound events it finds. The coordinate system uses the location of A as the origin, and the line running from A to B as the X axis. The Y axis is (of course) 90 degrees counterclockwise from X.

The calculation code assumes that the X coordinate of C is between A and B. If C lies to the left of A, or the right of B, then you need to rename your points. If C is to the left of A, then B becomes A, C becomes B, and A becomes C:

Pictured are two triangles

Enjoy your coordinates!