Home > Other > Solar > DIY Victron Smart Shunt

DIY Victron Smart Shunt

Esp32 based Victron SmartShunt 500A project

Overview

This project uses an INA226 shunt amplifier to implement some smart shunt functionality. It sums up the charges that move through the shunt. With this information it tries to calculate the load status of an attached battery. The INA226 should be connected to the shunt so that charges going into the battery are positive and those coming out of the battery are negtive.

The smart shunt has three main interfaces.

  1. A web interface for human users. It allows setting the main parameters of the system and displays the current status of the system
  2. A modbus interface that is based on a PZEM017 energy meter but enhances it with the values mentioned above
  3. Victron VE.direct Text and Hex protocols in order to function as a Battery Monitor. The Hex protocol is only implemented as far as it’s required for startup. Furthermore, some fields of the Text protocol are not yet filled correctly.
  4. An API returning values a JSON payload, for use without the USB interface.

Hardware

For measuring the current you need an INA226 breakout board as you can acquire from Amazon.

Some of the boards have a different pinout. The SDA and SDL pins are swapped in comparison to others. So please check this if you can’t get a connection to the sensor.

As miocrocontroller I settled for Espressif products. This code has been tested with a Wemos D1 Mini, a Wemos S2 mini and a 8266 Nodemcu. I didn’t test any ESP32 WROOM boards, but they should work too. I settled for the D1 mini due to its small footprint and powerful CPU. I got mine from Amazon

You also need a shunt, since the small resistor on the board (don’t forget to remove it!) will not survive the high currents of a PV plant. There are plenty of options out there. Make sure that you select a resistor appropriate for the currents you expect. I’m using a 20A/75mV shunt.

The D1 needs a USB power supply, to power it, I used a 12v to USB converter connected into the same DC system as being measured. Make sure the Battery – is connected to the GND potential of the sensor. Otherwise the voltage measurements will be invalid, since the INA226 has only one GND. Furthermore, you should use an isolated USB module to connect the D1 to the target. You can destroy your computer or Victron GX if you connect it directly to the USB of the MCU.

Before you can use the sensor board you have to remove the shunt resistor soldered to that board and instead use a bigger shunt, e.g. a 100A/75mV. Make sure that the shunt supports the current your system produces. You can set the parameters of the shunt in the web interface. A wide variety of shunts can be found on Amazon, EBay or other platforms.

If you have a 48V System, be aware of the fact that the INA226 does only support voltages up to 36V (40V max). You need a voltage divider to make sure your sensor is not destroyed. The code assumes that you use a 470K Ohm and a 1M Ohm resistor, measuring across the 1MOhm towards GND. ( + --470K-- --1M -- GND ) This works for a 16S LifePO4 battery. The smaller you choose the small resistor in comparison to the bigger one, the more accurate the measurement will be.

Optional Temperature and Humidity monitoring using a AHT20 I2C Temperature Humidity Sensor

Smart Shunt Circuit diagram

https://crcit.net/c/93609e4da6e9468ea96ee64330156ded

Software

The Software has been created using platformio and the Arduino environment. In order to build it you also need some libraries.

  • the INA226lib The latest version should work with this code.
  • emelianov/modbus-esp8266
  • locoduino/RingBuffer
  • prampec/IotWebConf

The latter three will be automatically downloaded when using platformio.

https://github.com/IanCarruther5/SmartShuntINA226

Set up

The configuration field Voltage calibration factor can be used to calibrate the voltage reading of the sensor. Set it to 1000 and then simply divide the real battery voltage by the value the sensor shows and multiply it by 1000. The same can be done for the current in the field Current calibration factor. If you entered the shunt resistance correctly, a value close to 1000 is expected here. Mine is 1028.5.

Yield: 1

DIY Victron SmartShunt

Arduino based SmartShunt

This project uses an INA226 shunt amplifier to implement some smart shunt functionality. It sums up the charges that move through the shunt. With this information it tries to calculate the load status of an attached battery. The INA226 should be connected to the shunt so that charges going into the battery are positive and those coming out of the battery are negtive.

The smart shunt has three main interfaces.

  1. A web interface for human users. It allows setting the main parameters of the system and displays the current status of the system
  2. A modbus interface that is based on a PZEM017 energy meter but enhances it with the values mentioned above
  3. Victron VE.direct Text and Hex protocols in order to function as a Battery Monitor. The Hex protocol is only implemented as far as it's required for startup. Furthermore, some fields of the Text protocol are not yet filled correctly.

Instructions

  1. First take a piece of stripboard 9 tracks wide and links to join D2 to header 3 (track 3) and D1 to header 4 (track4). +3.3v to JST pin4 (track 6) and gnd to JST pin1 (track 9)
    Shunt Circuit board links
  2. Add JST 4 pin connector to the bottom right connected to track 6-9
    Shunt circuit board JST connector
  3. Add a 8 pin header soldered to tracks 1-5
    Shunt circuit board header
  4. Cut tracks 6-8 one from header so no connection is made from pins 6-8 of the header. Cut track 52 down from the header so that D5 can connect to the header but is isolated from the rest of the board. Cut track 6 one up from the JST to break the connection.
    Shunt circuit board breaks
  5. Solder in header pins from 3v3, gnd ,D5, D2,D1 Tx and RX (these are the only pins used.
    Shunt circuit board IC connectors
  6. Solder the D1 mini on to the header pins 3v3, gnd ,D5, D2,D1 Tx and RX
    Shunt circuit board ESP32
  7. Solder 8 pin header (keep as much as possible protruding to allow contact to the D! board header), 1M resistor from pins 2-6 (gnd to ALE) and 470k from ALE to 3pin JST 3pin 1. Solder 4 pin JST to pins 1-4 and 3 pin JST to pins 6-8
    Shunt circuit board INA226 header
  8. Remove resistor from INA226
    INA226 with Resistor removed
  9. Solder INA226 to header pins
    Shunt circuit board INA226 header
  10. Put D1 mini board in case
    Shunt circuit board in case
  11. Put divider in case
    Shunt circuit board in case
  12. Fit INA226 daughter board
    Shunt circuit board in case
  13. Make up JST to JST cable
    Serial Cable
  14. Plug in comms cable
    Shunt circuit board in case
  15. Fit lid
    Shunt circuit board in case
  16. Put TTL USB in case
    Shunt USB UART board in case
  17. Plug in comms cable
    USB Serial UART
  18. Fit lid
    UART to USB module
  19. Finished Shunt
    Smart Shunt packaged

Did you make this project?

Please leave a comment on the blog or share a photo on Pinterest

https://www.amazon.co.uk/hz/wishlist/ls/1I6J6VZ0SYMQA?ref_=wl_share

If you liked this you might like my DIY temperature sensor.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *