Home - dalathegreat/Battery-Emulator GitHub Wiki

[!CAUTION] Working with high voltage is dangerous. Always follow local laws and regulations regarding high voltage work. If you are unsure about the rules in your country, consult a licensed electrician for more information.

Welcome to the Battery-Emulator wiki!

Where do I get the hardware needed?

The Battery-Emulator software can be run on either of the following devices:

Product Product Link
LilyGo T-CAN485 AliExpress
Stark CMR Module Wiki page

[!NOTE]
There is no way to purchase a pre-programmed device. This is a hobbyist open source project. You will be responsible for loading the software and setting it up correctly for your components.

Supported inverters list

The following solar inverters have support. Remember to double check that the voltage range of your inverter matches the battery you intend to use.

Vendor Product Name Supported Notes Battery voltage
Afore Afore AF17K-THA 230V Testing ongoing :zap: , good option for Norway 150–800V
Canadian Solar CSI-TE & CSI-HE & CSI-BHE Series ⚠️ Untested, works with HVS / HVM
Deye SUN-(5-20)K-SG01HP3-EU-AM2
Deye SUN-(29.9-50)K-SG01HP3-EU-BM3 Both BYD_CAN and PYLON_CAN work
Ferroamp EnergyHub 174-432V
FoxESS H1/H3 FoxESS H1 .. H3 Cannot co-exist on EV battery CAN channel. Needs its own CAN channel!
Fronius Primo Gen24 Plus 150-455V
Fronius Symo Gen24 Plus 150-455V
Fronius Symo Hybrid 3.0/4.0/5.0-3-S 150-455V
GE GEH5.0/8.6/10-1U-10 ⚠️ Untested, works with HVS / HVM
GoodWe ET/BT & EH/BH & EHB
Growatt N/A ⚠️ :zap: Testing ongoing!
Huawei SUN2000 ❌ Requires DC/DC converter, NOT supported
Ingeteam STORAGE 1Play TL M (3-6 kW)
KACO Blueplanet hybrid 6.0- 10.0 TL3 ⚠️ Untested, works with HVS / HVM
Kostal Plenticore N/A :zap: Testing ongoing! 120-650V
Schneider XW PRO ⚠️ :zap: Testing ongoing! 48V
SMA Sunny Boy Storage 2.5 / 3.7 / 5.0 / 6.0
SMA Sunny Island 4.4M / 6.0H / 8.0H ⚠️ :zap: Testing ongoing! 48V
SMA Sunny Tripower Smart 5.0-10.0 SE ⚠️ Protocol added "SMA Tripower", testers welcome!
Sofar 5K...20KTL-3PH
SolaX X1 Hybrid Cannot co-exist on EV battery CAN channel. Needs its own CAN channel!
SolaX X3 Hybrid Cannot co-exist on EV battery CAN channel. Needs its own CAN channel!
Solis RHI-3P(5-10)K-HVES-5G ✅ / S6-EH1P10K-H-US-APST
Solis RHI-3P(5-10)K-HVES-5G ✅ / S6-EH3P-(5-10.0K)-H-EU
Sungrow SH5.0/6.0/8.0/10RT Some AU models not supported 150-600V
Sungrow SH3.0/3.6/4.0/5.0/6.0RS Some AU models not supported 80-460V
VIESSMANN Hybrid Inverter 5.0/6.5/8.0/10.0 A-3 ⚠️ Untested, works with HVS / HVM

Supported batteries list

(Car) Manufacturer Product Name # kWh Supported Voltage range Notes
BMW BMW i3 (all sizes) All 270-400V
BMW iX & i4-7 Platform 68 / 80.7 270-464V Manual contactor control
BYD BYD Atto 3 All 380-440V
Citroen C-Zero ? 310-370V
Hyundai E‐GMP platform 58.2 / 77.4 ⚠️ (Integration ongoing!)
Hyundai Kona 39/64kWh 39/64 230-410V*
Hyundai Kona Hybrid 2 ⚠️ Testing ongoing
Hyundai Santa Fe PHEV 14 290-400V
Jaguar I-PACE 90 ⚠️ Testing ongoing
Kia e-Niro 39/64kWh 39/64 230-410V*
Kia Niro Hybrid 2/9 ⚠️ Testing ongoing
Kia EV6
Land Rover Land Rover
Mitsubishi i-Miev ? 310-370V
Nissan Ariya 87/63 ⚠️ (CAN logs wanted!)
Nissan LEAF 24/30/40/62 300-400V
Nissan e-NV200 24/40 300-400V
Opel Ampera-e
Peugeot Ion ? 310-370V
Polestar 2 78 290-450V Manual contactor control
Renault Kangoo 22 ⚠️ Testing ongoing
Renault Twizy 6.1 ⚠️ Testing ongoing 48V
Renault Zoe Gen1 22/41 300-400V
Renault Zoe Gen2 50 300-400V
Tesla Model 3 & Y (all sizes) All 280-400V
Tesla Model S & X (2020+) All 310-460V
Volkswagen MEB Platform 48/55/61/82 252-450V* Requires extra precharge circuit
Volvo EX30
Volvo XC40 78 290-450V Manual contactor control

Other batteries

Supported chargers list (optional)

Emergency charging batteries via a generator, supported via the following standalone chargers:

Shunts

How do I configure the software for my inverter?

All the changes to the software are done in the USER_SETTINGS.h file, located in the Software folder. At the top of this file, you can select which battery and which inverter protocol should be in use. If you are unsure which protocol you need, check the specific page for the inverter you are using linked here in the Wiki.

How do I make changes to CAN configuration?

For advanced setups where you add CAN channels, you will need to change which channel a component is connected to. This is done in the USER_SETTINGS.cpp file.

Example, you want to change which CAN channel the inverter is connected to, since you added an MCP2515 chip. We then change the line .inverter = CAN_NATIVE, into the correct interface, .inverter = CAN_ADDON_MCP2515,

Example 2, you want to change which interface the battery connects to, since it needs CAN-FD add-on. We then change the line .battery = CAN_NATIVE, into the correct interface, .battery = CANFD_NATIVE,

Status LED

The board has a built in LED that is used to signal current status. With this feature, it is easy to at a glance catch what info the board is getting. It will show the current colors:

  • Pulses 🟢 if all is well and BMS is active
  • Pulses 🔵 if CAN wires are disconnected, wrong polarity, or incorrect terminating resistor setup. Check wiring!
  • Pulses 🟡 if battery has entered a warning state
  • Solid 🔴 if battery goes into a fault state

CAN wiring troubleshooting

CAN networks are vulnerable to lightning strikes. See the dedicated wiki page for this for more info :cloud_with_lightning:

[!CAUTION]
Grounding everything is especially important for certain inverters. If you fail to ground inverter or battery casing to protective earth (PE), there might be a voltage difference between the two components, which can fry the CAN communication chips on the Battery-Emulator. Always connect every component, and the communication shield wire to protective earth before turning the system on!

See this image for grounding:

image

[!CAUTION]
Never connect the signal wire shields in both sides. This creates a ground loop. One side of the shield should be freefloating, like shown in the above picture.

Every CAN bus must be terminated with a 120 Ohm resistor at each end of the bus. For quick testing, the exact value of the termination resistors is not always critical. Sometimes a single terminator is sufficient. For final installs, proper termination is essential. If you see strange errors, you should check the termination.

[!IMPORTANT]
To save yourself a lot of trouble, always terminate the CAN bus properly.

If you get a 🔵 blue LED on the board (or 🔴 red for BMS missing), you need to check the CAN wiring. Here are some basic tips:

  • Make sure all CAN devices are turned ON
  • Make sure the polarity of High/Low is correct. High goes to High, Low to Low
  • Make sure the terminating resistors are correct. CAN networks should have two 120 Ohm resistors in each end of the network. With everything OFF, you can measure resistance between CAN-H and CAN-L. The result should be 60 Ohm. If it shows 120 Ohm, one resistor is missing at an end. If it shows 40 Ohm, you have too many terminating resistors, and might need to remove the built in resistor on the LilyGo. RemoveThisWhenUsingCANinverter
  • Make sure the cable you are using is a twisted pair cable. This is important for signal quality.
  • Make sure the cable you are using is shielded. One side of the shield should be connected to a pin labelled SHIELD (or PE if no dedicated shield exists). This improves signal quality
  • Try a different powersupply for the board. Powering it via USB from a computer can cause noise on the signal output. Powerbank or phone charger might have cleaner voltage output. If you see CAN_TX_FAILURE occasionally your powersupply might be noisy

What about safety? ⚠️ ℹ️

Reusing old often crashed EV packs always comes with risks. The system performs a few safety functions for safer charging and discharging. Apart from this, the data sent to the Inverter is also processed on the inverter side, and depending on which inverter is used a few additional safety checks are performed there. Here is a list of all safety functionalities that are in the system. Note that almost all safety features rely on communication data, so a physical error (damaged cell casings, ruptured/leaking cells, corrosion etc.) wont be detectable via software. For this you need fuses, and periodic visual inspections.

[!CAUTION] At the end of the day, you alone are responsible for the system.

Safety features run on inverter side:

  • Battery sends max total voltage allowed for charging. Incase this value is reached, inverter stops charging. (For instance 404V)
  • Battery sends min total voltage allowed for discharging. Incase this value is reached, inverter stops discharge (For instance 300V)
  • Battery sends max cell temperature. Incase this value goes too high, inverter stops charge/discharge (For instance 40*C)
  • Battery sends min cell temperature. Incase this value goes too low, inverter stops charge/discharge (For instance -15*C)
  • Battery sends max allowed charge in Watts. Incase this goes to 0W, no further charging is possible. (This can happen when battery is full)
  • Battery sends max allowed discharge in Watts. Incase this goes to 0W, no further discharge is possible. (This can happen when battery is completely empty)
  • Battery sends state of health %. Incase this value drops too low, the inverter will alert the user that it is time to recycle the battery.
  • Inverter analyzes insulation resistance of the battery connection. Incase a leakage to ground is detected, the system stops.

Safety features run on Battery-Emulator side:

  • If the code enters FAULT state, inverter gets notified, all charging/discharging stops, and contactors are opened (if they are controlled via GPIO pins).
  • If CAN communication is lost between emulator and battery for more than 60s, the code enters FAULT state.
  • Minimum cell voltage is sampled, and if one cell goes too low the code enters FAULT state. (For instance <2900mV)
  • Maximum cell voltage is sampled, and if one cell goes too high the code enters FAULT state. (For instance >4250mV)
  • Battery state of health % is sampled, if it is below 25% the code stops and informs the user that it is time to recycle the battery.
  • BMS fault codes are sampled, if any serious code is set, the code enters FAULT state (For instance LB_Failsafe_Status on Nissan LEAF packs)
  • High voltage wiring is unhooked during operation. This will trigger interlock messages, and the code enters FAULT state
  • Incase of a high voltage leak to battery casing (Protective earth), the code enters FAULT state (For instance LB_Failsafe_Status on Nissan LEAF packs)

[!IMPORTANT]
Do note that all actual limits are battery/inverter specific, the values here are only used for example purposes. The amount of safeties will vary depending on your choice of battery.

[!TIP]
You can also add an equipment stop button to the Battery-Emulator, to increase the amount of safety.

Connectivity

The board has wifi, and supports running a Webserver that you can connect to for real time values, Over The Air updates (OTA), cellmonitoring, changing settings and more. See the Webserver page for more info on how to use the system

For those into home automation, the code also supports MQTT

Alternative hardware

There is also an excellent Raspberry Pi integration available here: https://gitlab.com/pelle8/gen24 This version focuses more on power users that want to experiment more than the LilyGo "Set and forget" solution does. Say you want to integrate charging only during certain hours, spotpricing etc., then the Raspberry Pi solution made by Per Carlen is the way to go! You can also use both hardware at the same time, use LilyGo for the control, and use Raspberry for additional statistic-gathering!