User Guides DIY Wi-Fi Battery Monitor for Inverters/UPS (IoT Lead Acid Battery?)

A Never Ending Back Story:

About two and a half years ago, I bought an inverter that needed four batteries running at 48V:


IMG_20210416_020130.jpeg

The inverter was paired with four Amaron Quanta batteries, this was a decision I made — I thought the were really cool looking, colour matched the inverter nicely, didn't need any maintenance and I later learned that this kind of lead acid battery (vrla/agm) doesn't have any corrosion on the battery terminals as you would see in flooded lead acid batteries. I also found out that there are detailed datasheets with charge/discharge curves (with Peukert's law taken into account).



I also did the installation on my own, and I never did something like this before. How hard could it be? Turns out, there's more to this than just wiring up four batteries in series. The terminals should be scrubbed down until the copper is nice and shiny, the batteries should be pre-charged individually for a day each, and it's a good idea to check to see if the batteries are from the same batch.

I didn't do any of that and I didn't notice that one of the four batteries did not have a serial number that was sequential with the others. It was also missing the Q sticker on top of the battery, which was present on the other three batteries. For whatever reason, this battery was different — either a customer return or exchanged/forgotten stock.

And two years later that battery is now dead with a shorted cell inside (12V lead acid batteries have six cells inside of them). Run time has come down from a few hours to a few minutes as a result. Because of the shorted cell, the other batteries suffered and never charged fully (a lead acid battery with a shorted cell pulls more voltage, which prevents other batteries from getting a full charge).

Had I checked the voltages regularly, or had something that would report voltages, this issue might have been caught before irreversible damage was done to the other batteries:


After testing the battery voltages under load with a multimeter (and discovering the dead battery), I put together a few simple wi-fi monitors using ESP8266 controllers running Tasmota connected to INA219 current/voltage sensors and recorded these readings:

Screenshot_2023_11_20_01_46_30_117_org_telegram_messenger_web_edit.jpg

The dead battery fell to ~8V with a simple 25w load.

Screenshot_2023_11_20_01_48_14_041_org_telegram_messenger_web_edit.jpg

And when charging, it pulled over 14V, preventing the other batteries from charging fully.





So here in this guide, I'm rebuilding those battery monitors into a more permanent and usable version. One of the philosophies that has evolved in my DIY projects is not using any custom/bespoke PCBs/hardware, everything needs to be modular and easily available/replaceable. The need to get something working quickly again after a failure far outweighs any benefits a custom solution might have.

photo_2023-11-20 01.24.45.jpeg

I chose the Wemos D1 R2 ESP8266 module since it can be powered directly from the battery that's being measured. It also had unpopulated pinouts that I attached JST 2.5mm right angle connectors to for easier wiring. We're interested in five lines from the module, two for I2C and two for VIN and GND and a 3.3V to power the INA219. The connectors and wires were purchased from Sunrom:


photo_2023-11-20 01.24.46.jpeg

I used 10cm pre-crimped wires to connect to the INA219 module and 30cm wires to connect to the battery. There are two wires coming from each terminal of the battery to get the most accurate readings possible, without the voltage drop you might see if I were to measure the VIN voltage on the ESP8266 board instead. The INA219 modules have a 4mV resolution, which is more than what we need (100mV would've been enough). The INA219 modules are covered in transparent heatshrink, and there's heatshrink on the bullet connectors as well (transparent on the positive line, black + transparent on the negative line). These are the bullet connectors:


photo_2023-11-20 01.24.47.jpeg

The ESP8266 modules will be housed in a few generic 200ml food containers. Holes were marked, drilled out to 5mm and these snap fit PCB spacers were installed:


photo_2023-11-20 01.24.48.jpeg

photo_2023-11-20 01.24.49.jpeg

photo_2023-11-20 01.24.50.jpeg

I'm not using any strain relief in this version, and the exit holes are intentionally oversized to allow for some ventilation, if it's needed.

photo_2023-11-20 01.24.51.jpeg

Four completed monitors, one for each battery. As an aside, I looked at Stuart Pittaway's diyBMS and it uses a single ESP8266 module because his design relies on an isolated I2C bus that adds complexity and necessitates a custom PCB. The cost of each battery monitor here is around Rs 500, which is fairly reasonable despite using hobbyist modules.

photo_2023-11-20 01.24.52.jpeg

These are short battery connecting wires that I made with a separate wire to connect to each battery monitor. I would have liked shorter wires, but heatshrinking them would've been difficult. These aren't necessary, you can use your existing battery wires and just crimp a ring terminal for the battery monitors, like the two smaller ones here:

photo_2023-11-20 01.24.54.jpeg

photo_2023-11-20 01.24.53.jpeg

Before heatshrinking these larger aluminum ring terminals (they take 25 sq mm wire and have a 8mm hole), it's a good idea to sand down the edges of the crimp since they could tear the heatshrink.

photo_2023-11-20 01.24.55.jpeg

On the left, the bolts that came with the inverter, the middle is a high quality stainless steel hex head bolt and on the right is an absolutely beautiful socket head bolt. These are all M8 and the socket head one is 25mm long, purchased along with the flat washer and spring washer from indialocalshop:


photo_2023-11-20 01.24.56.jpeg

Here, the batteries are connected with the long 16 sq mm wires that came with the inverter (the fifth battery is the dead one that's been replaced)

photo_2023-11-20 01.24.57.jpeg

With the shorter cables and the battery monitors installed.

photo_2023-11-20 01.24.59.jpeg

Not too bad for what is essentially a prototype, maybe shorter wires next time.

photo_2023-11-20 01.25.00.jpeg

These socket head screws are so pretty.





From here, it's configuring Tasmota with your integration of choice (mine was Mikrotik's RouterOS and Telegram, but I'll be moving it over to MQTT/Node Red/InfluxDB/Grafana.
 
Last edited:
Hey This is interesting.

Can you please detail out what all information can the unit you built for each battery give as an output.
There is an LED indicator to depict some info. what are those?
Not sure if information can be transmitted to an app to set alerts?
Also how to DC input is the device taking in?
 
Well timed @rsaeon article. I am building something similar for my DIY UPS. Yours is more robust than what I am planning to build. I do not have a working prototype yet, but the idea is to use an ESP32 board and use multiple ADC inputs on it to measure the battery voltages. That works because my UPS uses 7AH batteries which are placed next to each other.
 
I'd definitely want to see how you make yours! My interest in electronics peaked with TTL/CMOS in the 9th grade and at that age I couldn't fully understand the equations associated with analogue circuits or the complexities of registers with microcontrollers — and I never grew out of that, I guess.

That particular ESP32 module that you linked, I saw it for a much better price on another shop, here: https://www.flyrobo.in/esp32-wifi-a...oled-development-board-with18650-battery-case It's a pretty cool module that I would love to find a use for some day. I usually buy XT60 connectors from that site.

I wish I had made these battery monitors a lot sooner (I've been thinking about them for over a year), I did a capacity test earlier today with a 1000W load and got a run time of only 20 minutes with the replacement battery, the other batteries are just too sulphated to handle the load anymore:

Screenshot_2023_11_20_15_28_15_729_org_telegram_messenger_web_edit.jpg

The Luminous Cruze+ 3.5kVA inverter I have beeps with a low battery alarm at 45V and cuts off power at 42V.

It'll be 15k to replace those three batteries with second hand ones, which I don't really want to do now.

But I probably would have to.
 
Awesome! You just saved me some money that I can now use to buy battery for that module. Your posts have inspired me to share my build log. I may not be able to match quality of your logs, but I will definitely will give it a try. :)

To avoid battery deterioration you can try using the Battery Desulfator devices.I have one fitted in my inverter battery. I was able to stretch life of my previous inverter battery to ~7.5 years. I have a spare that I can send to you for testing or you can order one from the supplier I recently bought more units. See if you are able to revive your old sulfated battery. Had it not been my ignorance towards checking water levels for the whole of pandemic, I could have had the battery still running. The battery was literally running on empty by the time I figured that it needed a top up. I had to pour ~12 litres of DM water to top it off. :weary:

Supplier details
Pioneer Industries
Office 5, Gokul Aprt.,Kevni Pada,
Off.S.V.Road Jogeshwari(W),
Mumbai-400102.
Mob.: 981972387
1700488638091.png
, 982102387
1700488638091.png
.
Website: www.pioneerfitting.com
Email: pioneerindustries@gmail.com sales@pioneerfitting.com
 
Can you please detail out what all information can the unit you built for each battery give as an output.

Not sure if information can be transmitted to an app to set alerts?

Hey, the ESP8266 modules are running Tasmota, it's an open source firmware for existing and diy wifi projects/devices that's geared towards home automation: https://tasmota.github.io/docs/

Flashing the firmware is as easy as connecting a USB cable and using their web flasher: https://tasmota.github.io/install/ These modules are running the Tasmota Sensors firmware because that version has support for the I2C module we're using here, the INA219.

The INA219 is actually a current sensor that also measures voltage, we're just ignoring the current/power measurements and using only the voltage readings.

You can access the data through a few ways, there's the web UI, MQTT, and web requests: https://tasmota.github.io/docs/Commands/

For the last five years or so, I've only ever used the web ui with Tasmota, it looks like this:

photo_2023-11-21 23.47.19.jpeg

This is one of my earlier wifi battery monitors that's connected to another inverter, I also added a temperature sensor and an addressable led to this one.

You can theoretically make a simple app that reads directly off the module, but it would far more useful if you added some kind of data logging server/vm. Tasmota publishes an MQTT message that's JSON formatted and looks like this:

JSON:
{
  "Time": "2023-11-21T23:43:11",
  "HTU21": {
    "Temperature": 31.4,
    "Humidity": 49.4,
    "DewPoint": 19.5
  },
  "INA219": {
    "Id": 40,
    "Voltage": 13.45,
    "Current": 2.633,
    "Power": 35.4
  },
  "TempUnit": "C"
}

This can be then used by something like Node Red to either store to a database or to send a notification over Telegram. Node Red is flow-based so it's incredibly intuitive. Here's a random flow:

Screen Shot 2023-11-21 at 11.54.38 PM.png

This flow monitors an MQTT topic for any messages sent when a VM goes offline (the MQTT message contains the hostname of the VM) and formulates a query to check InfluxDB on what is the last reported status of the VM by Proxmox (which is logging metrics to InfluxDB) and depending on whether the VM is running or stopped, it formulates a start or reset command to send to proxmox and once that command is sent, a message is formulated to send off to telegram, notifying me that a VM went offline and was brought back online.

None of that has to do with wifi battery monitors but it's an example of how a seemingly complex task can be accomplished with Node Red. Here's what a flow would look like with these battery monitors:

Screen Shot 2023-11-22 at 12.38.57 AM.png

The flows can be as complex or as simple as you'd want to make them, but you'll need to know the basics of javascript syntax.

Also how to DC input is the device taking in?

The Wemos D1 UNO module here can run between 6v to 20v, and the INA219 module can read voltages up to 26V.

There is an LED indicator to depict some info. what are those?

uno-based-esp8266-nodemcu-development-board-wemos-d1-.jpeg


The Wemos UNO D1 R2 module has three leds, two in the center of the board — one of those are for power (ON) and the other is for communication (SCK).

The third led is on the wifi chip, that's being used as a wifi/mqtt status led:



Here's the template I'm using for these monitors:

JSON:
{"NAME":"WEMOSD1R2","GPIO":[0,0,544,0,640,608,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}

All of this information may seem overwhelming but it's really very simple concepts once you start using them.

To avoid battery deterioration you can try using the Battery Desulfator devices.I have one fitted in my inverter battery. I was able to stretch life of my previous inverter battery to ~7.5 years. I have a spare that I can send to you for testing or you can order one from the supplier I recently bought more units. See if you are able to revive your old sulfated battery.

Thanks for the suggestion, I've contacted the company about buying one but I haven't gotten a reply. There's a detailed post of someone reviving dead AGM batteries from a couple of years ago that I found:


Their results sounds promising and their batteries exhibit the same behaviour that I'm seeing with mine. But I haven't been able to find anything about desulphating these Amaron Quanta batteries except for this excerpt:

Sulphation/Undercharge

If a battery has an open-circuit voltage lower than its rated
value, than sulphation may well be the cause. When a
battery is left in a discharged state or for prolonged periods
of storage, lead sulphate crystals begin to form, acting as a
barrier to recharge and will prevent normal battery operation.
Depending on the degree of sulphation, a battery may be
recovered from this condition by constant current charging
at a higher voltage, with the current limited to one-tenth of
the battery capacity, for a maximum of 72 hours.
Note: The applied voltage will exceed the normal
recommendation and so the battery must be monitored
(not left unattended) and removed from charge if excess
heat is dissipated. The voltage required to "force" this
maximum current into the battery will reduce as the battery
recovers, until normal charging takes place.
In extreme circumstances, a battery may never fully
recover from sulphation and must therefore be replaced.

It's from the last page here: https://www.amaronbatteryinverterchennai.com/files/amaron/Quanta Silver Book.pdf

But there's no more specifics given anywhere. Elsewhere online I read that desulphation only works above 15V. I guess I'll be experimenting with this in the next few weeks.
 
Last edited:
Wow. Somewhere around 2018 we (me and a friend) had developed similar stuff for making normal UPS smart with the addition of 8266 and some other circuity. I will be deploying this next year. This was part of industry 4.0 equivalent at that time.
 
Thanks Mr.Rsaeon,As a newbie to this,i followed your steps for everything to build a one.But not showing anything on the homepage of tasmota.Cud u pls stepup and check?
 
The Mr title is for my father, not me. I'm just me, ha.

Try and share as many photos as you can, I need visual aids. Also screenshots.

Also where are you located? Maybe I can drop by and see what's happening if you're local to 500001.
 
Back
Top