-
-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nRF52840: jsvReadVRef now reads VDDH value (not VDD, which is almost …
…always internally regulated)
- Loading branch information
1 parent
ed7e003
commit eabd13c
Showing
2 changed files
with
10 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eabd13c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I notice this affects the voltage, no longer being approximate to 3.3V!
I have like 2.44V from this read out now.
What is this change and how do I compute battery voltage estimation now.
Previously was used :
lcars.app.js#L330C5-L330C5
I need to update this now?
eabd13c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just replace the code with what we actually do inside Bangle.js? https://github.com/espruino/Espruino/blob/cfbc4040d/libs/banglejs/jswrap_bangle.c#L2817-L2821
Battery full voltage on Bangle.js 2 as a default is 0.3144 although it can be read out of
batFullVoltage
in the settings file if it's defined.jshReadVRef as it was just didn't make any sense. It'd pretty much always return 3.3v so you might as well have just replaced it with a constant (you could still do that if you wanted).
eabd13c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually forget that - looks like on Bangle.js 2 particularly VDDH isn't connected so gives random values, so I've reverted the change (just for Bangle.js 2, not for other nRF52840)
eabd13c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formula that I used to derive the battery voltage was what I believe to be :
v = a * r * 3.3
Where:
a = analogRead(3)
r = 4 ( because its connected to 4 ohm resistors )
3.3 ( because this is the operational signal )
Equivalent to:
v = 3.3*4*a
v = 13.2 * a
This formula worked well for me with bangle 1 and 2, where I would replace 4 with 2, for bangle 1
, because it has 2 ohm resistor instead of 4.
It turns out that your formula :
v = 4.2 * a / 0.3144
equivalent to:
v = 4.2 * 3.18*a
v = 13.356 * a
If we assume the 3.3 is fixed, we get
13.356/3.3 = 4.0472
So your calculation has slightly more resistance.
You can see how its extremely similar to
4 * a * 3.3
.So your formula uses 13.356 (4.0472 resistance), mine uses 13.2 ( 4 resistance ).
1.2% more.
Is your formula more correct than mine? I know its trivial, but it interests me.
eabd13c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not 100% sure on the resistors used in the potential divider (I haven't measured them) but they're never entirely accurate so they vary by device (probably by around 5%). That's why we now have the calibration option.
The values chosen for Bangle.js 2 are based on looking at a bunch of watches and trying to choose the correct value based on what I saw, so I'd argue that my formula is marginally more accurate for most users, although it's always possible that yours is better for your device.
eabd13c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cross referencing to the issue in BangleApps