This is an experimental repo. My goal is to parse the VE.Direct protocol from Victron with TinyGo on a Raspberry Pico.
See specifications of the protocol here
I want to have a display in my van to see :
- Battery voltage and current
- Solar panel Voltage and Current
- Current State of the MPTT Controller
- Maximum power
- Minimum and maximum voltage
Roadmap:
- Parsing VE.Direct protocol
- Connect to the MPTT
- Flashing the pico nano with firmware
- Refactoring to avoid heap allocations
- Add a display
- Add a button
- Testing
- Optimizing and reliability
flowchart LR
MPTT(Victron MPTT) --> R[Rasp Pico];
R --> LCD;
flowchart LR
R["serial data"] --> P[Parsing];
P -- "map[string]string{}" --> Frame;
Frame -- "struct{}" --> State;
You will need a JST PH 4
female socket to connect your Victron device to the Raspberry
In this POC I used a Rasbberry Pico, cheap and well supported by TinyGO: https://tinygo.org/docs/reference/microcontrollers/pico/
tinygo flash -target=pico main.go
go test -v ./vedirect
It relies on a dump of my SmartSolar 100/20
More info available here.
As you may see, I had to modify a bit my usual gopher habits to reduce the number of heap allocations, in order to optimize the memory management of the microcontroller.
Here some adjumemts
- no pointer in "constructor like" method (aka
New() (*myStruct, err)
) - passing by value instead of reference in method :
- ex
func (m *myStruct) myMethod error
-->func (m myStruct) myMethod (m myStruct, err error)
- ex
tinygo build -o firmware.uf2 -target=pico -print-allocs=. 2> >(grep victron)