ESP32-C3 firmware for the HALSER board that bridges an Autonnic A5120 ultrasonic wind instrument to NMEA 2000 and Signal K networks.
This firmware serves as both a ready-to-use application and a reference example for building custom SensESP-based marine interface firmware.
- Receives apparent wind data (speed and angle) from the Autonnic A5120 via NMEA 0183 WIMWV sentences at 4800 bit/s
- Transmits wind data as NMEA 2000 PGN 130306 (Wind Data) at 100ms intervals
- Outputs wind data to Signal K via WiFi/WebSocket
- Configurable Autonnic A5120 parameters via web UI:
- Reference angle offset (wind vane alignment)
- Wind direction damping
- Wind speed damping
- Message repetition rate
- OLED display showing hostname, IP, uptime, wind speed, and wind angle
- RGB LED activity indicator
- OTA firmware updates
- NMEA 2000 watchdog with configurable auto-reboot
- HALSER board
- Autonnic A5120 ultrasonic wind instrument
- NMEA 2000 network connection
- Optional: SSD1306 128x64 OLED display (I2C)
| HALSER Pin | Function |
|---|---|
| GPIO 2 | UART1 TX → Autonnic RX |
| GPIO 3 | UART1 RX ← Autonnic TX |
| GPIO 4 | CAN TX → NMEA 2000 |
| GPIO 5 | CAN RX ← NMEA 2000 |
| GPIO 6 | I2C SDA (OLED display) |
| GPIO 7 | I2C SCL (OLED display) |
| GPIO 8 | RGB LED (SK6805) |
| GPIO 9 | Button |
The Autonnic A5120 communicates via NMEA 0183 at 4800 bit/s (8N1).
The A5120 uses RS-232 levels for its TX output (data to HALSER) and NMEA 0183 levels for its RX input (configuration commands from HALSER). Set the HALSER RX jumper to R (RS-232 mode). HALSER TX is connected to the NMEA 0183 TX output.
Use a 5-pin SP13 connector to route the masthead cable into the HALSER enclosure.
- Flash the firmware to the HALSER board
- The device creates a WiFi access point on first boot
- Connect to the AP and configure your WiFi network credentials
- Access the web UI at
http://wind.local
Navigate to the Reference Angle section in the web UI. Enter the angle readout (in degrees) when the wind vane is pointing straight ahead. This offset corrects for misalignment between the wind instrument and the vessel's heading.
The value is stored internally in radians but displayed in degrees in the web UI.
The Wind Direction Damping and Wind Speed Damping sections control smoothing applied to the wind data. Values range from 0 to 100, with a default of 50. Higher values produce smoother readings but increase response lag.
The Message Repetition Rate sets how often the A5120 sends WIMWV sentences, in milliseconds. Default is 500ms.
All Autonnic configuration parameters are stored in two places:
- ESP32 filesystem — persists across firmware reboots
- Autonnic A5120 — sent as proprietary
$PATC,IIMWVcommands with ACK confirmation
When a setting is saved via the web UI, the firmware writes to the filesystem and sends the corresponding command to the A5120. A semaphore-based mechanism waits for the $PATC,WIMWV,ACK response to confirm the command was accepted.
Wind data is emitted to Signal K as:
environment.wind.speedApparent— apparent wind speed in m/senvironment.wind.angleApparent— apparent wind angle in radians
An optional watchdog can be enabled in the web UI under Enable NMEA 2000 Watchdog. When enabled, the device reboots if no NMEA 2000 messages are received for two minutes. This helps recover from CAN bus lockups. The setting requires a device restart to take effect.
The N2K sender uses RepeatExpiring to handle stale wind data. If no new wind measurement arrives within 5 seconds, the sender transmits N2kDoubleNA ("not available") values instead of repeating stale data. PGN 130306 messages continue at 100ms regardless — downstream devices always see a consistent message rate and can distinguish "no data" from silence.
If connected, a 128x64 SSD1306 OLED display shows:
- Device hostname
- WiFi IP address
- Uptime in seconds
- (blank line)
- Apparent wind speed (m/s)
- Apparent wind angle (degrees, -180 to +180)
Autonnic A5120 (NMEA 0183, 4800 bit/s)
│
│ UART1 (GPIO 3 RX / GPIO 2 TX)
▼
NMEA0183IOTask
├── WIMWVSentenceParser (apparent wind speed + angle)
│ ├── N2kWindDataSender → NMEA 2000 bus (TWAI, GPIO 4/5)
│ ├── SKOutputFloat → Signal K server (speed + angle)
│ └── InfoDisplay → OLED (speed + angle)
│
└── AutonnicPATCWIMWVParser (ACK responses for config commands)
Web UI (SensESP) ──── Config objects ──── Autonnic (serial commands)
└── Filesystem (persistent storage)
The firmware is built on SensESP, which provides WiFi connectivity, a web UI for configuration, Signal K protocol support, and OTA updates.
Producer/Consumer pipeline: SensESP uses a reactive pipeline where producers emit values that flow to connected consumers. The WIMWV parser produces apparent wind speed and angle values consumed by the N2K sender, Signal K outputs, and OLED display. Producers and consumers are connected via connect_to().
Dual config storage with command/ACK confirmation: Each config object (ReferenceAngleConfig, WindDirectionDampingConfig, etc.) saves to the ESP32 filesystem and sends a proprietary command to the Autonnic A5120. A SemaphoreValue waits up to 1 second (5 seconds for repetition rate) for the ACK response, parsed by AutonnicPATCWIMWVParser.
NMEA 2000 value expiry: The N2kWindDataSender wraps inputs in RepeatExpiring<double>, which returns N2kDoubleNA when the source value is older than 5 seconds. This prevents stale wind data from being transmitted as valid measurements while maintaining the 100ms PGN 130306 transmission rate.
| File | Purpose |
|---|---|
autonnic_config.h |
4 config classes (reference angle, direction damping, speed damping, repetition rate) with dual filesystem/serial storage |
autonnic_a5120_parser.h |
SentenceParser for proprietary $PATC,WIMWV,ACK responses |
| File | Purpose |
|---|---|
n2k_senders.h |
N2kWindDataSender — PGN 130306 at 100ms with RepeatExpiring for stale data |
| File | Purpose |
|---|---|
main.cpp |
Entry point — wires all components together |
ssd1306_display.h/.cpp |
OLED display driver (hostname, IP, uptime, AWS, AWA) |
Configuration uses proprietary NMEA 0183 sentences:
| Command | Sentence | Description |
|---|---|---|
| Reference angle | $PATC,IIMWV,AHD,<degrees> |
Wind vane alignment offset |
| Direction damping | $PATC,IIMWV,DWD,<factor> |
Direction smoothing (0-100) |
| Speed damping | $PATC,IIMWV,DSP,<factor> |
Speed smoothing (0-100) |
| Repetition rate | $PATC,IIMWV,TXP,<ms> |
Message interval in milliseconds |
All commands receive a $PATC,WIMWV,ACK response on success. The parser ignores checksums because the A5120 does not include them in responses.
| Field | Value |
|---|---|
| Device function | 130 (Weather Instruments) |
| Device class | 85 (Sensor Communication Interface) |
| Manufacturer code | 2046 |
| Transmitted PGN | 130306 (Wind Data) |
| Wind reference | Apparent |
Requires PlatformIO.
# Build firmware
pio run
# Upload to connected board
pio run -t upload
# Monitor serial output
pio device monitorThis repository does not yet have automated tests. Contributions are welcome.
This firmware demonstrates several patterns useful for building custom SensESP marine interfaces:
- NMEA 0183 sentence parsing — Using SensESP's built-in
WIMWVSentenceParserfor standard sentences - External device configuration — Command/ACK pattern with semaphore-based confirmation and timeout handling
- NMEA 2000 output with value expiry —
RepeatExpiringprevents stale data transmission while maintaining constant PGN rate - Dual config storage — Persisting settings to both the ESP32 filesystem and the external device via serial commands
- Producer/Consumer pipeline — Connecting a single data source (wind parser) to multiple sinks (N2K, Signal K, OLED)
To adapt this for a different device:
- Replace the
AutonnicPATCWIMWVParserand config classes with your device's protocol - Modify or replace
WIMWVSentenceParserif your device uses different NMEA 0183 sentences - Update the N2K sender for your target PGNs
- Adjust pin assignments and bit rate in
main.cpp
See LICENSE for details.