A closer look at the inner workings of evcc

After setting up two instances of evcc with a relatively basic setup I wanted to learn a bit more about customizing the charging process. While the evcc documentation is comprehensive, it required some time and patience to learn from it how the different inputs and settings work and interact with each other. Therefore, in this post I’ll try the balancing act of providing an overview that is clear and simple but at the same time thorough and complete.

Let‘s start with why you‘d want to use evcc. In a nutshell: evcc takes control of your charger/wallbox and enables you to charge your electric vehicle with surplus from your photovoltaic (PV) system. Its power lies in its openness and the many interfaces implemented for different inverters, battery systems, vehicles and other energy-management equipment. This enables you to bring together hardware from different manufacturers and control vehicle charging at a level most similar systems cannot offer (see for example my comparison of evcc with the go-e Controller).

To introduce you to the inner workings of evcc, we’ll first talk about the different charging modes, then take a closer look at the Solar mode and finally cover a few use cases to put what we‘ve learned into practical context. To that end this post is structured in the following sections:

  • The three charging modes of evcc
  • The magic of the Solar mode
  • Use case 1: a PV system with only a grid meter
  • Use case 2: a PV system with only a pv meter
  • Use case 3: a PV system with integrated battery storage
  • Use case 4: a PV system with unmeasured battery storage
  • Use case 5: a PV system with another surplus-controlled device

Note that we will leave aside the details of how devices are integrated with evcc but will focus on how different inputs and settings define its control of your vehicle’s charging.

So, let’s get right to it:

The three charging modes of evcc

When using evcc you can use one of the following three modes to charge your vehicle:

  • Fast mode enables charging with the highest amount of power possible, without consideration of PV surplus. This mode basically replicates what your wallbox is already able to do on its own.
  • Solar mode is where the magic happens: based on available surplus, evcc starts and stops the charging process and adapts the amount of power.
  • Min+Solar mode is a bit of a mix of the previous two modes. Evcc starts the charging immediately when the mode is activated, regardless of surplus, but with only the minimum power needed by the charger. If more surplus than that is available, evcc will adapt the amount of power.

In all three modes, charging will be stopped once the set charge limit is reached. Charging plans set a time when a certain charge limit shall be reached and combine the Solar and Fast modes: the vehicle is charged with surplus and at the latest possible time Fast mode is activated to meet the targeted charge limit. If you have a battery, Solar mode also allows you to set priorities between battery and vehicle charging.

The screenshot below shows the selection of the charging mode in the evcc user interface:

The magic of the Solar mode

Now, let’s dive into the details of the Solar (and Min+Solar) mode. The Solar mode is highly customizable, and can therefore adapt to many different setups and requirements. 

I’ll assume that you are already familiar with the structure of the evcc configuration, which defines inputs and parameters for the Solar mode. The following diagram shows which of these we will discuss in this post. Blue are settings that define inputs, green are other configuration parameters.

Evcc is just in process of migrating from file-based to user-interface-based configuration. Most parameters still need to be set in the configuration file, but the battery settings can already be done on the user interface and will be saved in the evcc database. 

The inputs defined in the configuration file connect evcc to various other devices in your system, enabling the interactions shown in the next diagram:

So, having laid the groundwork, let’s start talking about how the Solar mode works. When in Solar mode, evcc constantly calculates the available charging power (surplus) based on the metering inputs shown in the diagram above:

  • The most important factor is grid power, which shows available surplus that is fed into the grid.
  • With data from battery systems that are also charged with surplus, evcc can depending on their charge level prioritize vehicle charging. It does that by increasing the charging power of the vehicle, practically forcing the battery to reduce or stop charging. See also the third use case described further below. 
  • The same can be done for other devices operated with surplus (“aux” devices). See also the fifth use case described further below.
  • The output of your PV system can also be measured, mostly for display purposes. Only if grid power cannot be measured, you can use PV power and a constant value for assumed house consumption to approximate surplus. See also the second use case described further below.
  • The actual charging power consumed by the charger is also measured. If the charger itself does not provide this measurement, a separate meter can be used. If that is not available as well, then instead the power last set by evcc will be used.

Also important is the integration with your vehicle, which allows evcc to determine its state-of-charge and implement charge limits and charging plans.

And last but not least there are different configuration parameters available for customizing the Solar mode:

The following diagram shows in detail how all these variables are factored into the calculation of available charging power and starting and stopping the charging process (click to enlarge). Its main focus lies on Solar mode in combination with a battery system, but it also covers how systems without battery work as well as the Min+Solar mode. The formulas are not necessarily those programmed into evcc, but rather provide a mathematical model that helps understanding how the software works:

Minimum charging power and phases

In the diagram above, you can see that the minimum charging power is calculated from minCurrent and the phases setting. If your charger supports automatic switching between 1-phase and 3-phase charging, you can have evcc manage that by setting phases=0. If available charging power allows it, the system will use three phases, otherwise only one. 

Note that the minCurrent and maxCurrent settings apply to both 1-phase and 3-phase charging. Depending on the range of those settings in your system, you’ll likely have gap between 1-phase and 3-phase charging, were evcc needs to continue charging with the maximum charging power of one phase and additional surplus has to be fed into the grid or a battery. The following diagram shows the calculations and the resulting gap:

Timing: interval and delays

The calculation of available charging power and resulting actions and adjustments are executed in the interval defined in the configuration file. Therefore evcc does not react to any change in the inputs but only to the state detected at each interval, as the next diagram illustrates:

The time in between the intervals gives the charger or other device represented by the loadpoint as well as other surplus-controlled devices chances to react before the state is checked again and further adjustments are made.

To avoid vehicle charging being started and stopped in the typically relatively short intervals, several delays are applied:

  • loadpoint.enable:delay defines the time the enable threshold must be met before charging is started. Also applies to switching from 1-phase to 3-phase charging.
  • loadpoint.disable:delay defines the time the disable threshold must be met before charging is stopped. Also applies to switching from 3-phase to 1-phase charging.
  • loadpoint.guardduration defines the time that after starting charging must pass before charging can be stopped again, and vice versa the time that must pass after stopping before charging can start again.

The next diagram shows the application of those settings and their relationship with the control cycle interval:

Timing: multiple loadpoints

If you have two or more loadpoints, at each interval only one will be calculated and adjusted. This way each loadpoint represents its own independent control circuit. The control circuit of each loadpoint only takes into account the measurement inputs from the devices represented by the other loadpoints, but is not aware of their ongoing adjustments or delay timers. The next diagram shows these independent control circuits for two loadpoints. As example, we have Loadpoint A with lower priority grabbing surplus first but then releasing it again, after Loadpoint B with higher priority also starts charging:

Note that this back-and-forth can be avoided by setting a longer delay for the loadpoint with lower priority:

To put all this information into the perspective, the next sections will focus on a few use cases, showing how the Solar mode can be used in different real world environments.

Use case 1: a PV system with only a grid meter

The diagram below shows a simple use case with a charger and grid meter that interface with evcc, and without any battery system. Integration with a vehicle enables charging plans and charge limits, but if that is not possible you can still use charge limits set in the vehicle itself.

In terms of configuration you can use phases, minCurrent and maxCurrent to reflect the capacity and requirements of your charger and vehicle. If your charger supports it, automatic phase switching (phases=0) will allow effective use of your solar surplus, especially if your PV system is smaller and often does not produce enough surplus for 3-phase charging.

The main use of residualPower and the enable/disable thresholds in this use case are to influence the share of solar power used for charging. By default, evcc charges only if enough surplus is available to completely sustain the charging. If that is not enough to charge your vehicle sufficiently and if you do not want to waste lower amounts of surplus to the grid, you can supplement charging with grid power by setting a negative residualPower or lowering enable/disable thresholds below the minimum charging power.

On the other hand, if your PV system provides sufficient output you may think about raising the minimum power levels for charging, to avoid the proportionally higher charging losses when charging with smaller amounts of power. However without a battery, charging your vehicle with smaller amounts of power is probably still the best use of your surplus, except you get very good rates for the power you feed into the grid. To raise the minimum power levels you can either raise the enable/disable thresholds or the minCurrent setting. If you use automatic switching between 1-phase and 3-phase charging, then I’d recommend using the thresholds, since raising minCurrent will also apply to 3-phase charging and increase the gap between 1-phase and 3-phase charging (see the last diagram in the Solar mode section further above).

Another way to improve use of your surplus is a charger whose charging power can be set in milliampere instead of ampere (check the evcc charger list for devices tagged with „mA regulation“). No configuration is required for that, evcc will use smaller increments automatically. 

Use case 2: a PV system with only a PV meter

The setup for this use case is the same as for use case 1, but instead of a grid meter you only have a PV meter available:

Evcc can therefore only measure the output of your PV system but does not know the consumption of your house and therefore cannot accurately calculate surplus. As the evvc documentation describes, in this situation you can use a positive residualPower to assume a constant for house consumption. For example, if you set residualPower=500, evcc will reserve 500W and only see the remainder of the output of your PV system as available charging power. If your house uses more than 500W, it will be drawn from the grid, if it uses less the remainder will be fed into the grid. All other settings can be used as described above for use case 1.

Use case 3: a PV system with integrated battery storage

The third use case covers the setup we have in our both our homes, a PV system with a hybrid inverter and connected battery storage. Check our previous articles for details: the first one for our setup with Huawei and the second one for our setup with Fronius. In both setups, the battery is directly integrated with the inverter. Also, they include a smart meter measuring grid power, since similar to evcc, the battery system needs that to determine whether the battery should be charged with surplus or discharged to provide power instead of it being drawn from the grid. Technically this setup is fairly simple because evcc only needs an interface to the inverter, which can provide grid power, pv power and battery power/state-of-charge.

What makes this setup interesting is that with the battery and evcc you have two systems that can make use of surplus from your PV system. The battery sees evcc only as another consumer, but evcc receives power input/output and state-of-charge of the battery and therefore  is aware of the battery’s activity and can prioritize one of the two systems. Below a screenshot of the battery settings in evcc:

Setting priorities with battery settings and residualPower

The lower threshold is prioritySoc and defines the charge level of the battery under which the battery shall have priority over vehicle charging. Above prioritySoc, vehicle charging will take priority but does not yet use battery power. Only if bufferSoc, the upper threshold, is surpassed, then battery power may also be used to charge the vehicle. The final threshold you can define is bufferStartSoc. By default, even when above bufferSoc, evcc will start charging only if enough surplus is available, and the battery will then be used only when the surplus drops. If you set bufferStartSoc, then charging will start even if surplus is too low and the remainder needed to achieve minimum charging power will be drawn from the battery.

So, how does evcc implement those priorities? 

When the vehicle is prioritized above the battery, evcc simply includes the power going into the battery into its calculation of available charging power. The battery will then see that additional consumption from the grid meter and reduce or stop its charging.

When the battery is prioritized it gets more complicated. Evcc still should be able to start charging, since there may be more surplus than the battery can use, but it actually does not know the maximum charging power of the battery. Therefore it could occupy surplus that actually should go into the battery. To avoid that, the evcc documentation recommends to set residualPower to value between 100 and 300, forcing evcc to leave that amount of surplus available. The battery recognizes that surplus and increases charging, forcing evcc to reduce or stop charging to maintain the target residualPower. Therefore, even if evcc grabs power that should go into the battery, that power will gradually shift to the battery. If you set residualPower higher, that process will be faster, at the disadvantage that the residualPower will also be left to battery or grid at times when the vehicle is prioritized. For our systems we have decided to work with residualPower=200.

Its ability to interact with battery systems and set such priorities is one of the advantages evcc has over similar solutions (see our comparison with the go-e Controller). Vehicle charging needs a relatively high minimum power and often can only be adjusted in large increments (sidenote: chargers supporting smaller increments are tagged with „mA regulation“ in evcc’s list of supported chargers). Compared to that, battery storage can charge with small amounts of power and also typically reacts faster to changes in PV output or consumption. Therefore the two systems complement each other well, and I’d recommend to always start prioritizing the vehicle over the battery long before the battery is full. The battery will then always be able to charge with small amounts of surplus left over by vehicle charging (including the residualPower) or when the surplus is not sufficient. This way you can make best use of your surplus, avoiding situations where the battery is full and surplus has to be fed into the grid because it is too little for vehicle charging or there is no vehicle connected.

Other settings

Other parameters are also setting priorities between vehicle and battery. The settings for enable/disable thresholds and phases/minCurrent/maxCurrent can be used to customize the levels of available charging power at which charging is started or stopped and the minimum and maximum charging power. However, be aware that evcc cannot directly control if power is drawn from the battery. If you set the enable/disable thresholds lower than minimum charging power, the deficit will first be drawn from the battery, regardless of the battery settings, and only from the grid once the battery is empty. The same applies to Fast charging. Side note: implementing control of battery discharge in evcc is being discussed and worked on, so in future there may be additional integrations and options for this coming to evcc. See here for details.

Generally, with a battery that can “catch” surplus too little to charge the vehicle, you have less incentive to subsidize your surplus with power from the grid. Therefore in most cases you can leave the thresholds on their defaults and charge only with solar surplus. 

You might even consider increasing the minimum charging power if your PV system produces sufficient output. That way you can avoid the proportionally higher charging losses of your vehicle when using lower charging power and instead use the power to charge the battery, at lower losses. If you use automatic switching between 1-phase and 3-phase charging, then I’d recommend raising the enable/disable thresholds for that, since raising minCurrent will also apply to 3-phase charging and increase the gap between 1-phase and 3-phase charging (see the last diagram in the Solar mode section further above).

Deal with limitations of the DC/AC interface with maxGridSupplyWhileBatteryCharging

In PV systems with integrated batteries, the DC/AC interface of the inverter may become a bottle neck. If the PV panels produce a higher DC output than can be provided through that DC/AC interface, then the additional power can only be charged into the DC battery. If vehicle charging is prioritized over battery charging using prioritySoc, then evcc will include that power into calculating available charging power. But due to the limit of the DC/AC interface the power can actually not be diverted and will be drawn from the grid instead. Setting maxGridSupplyWhileBatteryCharging will limit the power that can be drawn from the grid, resulting in evcc using only the power that can be drawn from the AC/DC interface.

Use case 4: a PV system with unmeasured battery storage

Now let‘s look at a setup with a battery storage system that cannot interface with evcc:

Setting priorities with residualPower

Without data from the battery, you will not be able to define priorities in evcc using the battery settings. Still, you can use residualPower to set prioritize the battery and avoid instabilities where both systems randomly grab power. Set residualPower to a small value positive value between 100 and 300W and as described in the third use case above, that will allow the battery to gradually take power from vehicle charging. 

Setting residualPower to an equal but negative value would effectively give the vehicle priority by gradually forcing the battery to reduce and stop charging. However evcc would not stop there but continue to increase vehicle charging till the battery is drained. Also this may lead to additional grid power being used for vehicle charging  and power constantly being charged into the battery and then immediately discharged to the vehicle. I would therefore refrain from using a negative residualPower in this situation. If your battery has a similar setting it may be a more stable option to leave residualPower=0 in evcc at and use the battery‘s setting to prioritize vehicle charging. 

Other settings

Especially without being able to use battery settings, other parameters become more important to control priorities between vehicle and battery. The settings for enable/disable thresholds and phases/minCurrent/maxCurrent all define the power range at which the vehicle will be charged, and thus also effectively the ranges where the battery comes into play. See use case 3 for more information.

Use case 5: a PV system with another surplus-controlled device

Beyond batteries there are also other devices that can be operated with solar surplus, for example heat pumps. Similar to batteries, metering their power level as aux device and/or setting residualPower can be used to define priorities and ensure a stability of the overall system. 

Setting priorities with residualPower and/or aux devices

If the device should have priority over vehicle charging you can work with a small positive value between 100 and 300W for residualPower, which allows the device to gradually take power from vehicle charging, similar for what we described in the previous two uses cases for batteries. In this case integration between the device and evcc is not necessary.

If you’d like to give the vehicle priority and the device has an accessible interface, you can set up the other device in evcc as aux device:

Evcc will then include the power going into the aux device into the available charging power, enabling it to force that device to reduce or stop consumption.

If the device cannot interface with evcc, you can still give vehicle charging priority by setting a small negative value for residualPower in evcc. This will force the device to gradually reduce or stop consumption. Drawback is, that will then lead to constant grid consumption for vehicle charging, to the amount set for residualPower. The other drawbacks of negative residualPower described previously for batteries do not apply, since the device does not discharge power.

Other settings

Other parameters are also important to balance the allocation of power between vehicle and another surplus-controlled device. The settings for enable/disable thresholds and phases/minCurrent/maxCurrent all define the power range the vehicle will be charged with, and thus also effectively the ranges and extend to which the other device will receive surplus power. Depending on how the other device operate and its power consumption you should find settings that fulfil its needs as well as the vehicles.

Enable/disable lower than minimal charging power will be enacted regardless of the aux devices consumption, so your system will use grid power to sustain charging. Raising the enable/disable thresholds above minimum charging power leaves more power to the aux device and avoids charging the vehicle at lower power levels where charging losses are proportionally higher. The same can be achieved with raising minCurrent, but better avoid that if you use automatic phase switching. A higher minCurrent will increase the gap between 1-phase and 3-phase charging described in the section above on the Solar mode.

Using a HEMS

Note that the mechanisms described here work well only in combination of evcc with one other surplus-controlled device. If you have multiple, you will need some kind of higher level coordination mechanism to be able to set priorities and keep your system stable. Such mechanism are typically provided by a Home Energy Management System (HEMS).

Final words

I hope this article succeeded in providing you a comprehensible overview of the intricate but powerful Solar mode of evcc. While the dependencies between the different settings are not always easy to understand, they allow the system to adapt to many situations way beyond the relatively simple use cases described above. The right setup is always a balance between many factors, among them: the output of your PV system, the consumption of your house and vehicle, the presence of batteries or other surplus controlled devices and the rates that apply to feeding power into the grid or drawing from it. With evcc you have a powerful tool at hand to accommodate these factors and optimize solar-charging of your vehicle based on your individual needs.

Any questions or suggestions for improving this article are welcome and highly appreciated, please feel free to contact me.