0
# Depth and Sonar Sentences
1
2
Depth and sonar sentences provide water depth measurements from various types of depth finding equipment including echo sounders and sonar systems.
3
4
## Depth Measurement Sentences
5
6
### DBT - Depth Below Transducer
7
8
```python { .api }
9
class DBT(TalkerSentence):
10
"""Depth Below Transducer."""
11
12
depth_feet: str # Depth in feet
13
unit_feet: str # 'f' for feet
14
depth_meters: str # Depth in meters
15
unit_meters: str # 'M' for meters
16
depth_fathoms: str # Depth in fathoms
17
unit_fathoms: str # 'F' for fathoms
18
```
19
20
### DBS - Depth Below Surface
21
22
```python { .api }
23
class DBS(TalkerSentence):
24
"""Depth Below Surface."""
25
26
depth_feet: str # Depth in feet
27
feets: str # 'f' for feet
28
depth_meter: str # Depth in meters
29
meters: str # 'M' for meters
30
depth_fathoms: str # Depth in fathoms
31
fathoms: str # 'F' for fathoms
32
```
33
34
### DPT - Depth of Water
35
36
```python { .api }
37
class DPT(TalkerSentence):
38
"""Depth of Water."""
39
40
depth: str # Water depth in meters
41
offset: str # Offset from transducer
42
range: str # Maximum range scale
43
```
44
45
## Usage Examples
46
47
```python
48
import pynmea2
49
50
# Parse depth below transducer
51
msg = pynmea2.parse("$SDDBT,12.3,f,3.7,M,2.0,F*35")
52
print(f"Depth: {msg.depth_feet} feet = {msg.depth_meters} meters = {msg.depth_fathoms} fathoms")
53
# Depth: 12.3 feet = 3.7 meters = 2.0 fathoms
54
55
# Parse depth below surface
56
msg = pynmea2.parse("$SDDBS,15.8,f,4.8,M,2.6,F*09")
57
print(f"Surface depth: {msg.depth_meter} {msg.meters}") # 4.8 M
58
59
# Parse water depth with offset
60
msg = pynmea2.parse("$SDDPT,4.2,0.5,*4F")
61
print(f"Water depth: {msg.depth}m, Offset: {msg.offset}m") # 4.2m, 0.5m
62
if msg.range:
63
print(f"Range scale: {msg.range}")
64
65
# Create depth sentence
66
dbt_data = ['12.3', 'f', '3.7', 'M', '2.0', 'F']
67
depth_msg = pynmea2.DBT('SD', 'DBT', dbt_data)
68
print(str(depth_msg)) # $SDDBT,12.3,f,3.7,M,2.0,F*35
69
```
70
71
## Unit Conversions
72
73
Common depth unit conversions:
74
- **1 fathom = 6 feet = 1.8288 meters**
75
- **1 meter = 3.28084 feet**
76
- **1 foot = 0.3048 meters**
77
78
```python
79
import pynmea2
80
81
msg = pynmea2.parse("$SDDBT,12.3,f,3.7,M,2.0,F*35")
82
83
# Convert between units manually
84
feet_to_meters = float(msg.depth_feet) * 0.3048
85
meters_to_feet = float(msg.depth_meters) * 3.28084
86
fathoms_to_meters = float(msg.depth_fathoms) * 1.8288
87
88
print(f"Conversions:")
89
print(f" {msg.depth_feet} ft = {feet_to_meters:.2f} m") # 12.3 ft = 3.75 m
90
print(f" {msg.depth_meters} m = {meters_to_feet:.2f} ft") # 3.7 m = 12.14 ft
91
print(f" {msg.depth_fathoms} F = {fathoms_to_meters:.2f} m") # 2.0 F = 3.66 m
92
```