NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: how to control battery charge level on a laptop



adr <adr%sdf.org@localhost> writes:

> On Wed, 22 Oct 2025, Michael van Elst wrote:
>>>  1) design capacity is said to be 5.376Ah, but written directly on the
>>> battery is 7.7V, 41Wh (=~5.324Ah) and nominal 5350mAh.  While small, the
>>> battery is being overcharged to 5.376Ah (101%).  Is there a way to
>>> correct the design capacity to 5.324Ah, and force the machine to keep
>>> the charge no higher than 5.324Ah?
>>
>> No. The value is reported by the battery.
>>
>> It's also unclear if you can influence the charging process. Some
>> laptops (like Thinkpads) allow this, others do not. If they do,
>> they use some vendor-specific methods.
>>
>>
>>>  2) the CritMax and WarnMax entries are blank.  Is there a way to
>>> inform the machine of these parameters, and issue a warning and stop
>>> charging the machine until the issue is resolved?
>>
>> You can set values, and this notifies powerd to trigger some action.
>> But you cannot stop the charging process. Best would be to play
>> an alarm signal telling you to remove the power cord.
>
> If there is real need for this, like a hw bug, I would recommend
> to use the opportunity to play building a small usb->gpio + relay
> between the barrel jack and the laptop. You can then used powerd
> to control the charging of the battery. Is there something like
> the MCP221A sopported by netbsd? There are really cheap boards in
> aliexpress. But this smells like a cheap or defective (old?) battery.
> Batteries come with overcharging protections, the hardware inside
> the batteries is more sofisticated than what people usually think.
>
> adr.


Yes.  umcpmio(4) and umcpmioctl(4) works with the MCP2221A.  I use it
for the I2C functions and sometimes the clock output, but simple GPIO
will work.  No GPIO interrupt support and you can't attach through it,
so no gpioow(4) and the like is possible.  I got mine from Adafruit, but
you can roll your own breakout boards if you can do SMD soldering.  It
requires very little in terms of additional components.  Adafruit
publishes the schemetics to their breakout.


https://mail-index.netbsd.org/source-changes/2024/12/16/msg154864.html




-- 
Brad Spencer - brad%anduin.eldar.org@localhost


Home | Main Index | Thread Index | Old Index