-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect charging status by measuring current flow with configured INA219 battery sensor #5271
base: master
Are you sure you want to change the base?
Detect charging status by measuring current flow with configured INA219 battery sensor #5271
Conversation
minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging
added comments and 2 extra defines to disable and swap detection direction
fix disabled case
minimal implementation: if there is a configured INA219 sensor for battery monitoring we can take the current flow across the shunt resistor to know if we are charging the battery - negative milliamps indicate charging
added comments and 2 extra defines to disable and swap detection direction
fix disabled case
90062a1
to
e54d259
Compare
…github.com/nebman/meshtastic-firmware into use-ina-currentflow-for-charging-detection
Thank you very much for this, very useful first contribution to Meshtastic :) I think I have a INA3221 lying around here to help test. What's the best way to wire these things up? |
Thank you and also thanks for offering your help to test! As it just happened, the mailman delivered me an INA3221 board some minutes ago :) If you give me some time I might be able to test it myself (also more coding is needed). |
code for INA3221 is up, using channel 1 for battery voltage and current monitoring, the charging detection works fine |
Hi, apologies. It looks like the devices I have lying around are an INA231 and an INA226. I will try and buy an INA3221 |
Detect charging status by measuring current flow with configured INA219 battery sensor
As already described in issue #5226 here is the pull-request
Intro
Nodes that use an e.g. INA219 for monitoring the battery voltage (explicitly set address in the power settings) can detect the charging status by measuring the current flow across the shunt. The current implementation in AnalogBatteryLevel doesn't make much use of the isCharging() function.
If the current is negative, that indicates the battery is being charged.
This PR adds the functionality to detect the charging status by measuring current flow when the INA address is set as battery monitor.
Changes to code
Tests
I tested the branch on two of my custom build NRF52 nodes integrating an INA219. Also tested both extra defines. Works well so far and the correct charging status is displayed on the screen
Every input is appreciated, especially because I'm no C++ expert ;) Unfortunately the trunk extension keeps crashing in my VS Code