Solar Energy Storage System

pascal boudalier
4 min readMar 24, 2023

--

connect grid energy meter and battery via wifi

An Energy Storage System. source Victron

I just added an Energy Storage System (ESS) on my self consumption solar installation.

The purpose of an ESS is to store excess solar in a battery during the day , and discharge the battery to provide power to the home at night.

I use Victron‘s Multiplus as the core of the ESS. The Multiplus manages the charge and discharge of the battery, based on solar production and home energy use.

The objective of this article is not to describes the ESS in detail, but to focus on one specific aspect: how to connect an Energy Meter to the ESS via WiFi.

Role of the Energy Meter in an ESS

The ESS needs to know the status of the AC current flowing between the house and the grid:

  • if current flows to the grid, the solar system is currently exporting, and this surplus shall instead be used by the ESS to charge the battery
  • if current flows from the grid, the ESS needs to start discharging the battery to power the home

An Energy Meter , installed in the main panel, provides this information.

The ET112 Energy Meter is installed at the connection point between the home and the grid

The meter needs to be connected to a USB port on the Multiplus (Victron provides such a cable).

However, in some instances, the energy meter (in the main panel) and the Victron system are far apart. Running a cable can be very unpracticable.

Note: Victron provides a wireless solution based on zigbee.

I already had installed a Raspberry PI in the main panel (used for home automation), and another one closed to the Multiplus (used to monitor the battery).

So what about re-using those Raspberry to connect the meter and the Multiplus via WiFi ….

usb2wifi (available on github) provides a real time, bidirectional relay between the Energy meter and a USB port on the Victron equipment, over wifi. It is implemented in python.

The data flow:
Energy Meter <-> RS485 <-> USB (serial) <-> raspberry PI <-> wifi <-> raspberry PI <-> USB (serial) <-> Victron
The Raspberry PI on the Energy Meter side. The white cable connects to the energy meter via USB. Black is power. A small custom PCB is used to host an OLED display
The Raspberry PI on the Victron side. The black cable connects to USB. The white cable is power

The relay logic is quite simple. It does not need to decode the protocol used by the energy meter (ET112 MODBUS), but to relay bytes back and forth (taking care of any timing requirements).

As the usb2wifi application is meant to run forever, unattended, much attention is given to application management

  • keep-alive threads (detect if the wifi connection is lost, and if so restart/resynchronize the application)
  • application automatically restarted if not running
  • integration with push notification, email
  • integration with system level monitoring (Monit)
  • display to show statistics on packet exchange.
  • led pulses every time data is received.

As an example, see above push notifications received on my smartphone, as part of the application start up sequence

From bottom to top:

  • first two entries: the usb2wifi application is starting on both the em (energy meter) and the gx (victron)
  • next two: the raspberry on the Victron side got a message on the USB serial port (a command, sent by Victron, which is trying to communicate to the ET112)
  • next one: the raspberry on the Energy Meter side is getting the above command from wifi
  • next two: the raspberry on the Energy Meter side is getting a message from the USB serial port (the response from the ET112)
  • last one: the raspberry on the Victron side got the response from wifi

This sequence validates that the energy meter and the Victron side are communicating correctly

— — — — — Do not cross this line if you are not interested in details — — — — —

The ET112 uses the MODBUS protocol, on a RS485 physical layer.

RS485 is meant for “industrial” environment (allows for long cabling distances, electrically noisy environments). It is quite popular on the factory floor. It uses just two data wires.

MODBUS is a based on serial, asynchronous communication, so quite easy to process with any python serial library.

Modbus frame

--

--

pascal boudalier

Tinkering with Raspberry PI, ESP32, RiscV, Solar, LifePo4, IoT, Zigbee, energy harvesting, Python, MicroPython, Keras, Tensorflow, tflite, TPU. Ex Intel and HP