Skip to content

Simulate a BYD Battery-Box Premium HVS over CAN Bus to use a custom battery with your inverter. Controllable via MQTT.

License

Notifications You must be signed in to change notification settings

SunshadeCorp/can-service

Repository files navigation

can-service

hardware

  • Waveshare 2-CH CAN HAT (shop , wiki)
  • Raspberry Pi 4B

installation

/usr/sbin/ip link set can0 type can restart-ms 100
/usr/sbin/ip link set can1 type can restart-ms 100
/usr/sbin/ip link set can0 up type can bitrate 500000
/usr/sbin/ip link set can1 up type can bitrate 500000
/usr/sbin/ifconfig can0 txqueuelen 100
/usr/sbin/ifconfig can1 txqueuelen 100
  • chmod +x startscript.sh
  • sudo crontab -e and add @reboot /root/startscript.sh
  • (if running directly): run pip install -r requirements.txt in repository dir

run

directly

./service.py

docker compose

can-service:
  build: https://github.com/SunshadeCorp/can-service.git
  container_name: can-service
  depends_on:
    - mosquitto
  network_mode: host
  restart: unless-stopped
  volumes:
    - ./can-service/credentials.yaml:/usr/src/app/credentials.yaml:ro

mqtt messages

publish:

master
└─ can (running/stopped)
   ├─ available (online/offline)
   └─ [topic] ([float])

subscribe:

master
├─ can
│  ├─ start ([any])
│  ├─ stop ([any])
│  └─ [topic]
│     ├─ reset ([any])
│     └─ set ([float])
└─ relays
   └─ kill_switch (pressed)
esp-total
├─ total_voltage ([float])
└─ total_current ([float]) {positive = discharge, negative = charge}

current config.yaml topics:

battery
├─ current {positive = charge, negative = discharge}
├─ max_cell_temp
├─ min_cell_temp
├─ soc
├─ soh
├─ temp
└─ voltage
inverter
├─ battery_voltage (read only)
├─ soc (read only)
└─ timestamp (read only)
limits
├─ max_charge_current
├─ max_discharge_current
├─ max_voltage
└─ min_voltage

About

Simulate a BYD Battery-Box Premium HVS over CAN Bus to use a custom battery with your inverter. Controllable via MQTT.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages