Are you trying to measure the voltage or the current being drawn.
The level of charge is generally measured via the voltage.
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.
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.
V-out needs to be less that 3V at the maximum expected battery voltage (15.8V or thereabouts?).
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.
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.
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
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.
@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.
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:
VAC1
and Analog in
VAC2
and GND
Analog in
and VAC1
goes to positive .Peripherals
and add Voltmeter
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
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.
Hi.
I know it’s an old thread, but I am trying almost exactly what you are doing.
Only difference, I would like to publish the voltage over mqtt.
That way I could do a hotspot in the car and have the values even when not at home
I just can’t find a way to get the shellyplusuni to publish the voltage, do you know if it is possible to do this?
I don’t have a uniplus, but most shelley products support MQTT. It should be in the Shelly’s web gui.
EDIT: If it is the same as my other shellies, go to internet and security, Advanced Developer Setting, In there is a setting to enable MQTT. Enable that and the options for server, password etc will pop up.
Thank you for replying.
Maybe I should create a new thread for this?
Unfortunately, the plusuni does not have same interface as ‘normal’ shelly devices.
The MQTT settings are these:
It IS publishing something, just not the values i am interested in
I am not that fluent in MQTT; but have a feeling i can send a command to the plusuni and have it return the voltage - but don’t know how to do this…