Always reading same battery voltage
-
@mmarkvoort R is the ratio:
Voltage_at_P16 / Voltage_at_battery
According to the schematics, it is 0.3275, which gives ~3.8 V = 1.246/ 0..3275 at the battery, but better check. -
But you can't get the Voltage_at_battery through code, right?
Thanks a lot by the way, you helped me a lot! :)
-
@mmarkvoort Yes, you can. Since R is a fixed value, you can get determine the Voltage at P16 by code and calculate the battery voltage as:
Voltage_at_P16/R -
But doesn't the value of R changes everytime?
You said R = Voltage_at_P16 / Voltage_at_battery, but how can you get Voltage_at_battery in the code.
Or in other words, how did you get the 0.3275 as a value?
EDIT: 0.3275 seems to be a good value indeed.
-
@mmarkvoort No, R is defined by the circuitry of the expansion board, and is fixed. The schematics show a voltage divider consisting of two resistors, one 56k, the other 115k, and so R can be calculated as:
R = 56 / (56 + 115)
If you want to find R by measuring, you have to take a Voltmeter and measure the real values at the battery and at P16, while the device is running from battery.
-
Robert thank you very much for your help.
I finally get it! -
Just some questions.
Is it a good idea to put a capacitor between battery and LoPy to reduce noise?
Now when I am reading the battery value it really fluctuates.Also sometimes when connecting the battery it is always reading low value. When move the connector a bit it is changing. What can this be? Is it the startup that needs a bit more?
And lastly, does it make a difference if I have a sensor connected?
-
@mmarkvoort The ADC of the esp32 is known to be very bad. If if you apply a perfectly good signal (stable, low impedance), the reading will fluctuate a lot. That's why in the sample code the average is used.
A capacitor will only help if placed directly at P16. and it must be a low impedance capacitor (ceramic, short leads). -
Aha, so it isn't me :)
Thanks, I thaught I did something wrong.Does it matter if you have sensors connected to the LoPy?
-
@mmarkvoort Other sensors do not hurt. When USB is connected, the battery voltage is higher, since it will be charged at that time.
And yes, if the voltage changes when you touch the connector, then you have a bad connector. By maybe that was just coincidence with the other fluctuations. -
Oke, will make a test program.
When USB is connected it indeed has a higher voltage :').
That was another mistake/issue I had :).Thanks a lot, again!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login