Please recommend sensors for monitoring a 12V battery with 6A of load

Hullo all.

I need to do a thing which is likely completely trivial, but I have never done it before, and because I am a farmer, I need to do it without having to spend much money.

Briefest description:
I need to monitor the state of a deep cycle 12v battery that is usually trickle charging, and report on its health at regular intervals. Other automations need this data. I’m thinking of an ESP8266 (cos I have one) with a sensor.

There will be 6A of load on the battery when it is discharging. I don’t know enough about these kinds of sensors to know if that’s going to be a problem or not, and is the thing I’m most worried about.

Can you recommend a good, affordable sensor for this application?

Longer description:
My country’s power infrastructure is collapsing because of reasons. We experience this as 8-12 hours of power loss per day, usually spread out into nice little 4 hour chunks that screw up production most optimally.

One of the many exciting side-effects of this is increased theft because affordable backup batteries aren’t designed to be deep cycled 3 times a day. If there’s stuff you can’t afford to lose that’s in a shed somewhere, best you find a way to keep the cameras up. Replacing a battery regularly is cheaper than replacing industrial power tools regularly.

So for my existing setup in the farm store, there’s a 12V (Meanwell?) power supply that drives the IP cameras, the network switch, and the wifi antenna that links to the main house. It recharges a 12v backup battery, but not fast enough for the kind of stupidity we’re seeing. That means I need to monitor the health of that battery pack, so that I can manually intervene if necessary. Buying big kit is not a thing until the next harvest is in.

Me being me, I’d like to make this out of what I have on hand. I think I can spring for a sensor, but I likely couldn’t afford a management system. Out here on the perimeter, there are no stars.

So I want to monitor the charge level of a 12V battery that will likely trickle charge all the time. I’ll use automations to alert me if the voltage drops below a certain point.

I have both ESP8266 and ESP32 chips in stock, breadboards, soldering wire, etc etc. My initial googling says that INA219 can monitor a 12V current, but having never worked with it, I’m concerned that it might catch on fire if the load is relevant.

Suggestions of both sensors and totally different approaches are welcome.

Thanks everyone.

Are you trying to measure the voltage or the current being drawn.

The level of charge is generally measured via the voltage.

Hi @nickrout, thanks for the response.

Voltage only.

Use case is that voltage below 12.2v requires my intervention, but don’t bother me otherwise.

It’s just that when I read the spec for INA219, it started mentioning amps, so I became concerned that the sensor would burn if a 12V load bigger than 3.2A passed through it. My understanding of these things is pretty basic, is why I’m asking. If the sensor doesn’t care about the load, neither do I.

1 Like

INA219 measures current as well as voltage and most of the available boards max at 3.2A, due to the tiny shunt resistor they use.

You can measure the voltage of the 12V battery directly using one of the ADC pins and a voltage divider.

image

V-out needs to be less that 3V at the maximum expected battery voltage (15.8V or thereabouts?).

https://ohmslawcalculator.com/voltage-divider-calculator

1 Like

Here a good article that uses a couple of MOSFETs to turn off the sense circuit to avoid draining your battery through the divider network.

1 Like

Hi @zoogara, thank you for that wonderful reading!

Look I’ll be honest, I’m more competent with a circular saw than an IDE, is part of why I use ESPHome. Nevertheless, I’m also the kind of stubborn bastard that gets annoyed when he can’t figure a thing out, which is often, because of not being generally fast on the uptake. You must appreciate that my degree is from UTube.

So I’m looking at the circuit diagram in your Ohms Law Calculator, and I’m trying to figure out what that would look like arranged on a piece of perf board. I’d like to tell you what I see, and you can tell me how wrong I am; super useful info.

Behold as I display my ignorance; it’s a miracle I haven’t killed myself yet.

So. On the left of that image it says Source Voltage. So I’m understanding that to mean, it’ll be connected across the battery, + and -.

Those two leads (now neatly connected to a perf board) head over to some resistors. The one that’s connected to the battery’s + terminal goes through Resistor R1. It is there joined by the - terminal, which has passed through Resistor R2.

That joined lead heads off , and … this is where I get stuck …

There’s another signal path that comes from just before R2 and it goes to …

Where? Do those two lines join at the analog pin of whatever microcontroller I use?

… and this is where I get even more wobbly … am I not putting a cap or a mov somewhere to protect this circuit when the inevitable blart from some power spike in the system rolls through? If so, before this voltage divider circuit? Or after?

Those are a lot of questions. If you do find time to answer, I’d appreciate it, because I always love to learn new stuff. Incidentally, you are never to old to learn. Trust me.

I’m doing this with a Shelly Uni. It’s attached to my car’s 12v battery to monitor it as there was a nasty bug in the car’s firmware which didn’t charge it frequently enough, killing the battery over a period of 2 years.

https://www.shelly.cloud/en-us/products/product-overview/shelly-uni

The Uni has an ADC which you can set in the low or high resolution range and will provide graphs in HA as required. You can control devices off it, such as trigger a charger, etc.

Let me know if you want more info - I can’t connect to it just now as the vehicle isn’t in WiFi range just now, but I can take screenshots later tonight.

5 Likes

The negative terminal of the battery connects to the ESP GND pin. The other line goes to an ADC pin, say GPIO32 on an ESP32.

You then need to set up a sensor in ESPHOME. On an ESP32 use attenuation: AUTO and a filter to multiply the reading by a suitable factor to get back to 12V. An example:

sensor:
  - platform: adc
    name: "Battery voltage"
    pin: GPIO32
    accuracy_decimals: 2
    update_interval: 60s
    attenuation: AUTO # or 11db if AUTO doesn't work
    filters:
      - multiply: 4.0  # The voltage divider requires us to multiply some factor to get back to 12V

See:

Not qualified to answer that one - sorry :slight_smile:

Remember: Before connection to the ESP use a multimeter on VOUT to ensure voltages do not exceed 3V.

Use a multimeter on your 12V battery determine the filter multiplication value.

1 Like

@zoogara Thank you so much. I actually think I can manage that. Thank you for such a detailed response, that’s fantastic.

@RonnieLast That’s very nice indeed. Hadn’t thought of displaying the data, but now I’m thinking about a frontend warning of some kind. Thank you for sharing.

Hi there.

You may want to check out this video from Chris (easy to follow and build from this).

If it’s just voltage you want to measure, then this is ideal, and installs with ESPHome.

If you need code for this “Sensor” module, then give me a shout as the voltage divider modules are all very closely spec’d in tolerance, so, from one unit to another I haven’t really had much discrepancy. I also have some silly code for pushing the notifications to HA for when the battery is ok, low or high (Faulty chargers happen).

Monitoring Voltage with ESPHome, D1 Mini ADC, and Home Assistant - YouTube.

If you are planning on doing the whole current and power etc, (as I have after building my esp8266 with the voltage divider, purely because I like to micro manage things), then as stated above, the INA219 is absolutely brilliant, and with a length of 2,5mm flat twin and earth, you can substitute the shunt resistor with a good length of “Serious copper wire” and up the max current.

I built my original “Battery Monitor” with just a buck regulator, the esp8266 and the voltage divider, and I can give you the wiring diagram for that setup if you like, it was not pretty, but it served me well as I had 2 of these on my micro solar setup, and they are now in the process of being repurposed for the 2 vehicles to monitor the battery levels.

Shelly Uni can measure 12V DC and report it to home assistant easily

5 Likes

Dabbling is solar power here in the US. I have the same need as DeeBeeKay. I just ordered the Shelly UNI, so how would you wire it up to just monitor the voltage?, I have a kplink smart outlet that the charger is plugged into so i done need to use the UNI as a switch…
(Sorry if stupid question)

Hi, as far as I recall I have pins 1 (positive) & 2 (negative) connected to the battery with pin 3 (ADC) also going to the positive side of the battery. Then configure from the web connection. I don’t have it here just now to check, the vehicle is on the road currently.

Just to mention that in my case I’m monitoring an EV 12v battery, so I don’t have spikes on engine-start, but it’s worth mentioning that if this was deployed on a vehicle with a fuel-engine that you should be adding a large enough cap as close to the Uni as possible to even out those spikes.

Thanks to this thread, I now have my 12 V battery on my car monitored with Shelly Uni Plus. Some clarifications:

  1. Get yourself a Shelly Uni Plus
  2. Wire together VAC1 and Analog in
  3. Wire together VAC2 and GND
  4. Connect the Shelly Uni to a power source - Analog in and VAC1 goes to positive .
  5. In the Shelly Web UI, go to Peripherals and add Voltmeter
  6. In the Shelly Web UI, set a static IP (Gateway and DNS is probably the IP of your home modem)
  7. Add the Shelly Uni to Home Assistant using the static IP.

Comments:

  • As my 12 V was in the car in the cold rain, I took benefit from the Shelly Uni accepting a wide voltage for power supply 9-28 V DC, and used a power brick from a decommissioned gadget for doing the setup

  • I added the Voltmeter to the Shelly Uni after adding the Shelly Uni to Home Assistant, and then I had to remove the Shelly Uni and add it back again in Home Assistant to see the voltmeter in Home Assistant.

  • I’m positively surprised by the wifi range of the Shelly Uni Plus.

  • Now I just need to figure out a way to make the Uni stay safely in the car. Considering buying the smallest food storage container, extension cables, hot glue and cable ties :smiley:

2 Likes

Im curious how it will drain the battery? versus a BLE sensor.

I have Wifi everywhere: house, 2 garages, in a 100 foot tower to cover all my yard and in my parents house that are linked with us on my wifi system so a wifi battery monitoring is way more interesting for me instead of BLE proxy.

Waiting for your results !

There is discussion of power consumption in this scenario here Monitor your car battery in Home Assistant

The Shelly Uni Plus only consumes <1W (83mA) so it’s probably good for around a year, without charges, on a 60AH 12v battery.