Skip to content

Port to platformio#3

Open
wodor wants to merge 26 commits intoTom-evnut:masterfrom
wodor:lilygo-t2-can-platformio-port
Open

Port to platformio#3
wodor wants to merge 26 commits intoTom-evnut:masterfrom
wodor:lilygo-t2-can-platformio-port

Conversation

@wodor
Copy link

@wodor wodor commented Jan 31, 2026

I decided to try running the CMUs from a LilyGo T2-Can. I could not justify the cost of buying a simpBMS for this project.
It turned out that the simplest path was a full rewrite to PlatformIO.
It went a bit further than I expected, as I was able to drive the project using agents and added a web server for convenience.
Now here is the problem: I am a software engineer, but I am not an embedded programming expert — quite the opposite.

So my main motivation for creating this PR is validation and an invitation to discussion, if the author of the original is willing to spend any time on this, which I'd truly appreciate.

The current state is that I see the readings from the CMUs on both CAN buses.
I have a duplicated CMU ID in my module "collection"; this approach allows me to dodge the problem of changing CMU IDs.
I get reasonable test results when I connect CMUs — protection kicks in and the data seems to add up.

I haven't connected the modules together yet, and I have not tested the contactor control.
The web server will be later replaced by reporting through MQTT to feed into better solutions for monitoring than staring on browser screen.

It is probably too early to merge this PR, but who knows — maybe early feedback will save me from doing something stupid.
If it gets merged I'd be happy to continue in a branch in the original repo.

wodor and others added 26 commits January 21, 2026 23:44
Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
…ds and best practices

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
as it looked like it was toggling off
Port V2 features with safety-critical hardening: SOC calculation, current sensing, and protection system
Add remote logging architecture plan with IoT standards and resilience strategy
- Created .github/workflows/ci.yml to run tests on PRs and pushes to main.
- Modified t2can_port/platformio.ini to move board-specific settings to
  [env:outlander_bms], allowing the native test environment to run
  independently of custom board definitions.
- Verified that 'pio test -e native' passes locally.

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
Removed the branch constraint for pull_request triggers in .github/workflows/ci.yml.

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
* Add dual CAN bus support for LilyGo T2-Can

- Initialize both MCP2515 (Bus A) and ESP32-S3 TWAI (Bus B).
- Map 10 modules per bus to a total of 20 modules (indices 0-19).
- Add runtime configuration for expected CMUs via serial commands 'A' and 'B'.
- Update web dashboard and serial console to display separate buses.
- Treat modules from both buses as a single serial battery string for voltage summation.

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>

* Add dual CAN support, persistent configuration, and connectivity protection

- Support both MCP2515 (Bus A) and ESP32-S3 TWAI (Bus B).
- Handle up to 10 modules per bus (20 total) with duplicate ID support.
- Implement NVS persistence for expected CMU configuration.
- Add web dashboard checkboxes for configuring expected CMUs.
- Add connectivity protection: trigger fault if any expected CMU is offline for >5s.
- Update serial menu with new configuration commands and grouped display.

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>

* Fix CI compilation error by using supported Preferences methods

- Use getUInt and putUInt instead of getUShort/putUShort in bms_data.cpp.
- This maintains compatibility with the mock Preferences class used in native tests.

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>

* Implement Dual CAN support and persistent CMU configuration

This commit adds support for two CAN buses on the LilyGo T2-Can board:
- Bus A uses the external MCP2515 (SPI)
- Bus B uses the internal ESP32-S3 TWAI controller

Key changes:
- Increased BMS_MODULE_COUNT to 20 (10 per bus).
- Implemented CMU ID mapping (Bus A: 0-9, Bus B: 10-19).
- Added persistent storage for 'Expected CMUs' using ESP32 Preferences.
- Implemented communication fault protection (5s timeout) for expected modules.
- Updated Serial and Web UI to display both buses separately.
- Added API and UI controls to configure expected modules at runtime.
- Fixed CI build compatibility for native tests.
- Re-enabled GitHub Actions CI.

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>

* Implement Dual CAN support and persistent CMU configuration

This commit adds support for two CAN buses on the LilyGo T2-Can board:
- Bus A uses the external MCP2515 (SPI)
- Bus B uses the internal ESP32-S3 TWAI controller

Key changes:
- Increased BMS_MODULE_COUNT to 20 (10 per bus).
- Implemented CMU ID mapping (Bus A: 0-9, Bus B: 10-19).
- Added persistent storage for 'Expected CMUs' using ESP32 Preferences.
- Implemented communication fault protection (5s timeout) for expected modules.
- Updated Serial and Web UI to display both buses separately.
- Added API and UI controls to configure expected modules at runtime.
- Updated unit tests to support 20 modules.
- Fixed portability issues in platformio.ini for better CI compatibility.
- Re-enabled GitHub Actions CI.

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>

* Handle missing CMUs in UI and protection

* Fix CAN-B pins and accept 0x6xx CMU IDs

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
* Initial plan

* Add ESS control module with tests and integration

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>

* Verify ESS control tests pass successfully

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>

* Add .gitignore and remove build artifacts

* Address code review comments - mark helper functions as static and clarify IDLE state

Co-authored-by: wodor <959800+wodor@users.noreply.github.com>

* Remove codeql symlink artifact

* Update .gitignore to exclude CodeQL artifacts

* Add ESS IO pin mapping and tests

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wodor <959800+wodor@users.noreply.github.com>
Co-authored-by: Artur 'Wodor' Wielogorski <artur.wielogorski@arbor-education.com>
This reverts commit 8902526.
@wodor wodor force-pushed the lilygo-t2-can-platformio-port branch from a3f7f15 to ef07382 Compare February 1, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants