Charging an EV for free - part 1

The solar landscape has changed in Australia.

In the boom days of solar, there were extensive and lucrative reasons to invest in solar power for the home. The FIT (Feed In Tarrifs) were so high (ludicrously so, really) with enormously long tenures, that getting solar was a no-brainer.

Not that I’m arguing that that was a bad idea. It has made us a nation where home renewable power generation is very high - and that’s a good thing.

But because those FIT’s were so high, those on them are incentivised to not consume power while it is being generated and to instead sell it back to the grid. Often, for more than it costs to buy back later when the sun goes down - basically making a profit.

(As an aside, naturally, the power companies are now complaining there is too much solar during the day, and they want to be able to remotely “kill-switch” our solar at their convenience.)

The days of these kind of subsidised tariffs are over, and nowadays, for someone like me with no subsidy and a terrible FIT (0.10c per kWh, but only for the first 14kWh per day!), it makes more sense for me to consume the energy I’m generating, instead of giving it back to the grid at a tiny fraction of what it will cost to me to buy it back when the sun goes down.

Some of this is easy - run the dishwasher/washing machine during the day where possible, and so on.

Having recently bought an EV, of course I’d like to do the same with that. Free “fuel”, who can say no? And since the EV is a big consumer of electricity (~50kWh battery), it makes even more sense.

Suddenly we have a very interesting possibility. While I can look at my solar generation and say “I have an excess of 3kW, I should run the dishwasher now”, charging the EV is a different proposition - if I don’t care about how long it takes to charge (within reason) I can treat it as a controllable variable load, and only consume the energy that I can produce - and no more.

With the right charger and controls, I can vary it in near-realtime, and never pay a cent - including completely disabling charging when appropriate.

Of course I need to be able to override - if the SOC is low and I know I need to drive a lot the next day, well, I’ll have to buy some kWh.

I need a few things to realise all of this - a charger that I can dynamically control, the information about how much excess solar I have available, and some code to implement a control loop.

A control loop

The control loop is pretty straightforward. The inputs and ouputs are:

What this really means is “how much am I exporting to the grid”. You must be able to determine how much is being exported (or deduce it, by knowing your house load and your generation) to know how much is “spare”. In my case it’s a measure of “meter energy”, where positive numbers indicate I am consuming more than generating, and negative numbers mean I am exporting back to the grid.

We cannot simply use “generation” for our evaluation, if the house load increases (I turned the dishwasher on) we want the car output to decrease proportionally, to stick with out “charge for free only” scenario.

I need to be able to control (via a current limit) how much energy is “allowed” to go into the car. This involves “talking” to the charger via an API.

Our control loops simply evaluates excess power, and tells the charger “you can use that much”. However we need to know one final input for this to work:

As soon as we starting charging the car, the excess power available will drop by the same amount. We need to measure how much the car is actually consuming (which may not be the same as the actual limit we set) to reach a correct evaluation of what our charger set-point should be in the next iteration.

For example:

If we have 4kW of solar generation and a house load of .5kW, we have 3.5kW of power available for our charger, and we should set the charger limit to 3.5kW. The car is not yet connected.

meter - car = charger limit
  3.5 - 0.0 = 3.5

Now I plug the car in - it starts drawing 3.0kW, but the sun comes out from a cloud and generation goes up to 4.5kW. The rest of the house load remains at 0.5kW. My new calculation is:

meter - car = charger limit
  1.0 + 3.0 = 4.0

Remember that even though the generation is now 4.5kW the house load will also include the car current draw, so we need to add that back in to calculate an accurate limit. As expected, it is 0.5kW higher than it was previously, as we are generating 0.5kW more.

The charger

After getting advice from a friend, I settled on the Victron EV Charging Station NS:

EV Charging Station NS
EV Charging Station NS

The key feature here is the ability for it to be controlled via a sensible API (modbus-TCP in this case) and a fully manual operation mode, where it does not try to do anything “automatic” - allowing me full flexibility to control charging as I see fit.

In terms of our three dot points above, the two required ones are easy - I can set the charging current allowed (between 6 and 32 amps) and I can measure how much actual power is being consumed.

Measuring the solar generation and excess energy

When I had my solar system installed, I chose an inverter that was paired with an export meter. Thus, I already have the telemetry needed to “plug in” to the control loop above.

The technical details - I have a Sungrow SG5K-D inverter with the S100 export meter fitted. The inverter comes with a wifi dongle which uploads solar data to the a̶̗ͭc͕͐́cͩ͏͈u̧̳ͨr̛̝̂s̨͕̐ẻ̡̠ď̞͢ cloud, but it can also be accessed directly from your local network.

I use the Sungather project to talk to the inverter and expose the data to a /metrics endpoint which is consumed by VictoriaMetrics, making the timeseries data available at a HTTP endpoint with a PromQL query.

All this data lets me construct Grafana panels like:

Energy generation and consumption
Energy generation and consumption

See all that empty space between the yellow line and ‘0’? That’s me giving energy back to the power company, almost for free. We’re here to change that….

Continued in part 2.

Tags: ev  solar  energy  grafana  victoriametrics