Skip to the content
2 layers110 × 82 mmInvertor, the printed circuit board in 3D

This repository contains an ESP-IDF firmware for an ESP32 board that bridges, translates, decodes, and exposes battery/inverter communication over CAN and RS485.

Size
110 × 82 mm
Copper layers
2
Thickness
1.6 mm
Parts
151
Nets
104
Pads
443
Tracks, vias
1,283, 271
Pours
8
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
8 Feb 2026
Updated
23 Aug 2026

Overview

Invertor is an open-source printed circuit board by victorstoica114, from the victorstoica114/Invertor_board repository on GitHub. It is a 2-layer board of 110 × 82 mm with 151 parts on 104 nets, routed with 1,283 tracks and 271 vias.

It is built around the ESP32-C6-WROOM-1-N8, RS485 and MCP16311-E/MS, with the TPD2S017DBV and ESDA5V3L among its other parts. Its parts include 49 capacitors, 40 resistors, 12 diodes, 10 fuses and 7 ICs. It belongs with the interfaces and adapters boards and the ESP32 and RISC-V boards of this library.

Main components

5

README

README.md

ESP32 CAN/RS485 Bridge Firmware

This repository contains an ESP-IDF firmware for an ESP32 board that bridges, translates, decodes, and exposes battery/inverter communication over CAN and RS485.

The project is used as a practical protocol bridge between BMS and inverter, with runtime configuration through a web UI.

See also: CHANGELOG.md

CAN protocol implementation backlog: docs/can_protocols.md

Target Hardware

  • MCU family: Espressif ESP32
  • Current target in this repository: ESP32-C6
  • Field-tested module: ESP32-C6-WROOM-1-N8 (8MB flash)
  • ESP-IDF version used by local builds and CI: v6.0.1
  • Suggested IDF target command: idf.py set-target esp32c6
  • Current partition layout: single 7MB factory app partition, no OTA

PCB and Schematic

Invertor main board PCB

Board schematic: Kicad project/Invertor_main_board/Schematic.pdf

Short Description

Main goals:

  • acquire battery data from CAN or RS485 protocols
  • normalize and forward data toward inverter-side protocols
  • support special translator routes (not only same-protocol pass-through)
  • provide runtime settings via web API/UI
  • expose telemetry + decoded logs for diagnostics

Current Capabilities (High Level)

Implemented / available:

  • RS485_GROWATT BMS polling/decoding (Modbus) + queue publish, including JK UART profile 006 cell voltages and Growatt warning/error bits
  • JKBMS_MODBUS BMS polling/decoding (Modbus) + rich snapshot, with 9600 and 115200 RS485 variants
  • JKBMS_RS485_NATIVE experimental BMS polling/decoding (4E 57 native RS485 read-all frames) + rich snapshot
  • PACE_RS485_MODBUS_V1.3 BMS polling/decoding (Modbus) + rich snapshot
  • VOLTRONIC_MODBUS BMS polling/decoding for JK UART profile 007 - Voltronic_Inverter_and_BMS_485 + rich snapshot
  • CHINA_TOWER_MODBUS BMS polling/decoding for JK UART profile 008 - China tower shared battery cabinet V2.0 + pack/cell/temperature snapshot
  • WOW_MODBUS BMS polling/decoding for JK UART profile 009 - WOW_RS485_Modbus_V1.3 + PACE-compatible pack/cell/temperature snapshot
  • DALY_RS485 BMS polling/decoding for the Daly proprietary RS485 protocol + rich snapshot
  • experimental DALY_CAN BMS polling/decoding for the Daly proprietary CAN protocol
  • GROWATT inverter CAN sender (publishes the main low-voltage Growatt CAN frame set from the shared battery model)
  • CAN_GROWATT | CAN_PYLON | CAN_GOODWE | CAN_SOFAR | CAN_SMA | CAN_VICTRON -> RS485_GROWATT translator (main/protocols/rs485_growatt/rs485_growatt_bridge.c)
  • RS485_JKBMS -> RS485_GROWATT translator (JKBMS_MODBUS, JKBMS_MODBUS_115200, and JKBMS_RS485_NATIVE)
  • RS485_WOW -> RS485_GROWATT translator/responder, intended for JK UART profile 009 - WOW_RS485_Modbus_V1.3
  • RS485_JKBMS -> CAN_GROWATT translator/sender (JKBMS_MODBUS, JKBMS_MODBUS_115200, and JKBMS_RS485_NATIVE), preserving JK all-cell telemetry while publishing Growatt CAN inverter frames
  • RS485_JKBMS -> RS485_PYLON translator/responder (JKBMS_MODBUS, JKBMS_MODBUS_115200, and JKBMS_RS485_NATIVE)
  • RS485_GROWATT -> RS485_PYLON translator/responder, intended for JK UART profile 006 - Growatt_BMS_RS485_Protocol_1xSxxP_ESS_Rev2.01
  • RS485_PACE -> RS485_PYLON translator/responder
  • RS485_VOLTRONIC -> RS485_PYLON translator/responder, intended for JK UART profile 007 - Voltronic_Inverter_and_BMS_485
  • RS485_CHINA_TOWER -> RS485_PYLON translator/responder, intended for JK UART profile 008 - China tower shared battery cabinet V2.0
  • RS485_WOW -> RS485_PYLON translator/responder, intended for JK UART profile 009 - WOW_RS485_Modbus_V1.3
  • RS485_DALY -> RS485_PYLON translator/responder
  • RS485_DALY -> CAN_PYLON translator/sender, field-tested as Daly RS485 on RS485_1 to EASUN Pylon CAN on CAN2
  • RS485_PYLON -> CAN_PYLON translator/sender, field-tested as JK Pylon RS485 on RS485_1 to Pylon CAN inverter output on CAN2
  • RS485_PYLON -> CAN_GROWATT translator/sender, using the Pylon RS485 source poller and Growatt CAN sender on the selected CAN inverter port
  • experimental DALY_CAN -> RS485_PYLON translator/responder
  • RS485_PYLON <-> RS485_PYLON bridge/responder, including the RS485_PYLON_115200 variant
  • CAN_PYLON -> RS485_PYLON synthetic responder/bridge, including the RS485_PYLON_115200 variant
  • JKBMS_CAN_250K -> RS485_PYLON synthetic responder/bridge for JK app profile 000 - JK BMS CAN Protocol (250K) V2.0
  • CAN_DEYE -> RS485_PYLON synthetic responder/bridge for JK app profile 001 - Deye Low-voltage hybrid inverter CAN
  • CAN_PYLON -> CAN_PYLON direct forward mode for split CAN ports, field-tested as JKBMS Pylon CAN on CAN1 -> EASUN Pylon CAN on CAN2
  • CAN snapshot decoders for Growatt-like, Pylon, Deye, and JK BMS CAN frame sets
  • web UI + API for runtime config and telemetry
  • optional dual-BMS mode with an independent, telemetry-only RS485 BMS 2 and a second telemetry tab/API
  • runtime Fake Inverter Data override for inverter-facing synthetic routes, Pylon RS485 passthrough, and Pylon CAN forward frames

Dual-BMS configuration and current limitations are documented in docs/dual_bms.md.

Partially implemented / scaffold:

  • generic PROTOCOL_ID_PYLON BMS task (pylon_bms_task.c) remains a scaffold placeholder; the inverter side has an active CAN_PYLON sender and RS485 Pylon routes are handled by the dedicated bridge/responder
  • CAN_SOFAR, CAN_SMA, CAN_VICTRON have protocol IDs and register-map headers, but no dedicated full task pipeline yet
  • CAN_DEYE has active CAN decode path, but is not currently in the dedicated CAN -> RS485_GROWATT special-route selector
  • DALY_CAN has a native poller and RS485_PYLON synthetic responder route, but the field BMS tested on 2026-05-30 did not ACK CAN traffic on either CAN port
  • optional EASUN/Pylon 24V diagnostic CAN sender exists for isolated inverter tests, but is disabled by default (EASUN_PYLON_24V_DIAG_SENDER_ENABLE=0)

Current bridge-mode route matrix:

RouteConditionStatus
CAN -> RS485_GROWATT translatorbms_line=CAN, inv_line=RS485, inv_protocol=RS485_GROWATT, bms_protocol in {CAN_GROWATT,CAN_PYLON,CAN_GOODWE,CAN_SOFAR,CAN_SMA,CAN_VICTRON}Active
RS485_JKBMS -> RS485_GROWATT translatorbms_line=RS485, inv_line=RS485, bms_protocol in {JKBMS_MODBUS,JKBMS_MODBUS_115200,JKBMS_RS485_NATIVE}, inv_protocol=RS485_GROWATTActive for Modbus; native is experimental
RS485_WOW -> RS485_GROWATT translatorbms_line=RS485, inv_line=RS485, bms_protocol=WOW_MODBUS, inv_protocol=RS485_GROWATTActive; covers JK UART profile 009 with the PACE-compatible WOW map
RS485_JKBMS -> CAN_GROWATT translatorbms_line=RS485, inv_line=CAN, bms_protocol in {JKBMS_MODBUS,JKBMS_MODBUS_115200,JKBMS_RS485_NATIVE}, inv_protocol=CAN_GROWATTActive; preferred when the web/API must show JK all-cell voltages while the inverter receives Growatt CAN
RS485_JKBMS -> RS485_PYLON translatorbms_line=RS485, inv_line=RS485, bms_protocol in {JKBMS_MODBUS,JKBMS_MODBUS_115200,JKBMS_RS485_NATIVE}, inv_protocol in {RS485_PYLON,RS485_PYLON_115200}Active for Modbus; native is experimental
RS485_GROWATT -> RS485_PYLON translatorbms_line=RS485, inv_line=RS485, bms_protocol=RS485_GROWATT, inv_protocol=RS485_PYLONActive; covers JK UART profile 006
RS485_GROWATT -> CAN_PYLON translatorbms_line=RS485, inv_line=CAN, bms_protocol=RS485_GROWATT, inv_protocol=CAN_PYLONActive; field-tested with Seplos selector 10 (Growatt SPF), signed current and all 16 cell voltages
RS485_PACE -> RS485_PYLON translatorbms_line=RS485, inv_line=RS485, bms_protocol=PACE_RS485_MODBUS, inv_protocol=RS485_PYLONActive
RS485_VOLTRONIC -> RS485_PYLON translatorbms_line=RS485, inv_line=RS485, bms_protocol=VOLTRONIC_MODBUS, inv_protocol=RS485_PYLONActive; covers JK UART profile 007
RS485_CHINA_TOWER -> RS485_PYLON translatorbms_line=RS485, inv_line=RS485, bms_protocol=CHINA_TOWER_MODBUS, inv_protocol=RS485_PYLONActive; covers JK UART profile 008
RS485_WOW -> RS485_PYLON translatorbms_line=RS485, inv_line=RS485, bms_protocol=WOW_MODBUS, inv_protocol=RS485_PYLONActive initial implementation; covers JK UART profile 009 with PACE-compatible map
RS485_DALY -> RS485_PYLON translatorbms_line=RS485, inv_line=RS485, bms_protocol=DALY_RS485, inv_protocol=RS485_PYLONActive
RS485_DALY -> CAN_PYLON translatorbms_line=RS485, inv_line=CAN, bms_protocol=DALY_RS485, inv_protocol=CAN_PYLONActive; field-tested with EASUN 24V
RS485_PYLON -> CAN_PYLON translatorbms_line=RS485, inv_line=CAN, bms_protocol in {RS485_PYLON,RS485_PYLON_115200}, inv_protocol=CAN_PYLONActive; field-tested with JK Pylon RS485 at 9600
RS485_PYLON -> CAN_GROWATT translatorbms_line=RS485, inv_line=CAN, bms_protocol in {RS485_PYLON,RS485_PYLON_115200}, inv_protocol=CAN_GROWATTActive; uses the Pylon RS485 source poller and Growatt CAN sender
DALY_CAN -> RS485_PYLON translatorbms_line=CAN, inv_line=RS485, bms_protocol=DALY_CAN, inv_protocol=RS485_PYLONExperimental; protocol task implemented, live CAN link not validated
Pylon RS485 bridgeRS485_PYLON<->RS485_PYLON, RS485_PYLON->CAN_PYLON, CAN_PYLON->RS485_PYLON, CAN_DEYE->RS485_PYLON, or JKBMS_CAN_250K->RS485_PYLON, with RS485_PYLON_115200 accepted on RS485 sidesActive
Generic orchestrator routeany other valid combinationActive, depends on protocol task maturity

Runtime Modes

Modes are selected from runtime settings (mode):

  • MODE_BRIDGE = 3
  • uses orchestrator + protocol tasks/translators
  • this is the main production mode
  • MODE_FORWARD = 2
  • direct forward tasks (CAN1->CAN2, RS485_1->RS485_2) with optional decode logging
  • field-tested CAN forward case: JKBMS Pylon CAN -> EASUN Pylon CAN, with JKBMS on CAN1, EASUN on CAN2, both at 500 kbit/s
  • when runtime Fake Inverter Data is enabled, Pylon CAN forward modifies outgoing inverter-facing frames before transmit (0x351, 0x355, 0x356, 0x35C, and 0x373 when present)
  • MODE_SNIFFER = 1
  • passive sniff/decode tasks on both CAN + both RS485 ports

Important:

  • hot switching between modes is not supported at runtime in current build
  • changing mode usually requires restart/reboot path

Route Selection in Bridge Mode

Bridge mode route selection is done in orchestratorStartFromRuntime(...):

  1. CAN -> RS485_GROWATT translator route
  2. RS485_JKBMS -> RS485_GROWATT translator route
  3. RS485_WOW -> RS485_GROWATT translator route
  4. RS485_JKBMS -> RS485_PYLON translator route
  5. RS485_GROWATT -> RS485_PYLON translator route
  6. RS485_PACE -> RS485_PYLON translator route
  7. RS485_VOLTRONIC -> RS485_PYLON translator route
  8. RS485_CHINA_TOWER -> RS485_PYLON translator route
  9. RS485_WOW -> RS485_PYLON translator route
  10. RS485_SEPLOS -> RS485_PYLON translator route
  11. RS485_DALY -> RS485_PYLON translator route
  12. DALY_CAN -> RS485_PYLON translator route
  13. Pylon RS485 bridge route (RS485_PYLON<->RS485_PYLON, RS485_PYLON->CAN_PYLON, or CAN_PYLON->RS485_PYLON)
  14. fallback generic orchestrator route (protocol_id_t based)

Integration Notes

Field Status: EASUN Pylon CAN

As of the 2026-05-30 field session, the EASUN inverter CAN path is validated as a split-port forward route.

Bench setup that worked:

  • JKBMS is configured for PYLON CAN and connected to CAN1.
  • EASUN inverter is configured for PYLON CAN and connected to CAN2.
  • Both CAN ports use the normal Pylon bitrate, 500 kbit/s.
  • The active firmware mode is forward mode: CAN1 -> CAN2.
  • Current field config uses BMS_protocol=PROTOCOL_CAN_PYLON, Inverter_protocol=PROTOCOL_CAN_PYLON, BMS_PORT=1, Inverter_PORT=2.

Observed frames:

  • JKBMS emits normal Pylon frames such as 0x351, 0x355, 0x356, 0x359, 0x35C, 0x35E, 0x370, and 0x371.
  • 0x35E identifies the source as JK-BMS.
  • EASUN emits repeated 0x305 [00 00 00 00 00 00 00 00] frames when its CAN hardware is healthy.

Important hardware finding:

  • The initial "EASUN is silent/dead" symptom was caused by the inverter CAN transceiver hardware, not by the Pylon CAN firmware path.
  • After the inverter CAN transceiver was repaired, EASUN traffic was visible and the direct forward route was accepted.

Current forwarding rule:

  • The firmware forwards the JKBMS Pylon CAN data directly.
  • No voltage division/scaling is active in the field config (CAN_FORWARD_PYLON_16S_TO_8S_ENABLE=0), even though EASUN is a 24V inverter.
  • The optional 16S->8S scaler remains behind the compile-time macro if a future inverter test proves it is needed.
  • Do not clamp live forwarded voltage/current/SOC limits unless the inverter rejects the direct JKBMS values; these values can be adjusted on the JKBMS side.

Fake-data behavior:

  • Web Fake Inverter Data now affects Pylon CAN forward mode, not only synthetic bridge/responders.
  • In forward mode, fake data edits outgoing Pylon CAN frames before transmission to the inverter. The most important frame for EASUN behavior is 0x355 (SOC/SOH).
  • Setting fake SOC=0% was field-confirmed to influence EASUN behavior.
  • If fake SOC=0% makes EASUN stop/sleep, CAN TX failures or no-ACK counters on the inverter-facing bus can be expected during that test.
  • Fake data is runtime-only. Reboot, reset, or flashing clears it and it must be reapplied from the web UI or /api/fake_bms.

Field Status: JK Pylon RS485 to EASUN Pylon CAN

As of the 2026-06-03 field session, a JK BMS configured for PYLON RS485 can feed a Pylon CAN inverter path through the bridge.

Bench setup that worked:

  • JK BMS is configured for PYLON RS485 at 9600 bps and connected to RS485_1.
  • Inverter side is configured as CAN_PYLON on CAN2.
  • Firmware route: MODE_BRIDGE, PROTOCOL_RS485_PYLON -> PROTOCOL_CAN_PYLON.
  • Current config.h defaults are set for this bench route when NVS is empty or invalid. Normal boots load the runtime settings saved by the web UI/API from NVS.

Validated live values:

  • /api/settings after reboot reported bms_line=RS485, bms_protocol=RS485_PYLON, bms_port=1, inverter_line=CAN, inverter_protocol=CAN_PYLON, inverter_port=2.
  • /api/telemetry reported fresh RS485_1 / RS485_PYLON data with SOC=100%, pack voltage around 57.14..57.15 V, cell max/min around 3.573/3.571 V, and Pylon status 0xC0.
  • Serial logs showed valid 0x61 and 0x63 Pylon RS485 responses with chk=OK, followed by Pylon CAN inverter TX on CAN2.
  • The firmware can parse Pylon 0x42 cell-information responses and publish the full per-cell voltage list when a BMS exposes that frame. The tested JK PYLON RS485 profile did not expose it: 0x42 with FF, 00, 01, or an empty payload was rejected on the live 0x02 address with response code 0x04; the other tested Pylon pack addresses did not answer. For this JK profile the UI/API therefore shows only the 0x61 cell max/min values, not cells_v[]. Use JKBMS_MODBUS or JKBMS_RS485_NATIVE on the BMS side, plus an inverter-facing route such as RS485_JKBMS -> CAN_GROWATT, when full cell voltages are required in telemetry.
  • Pylon-compatible RS485 batteries can expose all-cell telemetry through CID2=0x42; the active probe now tries the aggregate FF request, the discovered response address, the low address nibble, 01, 00, and an empty payload. The tested Seplos Pylon profile replied to 0x42 on address 0x12 with an OK frame but no payload for those request forms, so its web/API telemetry currently remains limited to 0x61 cell max/min values.

Implementation details that matter:

  • The active Pylon RS485 probe discovers the live BMS response address (0x02 on the tested JK setup) and then keeps using that address instead of cycling slowly through every candidate address.
  • When a BMS is swapped on the same RS485 port, the probe drops the old preferred Pylon address after stale traffic or repeated timeouts and resumes address scanning. This was needed after swapping from a JK Pylon device to a Seplos Pylon device, where Seplos responded on 0x12.
  • JK-style Pylon RS485 0x61 responses can encode the first voltage word as a raw millivolt-like pack value. The firmware normalizes that value before web telemetry and Pylon CAN transmission, so 0xDF34 becomes about 57.14 V, not 571.4 V.
  • PYLON_RS485_SOURCE_STALE_MS is 10000 ms. If the RS485 source disappears, the Pylon CAN sender stops after this freshness window instead of replaying stale data.

Field Status: Daly RS485 to EASUN Pylon CAN

As of the 2026-05-30 field session, the Daly 24V pack can drive the EASUN inverter through the bridge:

  • BMS side: Daly proprietary RS485 on RS485_1.
  • Inverter side: EASUN configured for PYLON CAN on CAN2.
  • Firmware route: MODE_BRIDGE, PROTOCOL_RS485_DALY -> PROTOCOL_CAN_PYLON.
  • This remains a validated historical bench route; current config.h defaults are now set to the JK Pylon RS485 to Pylon CAN route above.

Validated live values:

  • Daly RS485 decode: 8 cells, pack voltage around 28.29..28.31 V, SOC=99.2%, current 0.0 A, charge/discharge enabled, no alarms.
  • Pylon CAN sender on CAN2: SOC=99%, pack around 28.29 V, status 0xC0.
  • EASUN leaves fault when the bridge is transmitting fresh Daly-derived Pylon CAN frames.

Important interpretation:

  • A previous 58 V Pylon CAN snapshot on CAN1 was not Daly data. It came from the old CAN_PYLON -> CAN_PYLON forward setup and should not be used to infer Daly CAN behavior.
  • Daly remains proven here as an RS485 source. Daly proprietary CAN is still experimental/no-ACK on the tested hardware.

Disconnect behavior:

  • The Pylon CAN sender must not keep EASUN alive with stale data.
  • When Daly disappears, DALY_RS485_SOURCE_STALE_MS is 10000 ms. After that, the sender stops transmitting and logs Pylon CAN inverter sender has no fresh BMS model yet.
  • This was field-tested by disconnecting the BMS; TX stopped instead of replaying the last valid Daly packet.

Known Field Issue: Seplos RS485

As of the 2026-05-24 field session, the Seplos RS485 issue was traced to a hardware-layer requirement: the tested Seplos BMS does not provide RS485 bias resistors on its interface. The bridge hardware used during testing also does not provide enough fail-safe bias on that bus, so the idle RS485 line can float. In that state the firmware sees noise-like bytes or short invalid chunks even though the same Seplos BMS communicates normally with an inverter that provides proper bus bias.

This is a hardware compatibility issue, not primarily a Pylon/Seplos protocol decoder problem.

Observed on the bench:

  • Seplos communicates with the inverter when connected directly.
  • With the bridge configured as RS485_PYLON <-> RS485_PYLON, the inverter sends valid Pylon requests on RS485_2 (0x61 and 0x63), and the firmware forwards those requests to RS485_1.
  • RS485_1 raw captures after forwarding do not contain a valid Pylon ASCII frame (~...), a valid Seplos ASCII frame, or a coherent Modbus RTU response. Captured bytes were mostly 00, FF, 05, EE, and other non-frame data.
  • The same result was observed with RS485_1 in ESP-IDF half-duplex mode, manual direction control, and inverted manual direction control.
  • Active Seplos proprietary polling at 9600 also did not produce valid responses; only single-byte or short non-frame raw chunks were captured.
  • Adding external RS485 bias resistors to the Seplos-facing bus made the link behave normally enough for valid Pylon-style Seplos responses to be captured and decoded.
  • With the biased Seplos link, 0x61, 0x62, and 0x63 Pylon-compatible responses decode correctly on address 0x12. 0x42 cell-information probes using FF, the discovered address (12), low nibble (02), 01, 00, and empty payload returned OK/no-payload frames, so this Seplos Pylon profile did not expose full per-cell voltages during the field test.

Hardware requirement / diagnostic recommendation:

  • The Seplos-facing RS485 bus must have a fail-safe bias network. Do not rely on the Seplos BMS to provide bias.
  • Add bias resistors on the bridge board revision, or fit external bias on the Seplos RS485 pair during bench testing.
  • Termination alone is not a substitute for bias; the idle A/B state must be driven to a known level.
  • Keep RS485_2 as the known-good inverter side unless the hardware wiring is intentionally changed.
  • If Seplos appears to work when connected directly to the inverter but not via the bridge, check RS485 bias before changing protocol code, baud rate, UART inversion, or direction-control settings.

Experimental Field Status: Daly CAN

As of the 2026-05-30 field session, DALY_CAN is implemented as a native CAN poller, but it is not live-validated with the tested Daly BMS.

Protocol assumptions currently used by the firmware:

  • CAN bitrate is 250 kbit/s.
  • The request identifier is extended CAN ID 0x18{DataID}{BMS_ID}40.
  • The tested hardware uses BMS_ID = 1, so the SOC/current/voltage request is 0x18900140.
  • The expected response for that request is 0x18904001.
  • Requests use 8 reserved data bytes, matching datasheets/daly-can-communications-protocol-v1-0-pr_69416dce77488f5846f10633ac80e389.pdf.

Additional compatibility test already tried:

  • A DLC-0 request was tested because the public dbus-serialbattery discussion #561 shows examples such as cansend can0 18950140#.

Observed on the bench:

  • CAN1 and CAN2 were both tested at 250 kbit/s.
  • The request ID was logged as 0x18900140.
  • No valid Daly CAN frames were received.
  • TWAI status showed a repeated no-ACK pattern: txErr=128, increasing txFail/bus error count, rxErr=0, and rxMiss=0.

Current interpretation:

  • The firmware-side protocol framing matches the available Daly CAN datasheet and the public Linux CAN examples.
  • The remaining failure looks below the decoder/protocol layer: CAN wiring, termination/common ground, BMS CAN enable/profile, direct BMS CAN port versus Daly interface board, or a Daly unit whose labelled CAN port is not active.
  • Do not spend more protocol-debug time on Daly CAN until a USB-CAN or inverter capture proves that the BMS ACKs/responds on the tested CAN pair.

JKBMS_MODBUS -> RS485_PYLON

For generic BMS sources such as JKBMS_MODBUS, the synthetic Pylon 0x63 status byte must stay conservative.

What we found during field debugging:

  • the inverter accepted the bridge immediately when the web Fake Inverter Data override was active
  • the same inverter stayed in fault with live JK data even when voltage, SOC, and current looked valid
  • the decisive difference was the synthetic Pylon 0x63 status byte

Required rule:

  • when the source is generic/non-native Pylon and there are no explicit native Pylon charge/discharge bits available, do not project the JK balance flag into Pylon 0x63
  • default the synthetic status to 0xC0 (charge + discharge enabled) instead of 0xE0

Why this matters:

  • projecting generic balance=1 produced 0xE0
  • the affected inverter accepted 0xC0 but faulted on 0xE0

Implementation reference:

  • main/protocols/pylon/pylon_rs485_bridge.c
  • buildCanDerivedInfo63(...)

Additional robustness kept in place:

  • JKBMS cellAvgMv is rejected as a pack-voltage source when it is inconsistent with decoded cell min/max values in the same snapshot
  • fallback pack voltage is then derived from decoded cell extremes, avoiding false jumps caused by noisy or invalid average-cell registers

Protocol IDs and Line IDs

Defined in main/config.h:

  • LINE_CAN = 1
  • LINE_RS485 = 2
  • PROTOCOL_CAN_GROWATT = 1
  • PROTOCOL_RS485_GROWATT = 2
  • PROTOCOL_RS485_PYLON = 3
  • PROTOCOL_CAN_PYLON = 4
  • PROTOCOL_CAN_DEYE = 5
  • PROTOCOL_RS485_JKBMS = 6
  • PROTOCOL_CAN_GOODWE = 7
  • PROTOCOL_CAN_SOFAR = 8
  • PROTOCOL_CAN_SMA = 9
  • PROTOCOL_CAN_VICTRON = 10
  • PROTOCOL_RS485_PACE = 11
  • PROTOCOL_RS485_JKBMS_NATIVE = 12
  • PROTOCOL_RS485_VOLTRONIC = 13
  • PROTOCOL_RS485_CHINA_TOWER = 14
  • PROTOCOL_RS485_WOW = 15
  • PROTOCOL_RS485_JKBMS_115200 = 16
  • PROTOCOL_RS485_PYLON_115200 = 17
  • PROTOCOL_CAN_JKBMS_250K = 18
  • PROTOCOL_RS485_SEPLOS = 19
  • PROTOCOL_RS485_SEPLOS_19200 = 20
  • PROTOCOL_RS485_DALY = 21
  • PROTOCOL_CAN_DALY = 22

Baud-rate / bitrate detail:

  • PROTOCOL_RS485_JKBMS and PROTOCOL_RS485_PYLON use 9600
  • PROTOCOL_RS485_JKBMS_115200 and PROTOCOL_RS485_PYLON_115200 use 115200
  • the 115200 variants reuse the same protocol decoders/responders; only the selected RS485 port baud changes
  • PROTOCOL_RS485_SEPLOS_19200 uses 19200; PROTOCOL_RS485_SEPLOS and PROTOCOL_RS485_DALY use 9600
  • PROTOCOL_CAN_JKBMS_250K and PROTOCOL_CAN_DALY reinitialize the selected CAN port at 250 kbit/s; other CAN profiles currently default to 500 kbit/s

Folder Structure (AI-Oriented)

Top-level:

  • main/ active firmware component
  • build/ ESP-IDF build artifacts (ignored)
  • vendor/ local/vendor files (ignored)
  • Protocol_Tasks/ legacy/auxiliary material

Inside main/:

  • main.c
  • app entrypoint (app_main), initializes drivers, mode manager, web task
  • config.h, config.c
  • compile-time switches, pin mapping, protocol/line IDs, exclusion lists, LED task
  • runtime_settings.h/.c
  • NVS-backed runtime settings (bridge_cfg namespace)
  • orchestrator/
  • route decision + queue orchestration across BMS and inverter tasks
  • modes/
  • mode manager + CAN forward/sniffer helper
  • decoders/
  • CAN_Decoder cache/snapshot/decode
  • modbusDecoder stream decoder and register cache
  • protocols/
  • active protocol implementations and register maps
  • Drivers/
  • CAN + RS485 low-level init and TX helpers
  • Web_interface/
  • web server, web UI, JSON API, bridge compatibility layer
  • protocols/rs485_growatt/rs485_growatt_bridge.c/.h
  • specialized translator/responder for Growatt-oriented RS485 inverter side
  • old/
  • archived legacy code (not part of active CMake sources)

Active vs Legacy Code Areas

Active source tree is defined by main/CMakeLists.txt and currently uses:

  • main/protocols/... (lowercase)
  • main/modes/...
  • main/decoders/...
  • main/orchestrator/...

Legacy/cleanup leftovers still present in repo:

  • main/Protocols/, main/BMS_Protocols/, main/Inverter_Protocols/, main/old/

These are useful for reference/history, but are not the primary active implementation path.

Protocol Implementation Status

main/protocols/growatt/

  • growatt_bms_task.c: adapter/wrapper over rs485_growatt BMS task
  • growatt_inverter_task.c: active CAN transmit task (0x322)
  • growatt_registers_map.h/.c: register + frame mapping constants

main/protocols/rs485_growatt/

  • active Modbus poller + decoder integration for Growatt BMS over RS485
  • decodes pack voltage, SOC, the single live pack temperature exposed by 0x0018, per-cell voltages, cell min/max, Growatt 0x0014 error/protection bits, 0x0022 warning bits, and raw 0x0013 status flags when the BMS exposes them
  • web telemetry intentionally shows only one temperature for this protocol; the Growatt RS485 status block does not expose separate MOS/T1/T2/T4/T5 live temperatures

main/protocols/jkbms_modbus/

  • active JK BMS Modbus poller + decoder + rich snapshot extraction
  • 0x12A0..0x12A1 is exposed as an alarm/status candidate only; live hardware has shown stable non-zero values there while the JK display reports no alarms, so these bits are not propagated to UI protections/alarms/warnings or inverter-facing alarm masks until a real fault-state capture validates them

main/protocols/jkbms_rs485/

  • experimental JK BMS native RS485 poller for binary frames starting with 4E 57
  • decodes pack voltage/current/power, SOC, SOH fallback, cycles, capacity, per-cell voltages, cell min/max/avg/delta, tube/MOS temperature, battery temperature, box temperature, raw alarm bits, charge/discharge MOS status, and balance status
  • supports RS485_JKBMS -> RS485_PYLON and RS485_JKBMS -> RS485_GROWATT bridge-mode translation through the shared battery model
  • field note: on the tested JK BMS setup, the same RS485 port responds correctly to JKBMS_MODBUS at 9600, but does not respond to the native 4E 57 read-all request, so JKBMS_MODBUS remains the recommended setting for that hardware

main/protocols/pace_modbus/

  • active PACE BMS RS485 Modbus V1.3 poller + decoder
  • supports RS485_PACE -> RS485_PYLON bridge-mode translation
  • web/API telemetry includes pack values, all cell voltages, individual temperature registers, protections, alarms/faults, warnings, raw status flags, and Pylon status output

main/protocols/rs485_growatt/

  • active Growatt/SPF Modbus poller with signed centiamp pack current, pack limits/status, warning/error fields, and individual cell registers
  • field-tested with Seplos V3 selector 10 (Growatt SPF Modbus RS485 RTU): the web/API exposes all 16 cells and the generic route forwards the battery model to CAN_PYLON

main/protocols/voltronic_modbus/

  • active Voltronic RS485 Modbus poller + decoder for JK UART profile 007 - Voltronic_Inverter_and_BMS_485
  • polls the Seplos-compatible public Voltronic core registers as single 0x03 reads; the tested Seplos firmware rejects broad reads but answers single-register requests with a 16-bit byte-count response (01 03 00 02 ... CRC)
  • keeps decoding support for standard Modbus responses, Voltronic function-first responses, and JK-compatible word-count responses in the shared register cache
  • supports RS485_VOLTRONIC -> RS485_PYLON bridge-mode translation through the shared synthetic Pylon responder path
  • web/API telemetry includes the confirmed live Seplos Voltronic pack values (SOC, voltage/current, capacity, charge/discharge limits/status) and raw protocol flags; the tested Seplos Voltronic profile did not expose per-cell voltages through this map

main/protocols/china_tower_modbus/

  • active China Tower shared battery cabinet RS485 Modbus poller + decoder for JK UART profile 008
  • polls the observed live map around 0x0000 for pack voltage, cell count, SOC, and runtime fields, with per-cell millivolts starting at 0x0009; raw candidate warning/protection/status fields are captured at 0x0019..0x001B
  • supports RS485_CHINA_TOWER -> RS485_PYLON bridge-mode translation through the shared synthetic Pylon responder path
  • web/API telemetry includes pack voltage, SOC, all cell voltages, cell min/max/delta, and the three live temperature registers observed in the compact summary block; only MOS, Temp 1, and Temp 2 are labeled for this profile because the exact battery-sensor assignment is not yet confirmed
  • named alert bits for China Tower profile 008 are not confirmed yet; non-zero raw candidate warning/protection bits are surfaced as unknown bits until they can be correlated with the JK app

main/protocols/wow_modbus/

  • active WOW RS485 Modbus poller + decoder for JK UART profile 009 - WOW_RS485_Modbus_V1.3
  • public WOW/SRNE register documentation is sparse, so the first implementation deliberately uses the PACE-compatible V1.3 register blocks as a separate protocol path instead of sharing cache interpretation with other pollers
  • supports RS485_WOW -> RS485_PYLON bridge-mode translation through the shared synthetic Pylon responder path
  • supports RS485_WOW -> RS485_GROWATT bridge-mode translation through the shared Growatt RS485 responder fed from the universal battery model
  • web/API telemetry includes pack values, all cell voltages, PACE-style temperature labels, warning/protection/fault/status fields, and raw diagnostics when the source exposes them
  • field validation on a BMS configured to JK UART profile 009 confirmed stable pack, cell, temperature, and Pylon-responder behavior; alert naming remains conservative until more fault-state captures are available

main/protocols/daly_rs485/

  • active Daly proprietary RS485 poller + decoder at 9600
  • decodes pack voltage/current/power, SOC, SOH, cycles, capacity, cell extremes, per-cell voltages where exposed, temperature sensors, MOS state, balance state, and failure/status bits
  • supports RS485_DALY -> RS485_PYLON bridge-mode translation through the shared synthetic Pylon responder path
  • field validation confirmed that telemetry remains available after the PC Daly application is stopped, and stale-source timeout is 10s

main/protocols/daly_can/

  • experimental Daly proprietary CAN poller + decoder at 250 kbit/s
  • uses extended request IDs in the Daly format 0x18{DataID}{BMS_ID}40, with BMS_ID=1 on the field hardware
  • uses the same Daly snapshot/model path as DALY_RS485, so successful CAN telemetry can feed DALY_CAN -> RS485_PYLON
  • not live-validated yet: the 2026-05-30 field BMS did not ACK either DLC-8 datasheet requests or DLC-0 Linux CAN example requests on CAN1/CAN2

main/protocols/pylon/

  • pylon_rs485_bridge.c: active bridge/responder for Pylon RS485 routes, including active BMS-side probing/parsing, optional Pylon 0x42 cell-information decoding when the source exposes it, and RS485_PYLON -> CAN_PYLON model publication
  • pylon_can_protocol.c: active CAN snapshot decode for Pylon frames
  • pylon_inverter_task.c: active Pylon CAN sender from the shared battery model for routes such as DALY_RS485 -> CAN_PYLON and RS485_PYLON -> CAN_PYLON
  • pylon_bms_task.c: scaffold placeholder for future dedicated Pylon BMS task
  • pylon_registers_map.h: canonical register map header

main/protocols/deye/

  • deye_can_protocol.c: active CAN snapshot decode for Deye frame set

main/protocols/goodwe|sofar|sma|victron/

  • currently map/header-focused; not full dedicated task pipelines
  • used as protocol constants and integration hints for translator/routing logic

Adding a New Protocol (AI-Safe Rules)

If Codex Web (or any contributor) adds a new protocol, use this mandatory layout:

  • folder: main/protocols/<protocol_name>/
  • required file: main/protocols/<protocol_name>/<protocol_name>_registers_map.h
  • optional companion: main/protocols/<protocol_name>/<protocol_name>_registers_map.c
  • protocol task files, if needed:
  • <protocol_name>_bms_task.c/.h
  • <protocol_name>_inverter_task.c/.h
  • <protocol_name>_can_protocol.c/.h
  • <protocol_name>_modbus_poller.c/.h

Minimum integration checklist (so files are actually used):

  1. add new source files in main/CMakeLists.txt
  2. include only canonical map header *_registers_map.h from runtime code
  3. add/extend protocol ID in main/config.h (if new ID is needed)
  4. update validation in main/runtime_settings.c
  5. update protocol selection UI lists in main/Web_interface/web_interface.c
  6. update routing/protocol mapping in main/orchestrator/orchestrator.c
  7. update decoders/translators if the new protocol needs telemetry, bridging, or synthetic responses

Telemetry Quality Standard for New Protocols

PACE_RS485_MODBUS_V1.3 -> RS485_PYLON is the reference for how new protocol integrations should look and behave in the web UI/API.

For every new BMS protocol, aim to expose a complete, inspectable telemetry snapshot:

  • runtime/source/protocol validity, age, stale state, and inverter-facing status
  • pack voltage, current, power, SOC, SOH, cycle count, and capacity fields when the source protocol provides them
  • cell min/max, delta, indexes, average, and the full per-cell voltage list instead of only synthesized extremes
  • real temperature registers mapped to their source labels; do not copy one generic/average temperature into every displayed sensor slot
  • protections, alarms/faults, warnings, balance state, and raw status/protocol flags decoded into human-readable names where the protocol map is known
  • unknown bits should still be visible as raw hex/unknown bit labels so field debugging can continue without firmware changes

Validation expectation:

  1. add or extend host tests for the register/frame decoder, including cell arrays, temperature arrays, warning/protection/fault bits, and status flags
  2. run the Python/host test suite
  3. build the ESP-IDF firmware
  4. flash the board when hardware is available
  5. verify /api/telemetry and the web UI against the vendor/BMS app screenshots or live source data

Avoid temporary UI polish that hides missing decode work. If the source protocol exposes a value, prefer decoding and showing it explicitly; if it is not known yet, show None, -, or a raw diagnostic value instead of fabricating a plausible value.

Important Core Files and Responsibilities

  • main/main.c
  • startup sequence and mode start
  • main/modes/mode_manager.c
  • behavior for bridge/forward/sniffer
  • main/orchestrator/orchestrator.c
  • bridge route decision and task orchestration
  • main/protocols/rs485_growatt/rs485_growatt_bridge.c
  • CAN->RS485 Growatt responder; JKBMS->RS485 Growatt responder; synthetic snapshot export
  • main/protocols/pylon/pylon_rs485_bridge.c
  • Pylon-specific RS485 responder/forwarder and CAN->RS485 synthetic support
  • main/decoders/CAN_Decoder.c
  • CAN cache, protocol-aware snapshots, universal model updates
  • main/decoders/modbusDecoder.c
  • Modbus stream framing + register cache + decode snapshots
  • main/Web_interface/web_interface.c
  • web UI and API endpoints
  • main/Web_interface/bridge_compat.c
  • compatibility facade between telemetry producers and web API

Data Model

Shared data structures:

  • bms_decoded_packet_t in main/orchestrator/protocol_types.h
  • minimal normalized packet between BMS-side and inverter-side tasks
  • universal_battery_model_t in main/protocols/common/universal_battery_model.h
  • broader cross-protocol model used especially by synthetic bridges
  • bridgeTelemetrySnapshot_t in main/Web_interface/web_bridge_api.h
  • web-facing telemetry snapshot

Web Interface

The ESP32 serves a responsive, dependency-free web UI directly from the firmware. It is organized into three tabs: Telemetry, Settings, and Logs. The page refreshes runtime data through the JSON/text endpoints documented in the next section.

The telemetry view summarizes the active source and protocol, pack voltage, current and power, SOC/SOH, cycle count, cell extrema and delta, temperatures, individual cell voltages, and decoded protections, alarms, and warnings.

Web UI Telemetry tab with pack, cell, and temperature data

The settings view selects the runtime mode, BMS/inverter lines and protocols, physical ports, Wi-Fi credentials, and web-server port. Its route preview is updated before Apply; accepted settings are saved in NVS and applied at runtime.

Web UI Settings tab with bridge route selection

The logs view exposes the latest protocol-aware decoded snapshot for field diagnostics, including frame families, cell values, pack data, limits, temperatures, alarms, and protocol status when supplied by the active decoder.

Web UI Logs tab with decoded Pylon data

Note: The Telemetry and Logs screenshots use an injected diagnostic dataset so all UI regions are populated. They demonstrate the interface layout and are not a recording of a live BMS/inverter transaction.

Web API

Implemented endpoints:

  • GET /
  • in-device HTML UI (Telemetry / Settings / Logs tabs)
  • GET /api/telemetry
  • JSON telemetry snapshot
  • GET /api/settings
  • JSON runtime settings
  • POST /api/settings
  • saves runtime settings to NVS and applies them
  • GET /api/logs
  • text decoded logs snapshot
  • GET /api/fake_bms
  • JSON runtime fake inverter data model
  • POST /api/fake_bms
  • enables/disables runtime fake inverter data and updates override values

Runtime settings are persisted in NVS namespace bridge_cfg.

Logic Analyzer Tools

Optional PulseView/libsigrokdecode helpers live under tools/sigrok/.

Decoder development rule:

  • this firmware repository is the workbench/source of truth for all in-progress PulseView decoders

  • develop, test, and refine decoders under tools/sigrok/decoders

  • copy a decoder to the separate sigrok-pylon-bms-decoders repository only after it is validated together on captures/hardware and explicitly accepted for publication

  • use tools/sigrok/copy-decoder-to-public-repo.ps1 -DecoderName <decoder> for that publication copy; do not use raw recursive copy commands, because the helper skips __pycache__ and .pyc artifacts

  • for live debugging, launch PulseView through tools/sigrok/start-pulseview.ps1 or the PulseView Workbench Decoders shortcut so the active local workbench decoder set is used

  • tools/sigrok/decoders/pylon_rs485/ decodes Pylon-compatible RS485 ASCII frames stacked above the built-in uart decoder.

  • tools/sigrok/decoders/growatt_rs485/ decodes Growatt-compatible RS485 Modbus RTU frames stacked above the built-in uart decoder, including CRC, request/response register ranges, status/warning/protection fields, and the 0x0071..0x0080 cell-voltage block.

  • tools/sigrok/decoders/pylon_can/ decodes Pylon-compatible Classic CAN frames directly from a CAN/RXD or digitized CANH/CANL logic capture.

  • tools/sigrok/decoders/growatt_can/ decodes Growatt-compatible Classic CAN frames directly from a CAN/RXD or digitized CANH/CANL logic capture, including 0x311..0x323 pack, limit, alert, cell, temperature, and metadata frames.

  • tools/sigrok/decoders/jkbms_modbus/ decodes JK BMS RS485 Modbus poller frames stacked above uart, including the 0x1200..0x12B8 runtime register map used by JKBMS_MODBUS (RS485 Poller, 115200).

  • tools/sigrok/decoders/jkbms_rs485_native/ decodes JK native binary RS485 frames (4E 57 ...) stacked above uart, including the 0x79 all-cell voltage list, pack values, temperatures, alarm bits, and status flags.

  • tools/sigrok/decoders/jkbms_can/ decodes JK native CAN V2.0 frames at 250 kbit/s, including 0x02F4, 0x04F4, 0x05F4, 0x07F4, extended 0x18E*28F4 cell-voltage frames, and 0x18F228F4 temperatures.

  • Typical analyzer settings are 9600 baud, 8N1, LSB-first; line inversion depends on whether the probe is on TTL RX/TX or on the RS485 A/B pair.

  • For the JK app profile 001 - JK BMS RS485 Modbus V1.0, use the jkbms_modbus decoder at 115200 8N1; for profile 013, use the same decoder at 9600 8N1.

  • The Pylon RS485 decoder validates Pylon length/checksum fields and decodes common 0x61, 0x62, and 0x63 payloads, including the important 0x63 status byte (0xC0 = charge/discharge enabled, balance off).

  • For JK Modbus captures, use the local register table in main/protocols/jkbms_modbus/jkbms_modbus_registers_map.h; for JK native RS485 captures, use the binary data-ID map in the decoder/firmware parser instead of treating the bytes as Modbus registers.

  • See tools/sigrok/README.md for installation and PulseView usage.

Build and Run

Use ESP-IDF v6.0.1 and target esp32c6.

Before the first local build, create a private secrets file for your Wi-Fi credentials:

bash
cp main/secrets.example.h main/secrets.h

Typical shell flow:

bash
. /path/to/esp-idf/export.sh
idf.py set-target esp32c6
idf.py build
idf.py -p <PORT> flash monitor

Notes:

  • project name in CMake is project-name
  • this repo currently enables idf_build_set_property(MINIMAL_BUILD ON)
  • flash size is configured as 8MB
  • the generated flash command should include --flash-size 8MB
  • the custom partition table is partitions_8mb_singleapp.csv

Local Windows / Codex Access Notes

These notes are for future Codex sessions on the current Windows development machine, so they do not have to rediscover the local ESP-IDF setup.

Known local setup:

  • workspace: C:\Users\Admin\Documents\test-CAN+RS485
  • ESP-IDF path used by the working build: C:\esp\v6.0.1\esp-idf
  • ESP-IDF Python: C:\Espressif\tools\python\v6.0.1\venv\Scripts\python.exe
  • Ninja: C:\Espressif\tools\ninja\1.12.1\ninja.EXE
  • ESP32-C6 serial port used during field tests: COM11
  • web UI used during field tests: http://192.168.141.151/
  • opening the serial monitor can reset the board; runtime-only fake inverter data must be reapplied after reset/flash
  • runtime settings are saved in ESP-IDF NVS (bridge_cfg) by /api/settings; RUNTIME_SETTINGS_FORCE_DEFAULTS should stay 0 except for deliberate diagnostics

Fast incremental build from a Codex/PowerShell shell:

powershell
$env:IDF_PATH='C:\esp\v6.0.1\esp-idf'
$env:PATH='C:\Espressif\tools\ccache\4.12.1\ccache-4.12.1-windows-x86_64;C:\Espressif\tools\riscv32-esp-elf\esp-15.2.0_20251204\riscv32-esp-elf\bin;C:\Espressif\tools\ninja\1.12.1;C:\Espressif\tools\cmake\4.0.3\bin;C:\Espressif\tools\python\v6.0.1\venv\Scripts;' + $env:PATH
& 'C:\Espressif\tools\ninja\1.12.1\ninja.EXE' -C build

Known harmless build warnings in the Codex sandbox:

  • fatal: detected dubious ownership in repository at 'C:/esp/v6.0.1/esp-idf'
  • ESP_ROM_ELF_DIR environment variable is not defined

The build can still complete and generate build\project-name.bin; verify the final Ninja result and binary-size line before assuming failure.

Fast flash without rebuilding:

powershell
& 'C:\Espressif\tools\python\v6.0.1\venv\Scripts\python.exe' 'C:\esp\v6.0.1\esp-idf\components\esptool_py\esptool\esptool.py' --chip esp32c6 -p COM11 -b 460800 --before default-reset --after hard-reset write_flash --flash-mode dio --flash-freq 80m --flash-size 8MB 0x0 build\bootloader\bootloader.bin 0x8000 build\partition_table\partition-table.bin 0x10000 build\project-name.bin

Serial monitor options:

powershell
& 'C:\Espressif\tools\python\v6.0.1\venv\Scripts\python.exe' 'C:\esp\v6.0.1\esp-idf\tools\idf_monitor.py' -p COM11 -b 115200 --toolchain-prefix riscv32-esp-elf- --target esp32c6 'C:\Users\Admin\Documents\test-CAN+RS485\build\project-name.elf'

Quick fake-SOC API test from PowerShell:

powershell
$payload = @{
  enabled = $true
  pack_voltage_v = 57.16
  pack_current_a = 0
  soc_pct = 0
  soh_pct = 100
  cycles = 0
  charge_voltage_limit_v = 57.6
  charge_current_limit_a = 100
  discharge_current_limit_a = 100
  cell_max_v = 3.58
  cell_min_v = 3.57
  cell_max_idx = 1
  cell_min_idx = 1
  temp_mos_c = 25
  temp_t1_c = 25
  temp_t2_c = 25
  temp_t4_c = 25
  temp_t5_c = 25
  charge_enabled = $true
  discharge_enabled = $true
  balance_enabled = $false
  protocol_state = 192
} | ConvertTo-Json
Invoke-RestMethod -Uri 'http://192.168.141.151/api/fake_bms' -Method Post -Body $payload -ContentType 'application/json'

For a short non-interactive log capture that closes the port automatically:

powershell
@'
import serial
import sys
import time

s = serial.Serial('COM11', 115200, timeout=0.2)
end = time.time() + 8
while time.time() < end:
    data = s.read(4096)
    if data:
        sys.stdout.write(data.decode('utf-8', 'replace'))
        sys.stdout.flush()
s.close()
'@ | & 'C:\Espressif\tools\python\v6.0.1\venv\Scripts\python.exe' -

If COM11 reports Access is denied, a previous monitor process is usually still holding the port. Check for ESP-IDF Python monitor processes before starting a new monitor. During field testing, stopping stale C:\Espressif\tools\python\v6.0.1\venv\Scripts\python.exe monitor processes released the port.

Useful web/API checks:

powershell
(Invoke-WebRequest -Uri http://192.168.141.151/api/settings -UseBasicParsing -TimeoutSec 8).Content
(Invoke-WebRequest -Uri http://192.168.141.151/api/telemetry -UseBasicParsing -TimeoutSec 8).Content
(Invoke-WebRequest -Uri http://192.168.141.151/api/logs -UseBasicParsing -TimeoutSec 8).Content

Current known-good RS485 sanity route on the field bench:

  • bms_line=RS485, bms_protocol=RS485_PYLON, bms_port=1
  • inverter_line=RS485, inverter_protocol=RS485_PYLON, inverter_port=2
  • this route produced valid Pylon 0x61, 0x62, and 0x63 decoded logs on RS485_1, confirming that the physical RS485 port and direction control work

Configuration Notes

Most compile-time toggles are in main/config.h, including:

  • pin mapping for CAN and RS485
  • decoder verbosity flags
  • bridge/forward feature flags
  • RS485 half-duplex behavior flags
  • default Wi-Fi/web settings

Local Wi-Fi credentials must live in main/secrets.h, which is ignored by Git. Start from the public template:

bash
cp main/secrets.example.h main/secrets.h

Then edit main/secrets.h for your device/network. If the local secrets file is missing, the firmware still builds using placeholder values from main/config.h.

Runtime settings from web API/UI override operational route/mode choices.

Public Repository Hygiene

Tracked files should not contain local credentials, machine-specific IDE paths, or generated build artifacts.

  • main/secrets.h is local-only and ignored
  • main/secrets.example.h is the public template
  • .vscode/, build/, managed_components/, .pytest_cache/, and pytest-cache-files-*/ are ignored
  • run git status --ignored --short when checking for generated artifacts before making the repository public

Testing

The project has four test layers. GitLab CI runs them as separate jobs, and the local commands below mirror those jobs.

Test Structure

text
tests/
  sanity/
    test_repo_sanity.py
  unit/
    test_can_decoder.c
    test_modbus_decoder.c
    test_route_selection.c
    test_host_unit_coverage.py
    esp_stub/
    host_stubs.c
  integration/
    test_firmware_configuration.py
    test_protocol_fixtures.py
    fixtures/protocol_samples.py
  firmware_build/
    test_build_artifacts.py
  requirements.txt

Python Test Environment

bash
python -m venv .venv
. .venv/bin/activate
python -m pip install -r tests/requirements.txt

On Windows, activate the venv with the matching PowerShell/CMD command for your shell.

Sanity Tests

bash
python -m pytest tests/sanity -v

Sanity tests check repository shape, GitLab CI settings, ESP-IDF image/version pinning, runner tag configuration, test entrypoints, and ignored generated artifacts.

Unit Tests

bash
python -m pytest tests/unit/test_host_unit_coverage.py -v

The host C unit suite compiles and runs CAN decoder, Modbus decoder, and route-selection tests on the host. It also emits gcov data under tests/.build/host_unit/coverage/.

Host unit tests require gcc and gcov. Missing tools skip on developer machines, but fail in CI so coverage cannot silently disappear.

Integration Tests

bash
python -m pytest tests/integration -v

Integration tests verify firmware configuration, protocol constants, repository structure, protocol fixture shape, and Modbus CRC helpers.

Firmware Build Tests

bash
. /path/to/esp-idf/export.sh
idf.py set-target esp32c6
idf.py build
python -m pytest tests/firmware_build -v

Build tests run after idf.py build and verify generated .elf/.bin artifacts, sdkconfig, and binary size.

Coverage Report

After unit tests, generate coverage reports manually with:

bash
python -m gcovr --root . \
  --object-directory tests/.build/host_unit \
  --filter main \
  --filter tests/unit \
  --xml-pretty --output tests/.build/host_unit/coverage/cobertura.xml \
  --html-details tests/.build/host_unit/coverage/html/index.html \
  --print-summary

See tests/README.md for more detailed testing documentation.

Continuous Integration

GitLab CI runs on every commit/merge-request source and is split into these stages:

  1. sanity
  2. unit
  3. integration
  4. build

Jobs:

  • sanity_tests: fast repository and CI checks
  • unit_tests: host C unit tests plus Cobertura/HTML coverage artifacts
  • integration_tests: firmware configuration and protocol fixture checks
  • build_firmware: final ESP32-C6 firmware build plus post-build artifact checks

The pipeline definition lives in .gitlab-ci.yml.

Current CI expectations:

  • ESP-IDF image/version is pinned to espressif/idf:v6.0.1
  • project runner tag is ubuntu
  • preferred executor is a local Linux shell runner
  • IDF_CCACHE_ENABLE=1 and .ccache/ are used for faster rebuilds
  • Python dependencies are installed into .venv for Python-only jobs
  • firmware build job sources ESP-IDF from /home/gitlab-runner/esp/esp-idf/export.sh when running on the local shell runner
  • if cmake/ninja are missing from the ESP-IDF environment, CI installs them into the ESP-IDF Python environment

GitLab Runner Setup

The project currently targets a project runner named ubuntu-runner with tag:

text
ubuntu

Required runner behavior:

  • executor: shell
  • OS: Linux amd64
  • tag: ubuntu
  • runner is allowed to run jobs from this project

Install ESP-IDF for the gitlab-runner user:

bash
sudo -u gitlab-runner -H bash -lc 'mkdir -p ~/esp && cd ~/esp && git clone -b v6.0.1 --recursive https://github.com/espressif/esp-idf.git esp-idf'
sudo -u gitlab-runner -H bash -lc 'cd ~/esp/esp-idf && ./install.sh esp32c6'
sudo -u gitlab-runner -H bash -lc 'cd /tmp && . ~/esp/esp-idf/export.sh && idf.py --version'

The last command should print:

text
ESP-IDF v6.0.1

In GitLab project settings:

  1. Go to Settings > CI/CD > Runners in the GitLab project.
  2. Ensure the project runner is online.
  3. Ensure the runner tag is ubuntu.
  4. Keep Run untagged jobs optional; the CI file explicitly uses the ubuntu tag.
  5. Disable shared/instance runners if you want to avoid GitLab SaaS Docker runners.

Successful local-runner logs should show:

text
on ubuntu-runner
Preparing the "shell" executor
Using Shell executor...

If logs show green-*.saas-linux..., docker+machine, or Pulling docker image, the job is still running on a shared GitLab runner instead of the local shell runner.

AI Onboarding Cheat Sheet (for Codex Web)

If you want an AI coding agent to be productive quickly, give it this context:

  1. active code is what appears in main/CMakeLists.txt
  2. primary runtime routing starts in main/main.c, main/modes/mode_manager.c, and main/orchestrator/orchestrator.c
  3. do not start from main/old unless explicitly asked
  4. protocol code of interest is under main/protocols/
  5. decoders are in main/decoders/
  6. web config/telemetry API is in main/Web_interface/
  7. keep canonical protocol map naming as *_registers_map.h

Suggested first-read file order for AI:

  1. main/config.h
  2. main/runtime_settings.h + main/runtime_settings.c
  3. main/main.c
  4. main/modes/mode_manager.c
  5. main/orchestrator/orchestrator.c
  6. main/protocols/rs485_growatt/rs485_growatt_bridge.c
  7. main/protocols/pylon/pylon_rs485_bridge.c
  8. main/decoders/CAN_Decoder.c
  9. main/decoders/modbusDecoder.c
  10. main/Web_interface/web_interface.c

Known Cleanup Direction

Repository is in active cleanup/refactor:

  • protocol code consolidation under main/protocols/ is ongoing
  • mode files were moved under main/modes/
  • decoders were moved under main/decoders/
  • legacy uppercase protocol folders remain for reference during transition

If you continue cleanup, prefer small mechanical moves + include/CMake fixes, then validate route behavior.

Parts

151
QtyValueFootprintReferences
17100nFCapacitor_SMD:C_0603_1608MetricC1, C2, C19, C27, C31, C33, C35, C37, C38, C40, C43, C45, C47, C49, C51, C52 +1
161uFCapacitor_SMD:C_0805_2012MetricC3, C4, C5, C12, C14, C15, C16, C24, C25, C26, C32, C34, C39, C42, C46, C50
1210Resistor_SMD:R_0603_1608MetricR28, R29, R30, R31, R32, R33, R38, R39, R40, R41, R42, R43
1010uFCapacitor_SMD:C_1206_3216MetricC6, C7, C9, C11, C20, C21, C22, C23, C28, C29
10330Resistor_SMD:R_0603_1608MetricR5, R6, R7, R8, R9, R10, R11, R12, R13, R14
8100mAFuse:Fuse_1206_3216MetricF3, F4, F5, F6, F7, F8, F9, F10
6FerriteBeadInductor_SMD:L_0805_2012MetricFB2, FB3, FB4, FB5, FB6, FB7
410kResistor_SMD:R_0603_1608MetricR1, R2, R18, R24
410uFCapacitor_SMD:C_0805_2012MetricC30, C41, C44, C53
4120Resistor_SMD:R_0603_1608MetricR34, R36, R45, R47
42k2Resistor_SMD:R_0603_1608MetricR35, R37, R44, R46
4ESDA5V3LPackage_TO_SOT_SMD:SOT-23-3D11, D12, D13, D14
4MountingHoleMountingHole:MountingHole_3.2mm_M3H1, H2, H3, H4
4TERMButton_Switch_THT:SW_DIP_SPSTx01_Slide_9.78x4.72mm_W7.62mm_P2.54mmSW2, SW3, SW4, SW5
3LED_GREENLED_SMD:LED_0603_1608MetricD2, D9, D10
210nFCapacitor_SMD:C_0805_2012MetricC36, C48
23v6Diode_SMD:D_SMAD6, D7
25.1kResistor_SMD:R_0603_1608MetricR70, R72
2680Resistor_SMD:R_0603_1608MetricR4, R26
2ADM2582EPackage_SO:SOIC-20W_7.5x12.8mm_P1.27mmU6, U7
2ADM3053Package_SO:SOIC-20W_7.5x12.8mm_P1.27mmU5, U8
2CANConnector_Phoenix_MC:PhoenixContact_MCV_1,5_3-G-3.5_1x03_P3.50mm_VerticalJ2, J5
2GNDTestPoint:TestPoint_Pad_D2.0mmTP2, TP4
2RS485Connector_Phoenix_MC:PhoenixContact_MCV_1,5_3-G-3.5_1x03_P3.50mm_VerticalJ3, J4
2SP4020Diode_SMD:D_SOD-323D1, D5
115uHInductor_SMD:L_Chilisin_BMRF00101040L1
11AFuse:Fuse_1206_3216MetricF1
11kResistor_SMD:R_0603_1608MetricR27
132k4Resistor_SMD:R_0603_1608MetricR23
13V3Jumper:SolderJumper-2_P1.3mm_Bridged_RoundedPad1.0x1.5mmJP2
13v3TestPoint:TestPoint_Pad_D2.0mmTP3
1500mAFuse:Fuse_1206_3216MetricF2
15VPTestPoint:TestPoint_Pad_D2.0mmTP1
1ESP32 RESETButton_Switch_THT:SW_PUSH_6mmSW1
1ESP32-C6-WROOM-1-N8ESP32-C6-WROOM:ESP32C6WROOM1N8IC1
1IO15Button_Switch_THT:SW_DIP_SPSTx01_Slide_9.78x4.72mm_W7.62mm_P2.54mmSW6
1JTAGESHF-105-01-L-D-TH:ESHF10501LDTHJ10
1LOGOSymbol:WEEE-Logo_4.2x6mm_SilkScreenG2
1LOGOSymbol:CE-Logo_8.5x6mm_SilkScreenG1
1MCP16311Package_SO:MSOP-8_3x3mm_P0.65mmU3
1SMAJ5CADiode_SMD:D_SMAD8
1SYM_ESD_SmallSymbol:ESD-Logo_6.6x6mm_SilkScreenSYM1
1SolderJumper_2_OpenJumper:SolderJumper-2_P1.3mm_Open_RoundedPad1.0x1.5mmJP1
1TPD2S017Package_TO_SOT_SMD:SOT-23-6U4
1USB_C_Receptacle_USB2.0_14PConnector_USB:USB_C_Receptacle_GCT_USB4105-xx-A_16P_TopMnt_HorizontalJ1
1VaristorResistor_SMD:R_0805_2012MetricRV1

More from victorstoica114/Invertor_board

1
  • 2 layers45.2 × 82 mmInvertor, the printed circuit board in 3D

    Invertor

    victorstoica114/Invertor_board

    This repository contains an ESP-IDF firmware for an ESP32 board that bridges, translates, decodes, and exposes battery/inverter communication over CAN and RS485.

    8 parts1

Similar boards

  • 2 layers75 × 35 mmCANPower, the printed circuit board in 3D

    CANPower

    RaphWeyman/CANPower

    Accessory power controller for BMW CAN bus bikes

    66 parts10GPL-2.0
  • 4 layers53.3 × 68.6 mmHamShield1, the printed circuit board in 3D

    HamShield1

    EnhancedRadioDevices/HamShield1

    HamShield 1.0 Hardware

    381 parts8
  • 4 layers103 × 126 mmSenzori iradiere, the printed circuit board in 3D

    Senzori iradiere

    cs-pub-ro/smart-solar-irradiance-sensor

    Open-source hardware & software for a smart wireless sensor that measures solar irradiance.

    351 parts
  • 4 layers100 × 66 mmVNA, the printed circuit board in 3D

    VNA

    joshajohnson/vna

    25MHz to 1.25GHz Vector Network Analyser

    254 parts25GPL-3.0
  • 2 layersAtmega32u4-au v1, the printed circuit board in 3D

    Atmega32u4-au v1

    adamws/kle2netlist

    Keyboard's layout json to KiCad netlist

    17 parts7MIT
  • 4 layers38 × 15 mmRuuvilogger reva1, the printed circuit board in 3D

    Ruuvilogger reva1

    ruuvi/ruuvilogger_hw

    You can find RuuviLogger related hardware design files from this repository. Design is almost finished, but not 100% ready. If RuuviLogger project continues, Rev.A version will be probably deprecated.

    93 parts5
  • 4 layers200 × 150 mmMicrowave SDR PCB, the printed circuit board in 3D

    Microwave SDR PCB

    artificer123/Microwave_SDR_PCB

    Collection of files used in development of a Xilinx Zynq based SDR with transverters for the V/UHF bands

    481 parts2
  • 2 layers197.1 × 44.7 mmCearusTab, the printed circuit board in 3D

    CearusTab

    Damocles2/CaerusTab

    A well engineered and uniquely shaped mechanical macro keyboard made for the open source community!

    42 parts1GPL-3.0

Questions

How big is the Invertor PCB?

It measures 110 × 82 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Invertor use?

151 parts, built around the ESP32-C6-WROOM-1-N8, RS485, MCP16311-E/MS and TPD2S017DBV. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Invertor KiCad files?

From the victorstoica114/Invertor_board repository on GitHub, at the commit this page was made from: the board is Kicad project/Invertor_main_board/invertor.kicad_pcb and its schematic Kicad project/Invertor_RJ45_adapter/ESP32.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Invertor design in my own project?

Its repository states no licence, so its author keeps all rights: ask victorstoica114 before reusing the design.