# Simulating battery charge & discharge component

Hey there,

I want to create some kind of component which helps me a bit with my Niu NQi Sport Battery (eScooter).
The eScooter can be charged directly by plugging a cable into it. Thats not the way I am charging it, as I dont have a electricity in the garage and thus, I have to unplug the battery from the scooter and charge it somewhere else.

When the battery is unplugged, I have a sensor where the last known percentage of it is exposed until the battery is re-plugged.

So I have the “last known state” available. I want to have some kind of sensor, which I can use to simulate the natural discharge of an unused lithium battery.
I think this can be done with Node-Red or an automation where I subtract a specific amount of “percent” every X Minutes/Hours.

So this might help me to determine when I have to charge the battery so it does not drop down to 0% which causes harm to a lithium battery.

So, the next step would be: when I plug the charger into the Battery, I want to trigger an automation or flow in Node-Red which handles the charging. I need to know how long it takes to charge 1% of the Battery when it is not being used (when charging it within the scooter, this might take a bit longer as it consumes power for the ECU - control unit which provides GPS and stuff).

As far as I know, lithium batteries are being charged quite quickly when they’re charged less than 80%? So I probably need some kind of logarithmic logic to raise the percentage…

As you can see, its not that simple to have a simulating component for charge and discharge of a lithium battery.
Does anyone have other ideas?

The concept that comes to my mind is to have a helper with the power charge value and a timer that gets started when you unplug the battery and each iteration of the timer would cause the helper value to change. Fairly low-brow but it seems like it would do the trick.

1 Like

Yah, something like this came to my mind aswell.
I wonder if there is some kind of specification which says how much kWh are “lost” when the battery is not in use tho. But I could also do some samples like:

• plug battery in
• grab current battery percentage
• unplug battery
• wait a few hours
• plug battery in
• grab current battery percentage

But I dont think that this might be a good way to determine the power consumption…
I’ve found this this article but I am unsure if thats really the case. It says that a lithium battery is discharging 5% in 24h and then 1-2% per month. I am unsure if that is really the case but I could verify this probably with some samples tho.

I think I will give this a try and then gather the informations I have and create some node-red flows.

I think you can get some decent baselines from information online, but the rest is going to be trial and error.

1 Like