Project – Shunt – battery monitor

A lot of people asking questions about how to monitor the battery of a solar system, well here is the answer.

How do you measure a battery capacity?
Many people think that voltage is a good way to measure capacity, it is not. Voltage can change under load, so it floats around and therefore is not a good indication of SOC.

How to measure a battery capacity?
Battery capacity is usually wrote on the battery, like 100ah. This measure is set out in how the battery is tested, outside of that test spec, the capacity may be more or less. So keep that in mind.

What is a good way to measure a battery capacity?
This is the project we have here, you should be able to make this and we will put a kit in our shop.

The project

A coulomb counter is a device that measures the amount of charge that flows into or out of a battery. It does this by measuring the current flowing through the battery and integrating it over time. The integral of current over time is equal to the charge, which is measured in coulombs.

Here’s how a coulomb counter works:

  1. Current Measurement: A small resistor is placed in series with the battery. The voltage drop across this resistor is proportional to the current flowing through it, according to Ohm’s law.  
  2. Voltage Measurement: The voltage drop across the resistor is measured using an analog-to-digital converter (ADC).  
  3. Integration: The ADC output is integrated over time to calculate the total charge that has flowed through the resistor.  
  4. Charge Calculation: The integrated value is converted to coulombs using a known conversion factor.
  5. State of Charge (SOC) Calculation: The coulomb counter can calculate the SOC of the battery by comparing the current charge to the battery’s rated capacity.

Coulomb counters have several advantages over other methods of battery state of charge measurement:

  • Accuracy: Coulomb counters provide a more accurate measurement of battery state of charge than voltage-based methods, especially when the battery is partially discharged.
  • Reliability: Coulomb counters are not affected by battery temperature or aging, which can affect the accuracy of voltage-based methods.
  • Flexibility: Coulomb counters can be used with a variety of battery chemistries, including lithium-ion, nickel-metal hydride, and lead-acid.

Buy not make!

If you do not want to make you can buy the coulomb from the shop… which is above, or our other meter here 60v Power meter LCD — RenewSolar.


Here is a ready made solution with optional screen and RS485 communications. Go to the shop




Making your own coulomb counter.

Making something smart is the first point of call, we don’t want a trip to the battery late and night to find out how much power we have, so having wifi access or MQTT is going to be the best option, we could use Bluetooth, but then we have to be in range and make a app.

Rather than make component parts, by hand; we want to avoid user variations as the unit has to them be calibrated for everyone which is made, this can take a long time and when we are building hardware for clients on commission this is a PITA part of any build.

We will need:
esp32 mcb
ADC current sensor / Shunt.
ADC Voltage sensor.
Voltage regulator.
Project box.

The ESP32-S3 is an excellent choice for a Coulomb Counter project due to its powerful features and low-cost. Here’s a breakdown of its key capabilities:

1. Wi-Fi Connectivity:

  • Remote Monitoring: Enables real-time data transmission to a remote server or mobile app, allowing you to monitor battery health and usage from anywhere.
  • Data Logging: Stores historical data for analysis and future reference.

2. Local Display:

  • User Interface: Provides a visual interface to display current battery status, charge/discharge rates, and other relevant information.
  • Intuitive Control: Allows users to interact with the device, such as setting thresholds or calibrating the counter.

3. Analog-to-Digital Converter (ADC):

  • Precise Voltage Measurement: Accurately measures battery voltage to calculate energy consumption and remaining capacity.
  • Current Sensing: Monitors current flow in real-time to determine charge/discharge rates.

Additional Benefits:

  • Low Power Consumption: Ideal for battery-powered devices, minimizing energy usage.
  • Multiple Cores: Offers efficient multitasking, allowing simultaneous handling of Wi-Fi, display, and ADC tasks.
  • Rich Peripheral Set: Provides various interfaces (SPI, I2C, UART) for connecting to sensors, displays, and other components.
  • Secure Boot and Encryption: Ensures data security and protects against unauthorized access.

Choosing between an I2C Current Sensor and a Shunt.

The optimal choice between an I2C current sensor and a shunt for a 200A application depends on several factors, including accuracy, cost, complexity, and the specific requirements of your project. Let’s break down the pros and cons of each:

I2C Current Sensor:

Pros:

  • Ease of Use: Often comes in pre-calibrated modules that are easy to integrate.  
  • Isolation: Provides electrical isolation between the measurement circuit and the high-current path, reducing noise and interference.
  • Accuracy: Can offer high accuracy, especially for lower current ranges.

Cons:

  • Cost: Can be more expensive, especially for higher current ranges.
  • Power Consumption: May require additional power supply.
  • Bandwidth Limitations: May have limitations on the maximum sampling rate, which could affect the resolution of transient measurements.

Shunt Resistor:

Pros:

  • Cost-Effective: Generally more affordable.
  • Simplicity: A relatively simple circuit involving a resistor and an ADC.
  • High Accuracy: Can achieve high accuracy with careful component selection and calibration.

Cons:

  • Power Dissipation: Can dissipate significant power, especially at high currents, requiring careful heat dissipation.  
  • Voltage Drop: Introduces a voltage drop across the resistor, which can affect the overall circuit performance.  
  • Noise Sensitivity: Can be sensitive to noise and interference, especially in high-noise environments.

Recommendation:

For a 200A application, a shunt resistor is generally a more cost-effective and practical solution. However, consider the following factors:

  • Accuracy Requirements: If you need extremely high accuracy, an I2C current sensor may be a better choice.
  • Noise Environment: If your application is in a noisy environment, an I2C current sensor with isolation can help reduce noise interference.
  • Power Budget: If power consumption is a critical concern, a shunt resistor with a lower resistance value can reduce power dissipation, but it will also reduce the voltage drop across the resistor.  

By carefully considering these factors, you can select the most appropriate solution for your specific needs.

Additional Tips:

  • Calibrate Your Measurement System: Ensure accurate measurements by calibrating your system using a known current source.
  • Consider the Power Rating of the Shunt Resistor: Choose a resistor with a sufficient power rating to handle the maximum current.
  • Use High-Precision ADCs: A high-precision ADC will improve the accuracy of your current measurements.  
  • Filter the Analog Signal: Filtering the analog signal can reduce noise and improve the accuracy of the measurements.

By following these guidelines, you can implement a reliable and accurate current measurement system for your 200A application. We do not recommend user calibration as this requires software programming ability as well as tools to make the accurate measurements.

Building a Battery Coulomb Counter with ESP32, I2C Shunt, and Voltage Regulator

Understanding the Components

Before we dive into the project, let’s understand the role of each component:

  1. ESP32: A powerful microcontroller that will handle the calculations, display, and communication aspects of the coulomb counter.
  2. I2C Shunt: A device that measures current flow by sensing the voltage drop across a shunt resistor. It communicates with the ESP32 via the I2C protocol.
  3. Voltage Regulator: A device that reduces the battery voltage to a level suitable for the ESP32’s operation.

Circuit Design

1. Power Supply Circuit:

  • Voltage Regulator: Connect the battery to the input of the voltage regulator.
  • Output Voltage: Set the output voltage of the regulator to 3.3V or 5V, depending on the ESP32 model.
  • Power Supply to ESP32: Connect the output of the regulator to the power supply pins of the ESP32.

2. I2C Shunt Connection:

  • Connect I2C Pins: Connect the SCL and SDA pins of the I2C shunt to the corresponding pins on the ESP32.
  • Power Supply to Shunt: Connect the power supply pins of the shunt to the regulated voltage from the regulator.
  • Ground Connection: Connect the ground pins of the shunt and ESP32 together.

3. Voltage meter:

  • Use a voltage divider to read the battery voltage.
  • Use i2c Voltage reader board, so that you do not need to calibrate the voltage divider.

Software Implementation

1. Library Installation:

  • I2C Library: Install the necessary I2C library for your ESP32 development environment.
  • Shunt Sensor Library: If the shunt sensor has a specific library, install it as well.

2. Reading Current and Voltage:

  • Initialize I2C: Initialize the I2C communication with the shunt sensor.
  • Read Current: Use the I2C library to read the current value from the shunt sensor.
  • Read Voltage: Use the ADC of the ESP32 to measure the battery voltage.

3. Coulomb Counter Algorithm:

  • Calculate Instantaneous Power: Multiply the current and voltage readings.
  • Integrate Power Over Time: Integrate the instantaneous power over a specific time interval to calculate the energy consumed or delivered.
  • Convert Energy to Coulomb: Divide the energy by the battery voltage to get the Coulomb count.

4. Data Logging and Display:

  • Serial Monitor: Print the current, voltage, and Coulomb count to the serial monitor for debugging.
  • Display: If you have an LCD or OLED display connected to the ESP32, display the relevant information.
  • Data Logging: Store the data to an SD card or transmit it to a cloud platform for remote monitoring.

Integrating MQTT and a Web Server into Your Coulomb Counter

Understanding MQTT and Web Servers

Before diving into this part of the implementation, let’s briefly understand the two technologies:

MQTT: A lightweight messaging protocol, perfect for IoT devices like the ESP32. It allows devices to publish data to a broker and subscribe to topics to receive updates.

Web Server: A software application that processes HTTP requests and sends HTTP responses. In our case, we’ll use the ESP32’s built-in web server capabilities to serve a simple HTML page that displays the Coulomb counter data.

Implementations

1. Install Required Libraries: Ensure you have the necessary libraries installed for both MQTT and the web server. You might need to use a library like PubSubClient for MQTT and the built-in WiFi and ESP8266WebServer libraries for the web server.

Accessing the Data

  1. Local Access:
    • Connect to the ESP32’s Wi-Fi network.
    • Open a web browser and enter the ESP32’s IP address.
  2. Remote Access:
    • Set up a MQTT broker and configure the ESP32 to connect to it.
    • Use an MQTT client or a web-based MQTT dashboard to view the published data.

Additional Considerations

  • Security: Implement security measures to protect your ESP32 and the data it transmits.
  • Power Optimization: Consider using low-power modes to conserve battery life.
  • Error Handling: Implement error handling mechanisms to gracefully handle unexpected situations.
  • Data Persistence: If you need to store data for long periods, consider using an SD card or a cloud storage solution.

By following these guidelines and customizing the code to your specific needs, you can create a powerful Coulomb counter with remote monitoring and local access. You can also add functions by integrating into something like home assistant or maybe you would want to start a generator at low voltage?

There are a few options here with what you can use and how your integrate this battery capacity meter into your solar setup, Maybe you have solar assistant, home assistant or want to program certain switching parameters directly from the ESP.

You can follow programming and circuits within the forum

CATEGORIES:

gadgets-Projects

No responses yet

Leave a Reply

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