How I built a HEMS with solar, a battery and a charge station (in Python)

The setup

Inside the inverter
Overview of the setup with 2 PV inverters, the battery and the inverter for the battery (on the right)

Background

Why a home battery?

Voltage at my grid connection

In 1 hour my voltage goes from almost 240 to almost 210 volts

Yearly zero net cost in the Netherlands

Use cases

Storing excessive solar energy

Keeping the power at grid connection at zero

The battery is charged during the day and discharged during the evening to keep the grid connection at around 0 watts.

Charge (cheap) during the night

The prices drop to 0 in the night
Negative prices during the afternoon

(Only) charge during the night when the next day will not be sunny

  • Minimum state of charge (25%, at least to make it through the morning)
  • Maximum state of charge (85%, always keep room for not predicted solar energy)
  • Predicted solar energy for the next day
  • Energy need during the day (10kWh)
The (not complete) formula. batteryChargePercentage is limited between 25% and 85%.
World Solar irradiance data from Solcast
The battery starts charging at 4am, to reach a minimum of 45% SoC (which the system has predicted as the needed SoC to get through the day)

Charge with solar, extra discharge in the evening

In this case 19:00h seems to be the most expensive hour

Grid balancing / power quality

The full setup with solar, battery and charge station

  • The system is aware of hourly kWh rates.
  • The battery will pre-charge at night when there is not enough predicted solar for the next day. It’ll charge at the cheapest hours.
  • The charge station will charge the electric vehicle at night at the cheapest hours.
  • The battery will store all excessive solar energy produced during the day in the battery.
  • The battery will keep the grid connection at around 0 watt, to be as self sufficient as possible.
  • The charge station will only charge the car with excessive solar if, and only if, the battery is 95% full and not discharging.
  • Discharging of the battery at the most expensive hours.
The SoC of the stationary battery (left) and the power on my grid connection, battery and charge station

Next steps or future use cases

The code

In-home protocols and modbus magic

Did I inspire you?

--

--

--

Cyber security, smart grids, electric vehicles, distributed ledger technology, hardware. Owner of Innoshift B.V. Articles on personal title.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Boolean Operators in Python

My Experience of becoming a Tezos Baker

Why Should You Consider Custom Healthcare Software Development?

Healthcare Software Development

OpenCV Image Processing

736+ Whatsapp Group Links — Join Now

Senior Engineer: How to lead a project

Containerizing the react app in a Docker container

Edge Persistence: living in the edge

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Harm van den Brink

Harm van den Brink

Cyber security, smart grids, electric vehicles, distributed ledger technology, hardware. Owner of Innoshift B.V. Articles on personal title.

More from Medium

KO Kings: Project Vision and Roadmap

Notice: DeployGate Ending New Personal Pro Plan Subscriptions

Best Automated Crypto Trading Bot Course? | My Honest Review Of Dan Hollings’ The Plan

Top 5 Tokens to Watch in 2022