Skip to content

Commit 4a4dcb5

Browse files
committed
docs: add sensor connection guide to README
1 parent ddb3ad2 commit 4a4dcb5

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,84 @@ All config flows through the `EdgeConfig` dataclass in `config.py`:
9292

9393
See `config.py` for the full list. Standalone mode uses env vars and CLI args; IoT Edge mode uses twin desired properties.
9494

95+
## Connecting Sensors
96+
97+
There are three ingestion paths, depending on how sensors deliver data.
98+
99+
### Network Stream (live sensors)
100+
101+
Most oceanographic instruments output serial data. A serial-to-TCP converter (e.g. Moxa NPort, Digi Connect, or `ser2net` on Linux) bridges the serial port to a TCP socket.
102+
103+
**Server mode** — module listens, sensor/converter connects to it:
104+
```
105+
Sensor → Serial → ser2net/Moxa → TCP connect to :9100 → sensorstream
106+
```
107+
Twin config:
108+
```json
109+
{"stream_port": 9100, "stream_connect_mode": "server", "stream_format": "auto"}
110+
```
111+
112+
**Client mode** — module connects to an existing TCP server:
113+
```
114+
Sensor → Serial → ser2net :4001 ← TCP connect ← sensorstream
115+
```
116+
Twin config:
117+
```json
118+
{"stream_host": "192.168.0.50", "stream_port": 4001, "stream_connect_mode": "client", "stream_format": "nmea"}
119+
```
120+
121+
UDP also works — common for NMEA multiplexers that broadcast on a UDP port.
122+
123+
| Sensor | Protocol | Format | Notes |
124+
|--------|----------|--------|-------|
125+
| Ship GPS (GGA/RMC) | TCP/UDP | `nmea` | NMEA 0183 via serial gateway |
126+
| Sea-Bird SBE 11plus | TCP | `hex` | Deck unit serial output, hex scan lines |
127+
| Generic CTD | TCP | `csv` | Comma-separated T/C/P values |
128+
129+
### File Drop (batch or near-real-time)
130+
131+
Sensors or acquisition software write files to a shared volume. The module watches that directory.
132+
133+
```
134+
EK80/SBE software → writes .cnv/.hex to /data/sensor/ → file watcher → sensorstream
135+
```
136+
Twin config:
137+
```json
138+
{"input_mode": "file", "watch_dir": "/data/sensor", "watch_patterns": "*.csv,*.txt,*.hex,*.cnv"}
139+
```
140+
141+
On edge devices, bind-mount the data volume into the container:
142+
```json
143+
"createOptions": {"HostConfig": {"Binds": ["/data/sensor:/data/sensor:ro"]}}
144+
```
145+
146+
### IoT Edge Message Route (from filenotifier)
147+
148+
The `filenotifier` module watches raw data directories and sends messages when new files appear:
149+
```json
150+
"routes": {
151+
"sensorNotifyToStream": "FROM /messages/modules/filenotifier/outputs/sensorfileadded INTO BrokeredEndpoint(\"/modules/iotedge-sensorstream/inputs/sensorfileadded\")"
152+
}
153+
```
154+
155+
### Combining Modes
156+
157+
Set `input_mode: "both"` to run file watcher and stream listener simultaneously — e.g. GNSS over TCP stream + CTD .hex files dropped to disk.
158+
159+
### Testing Without Hardware
160+
161+
Use the built-in simulators:
162+
```bash
163+
# Replay NMEA over TCP
164+
.venv/bin/python standalone.py --simulate-stream ./test_data/gnss/track.txt --output-dir ./output
165+
166+
# Replay CTD hex scans over TCP (emulates SBE 11plus)
167+
.venv/bin/python standalone.py --simulate-ctd ./test_data/ctd/hex/11901.hex --output-dir ./output
168+
169+
# Drop files into a watch directory
170+
.venv/bin/python standalone.py --simulate-files ./test_data --watch /tmp/watch --output-dir ./output
171+
```
172+
95173
## Testing
96174

97175
```bash

0 commit comments

Comments
 (0)