<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[read_battery_voltage() Voltage value to Battery Level]]></title><description><![CDATA[<p dir="auto">Hi all, have a FiPy &amp; a Pysense with 2000mAh LiPo battery.<br />
Found some good info on the forums to get its voltage from the <a href="http://pycoproc.py" target="_blank" rel="noopener noreferrer nofollow ugc">pycoproc.py</a> library.<br />
Using it as follows:</p>
<pre><code>from pysense import Pysense
py = Pysense()
print(py.read_battery_voltage())

&gt;&gt; 4.656595
</code></pre>
<p dir="auto">What's the best way to convert that into a rough battery level precentage.</p>
<p dir="auto">I thought perhaps the 1S chart values from here (<a href="https://blog.ampow.com/lipo-voltage-chart" target="_blank" rel="noopener noreferrer nofollow ugc">https://blog.ampow.com/lipo-voltage-chart</a>) but I imagine its not as simple as just doing the conversion math.</p>
<p dir="auto"><img src="/assets/uploads/files/1605902692619-screen-shot-2020-11-20-at-3.04.32-pm.png" alt="Screen Shot 2020-11-20 at 3.04.32 PM.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="/assets/uploads/files/1605902706933-screen-shot-2020-11-20-at-3.03.48-pm.png" alt="Screen Shot 2020-11-20 at 3.03.48 PM.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Is there anything I'm missing?</p>
]]></description><link>https://forum.pycom.io/topic/6585/read_battery_voltage-voltage-value-to-battery-level</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Nov 2026 19:51:40 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/6585.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 20 Nov 2020 20:05:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to read_battery_voltage() Voltage value to Battery Level on Sun, 22 Nov 2020 15:13:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claus" aria-label="Profile: claus">@<bdi>claus</bdi></a> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/kjm" aria-label="Profile: kjm">@<bdi>kjm</bdi></a> excellent tips guys thank you.<br />
I'm going to do both, first with the quick and dirty:</p>
<pre><code>battery_voltage = read_battery_voltage()
roughbatt = (battery_voltage - 3.25)*100

print(roughbatt)

&gt;&gt; 92.00001
</code></pre>
<p dir="auto">Whilst also recording raw timestamped voltage from full to empty (last transmission) a few times and basically just dividing that scale and tweaking above.</p>
]]></description><link>https://forum.pycom.io/post/35672</link><guid isPermaLink="true">https://forum.pycom.io/post/35672</guid><dc:creator><![CDATA[barryjump]]></dc:creator><pubDate>Sun, 22 Nov 2020 15:13:22 GMT</pubDate></item><item><title><![CDATA[Reply to read_battery_voltage() Voltage value to Battery Level on Sat, 21 Nov 2020 06:25:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/barryjump" aria-label="Profile: barryjump">@<bdi>barryjump</bdi></a> A typical lipo discharge curve looks like this</p>
<p dir="auto"><img src="https://i.stack.imgur.com/LV91V.gif" alt="alt text" class=" img-fluid img-markdown" /></p>
<p dir="auto">If you want more precise results than a linear interpolation you could easily measure the curve with your device. Write a program with more or less constant power consumption, say sending the voltage every minute via WiFi. Then just record voltage over time. Inverting this curve gives time left until discharge (which you set as a given voltage) over voltage and you can use this result to get a quite precise percentage of charge for your device and ambient conditions for any voltage. The curve changes as the battery degrades, laptops and phones remeasure it over time.</p>
]]></description><link>https://forum.pycom.io/post/35664</link><guid isPermaLink="true">https://forum.pycom.io/post/35664</guid><dc:creator><![CDATA[claus]]></dc:creator><pubDate>Sat, 21 Nov 2020 06:25:53 GMT</pubDate></item><item><title><![CDATA[Reply to read_battery_voltage() Voltage value to Battery Level on Sat, 21 Nov 2020 00:02:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/barryjump" aria-label="Profile: barryjump">@<bdi>barryjump</bdi></a> If you take 4.25v as fully charged and 3.25 as empty then (Vbatt-3.25)*100  is a quick &amp; dirty battery percentage.</p>
]]></description><link>https://forum.pycom.io/post/35661</link><guid isPermaLink="true">https://forum.pycom.io/post/35661</guid><dc:creator><![CDATA[kjm]]></dc:creator><pubDate>Sat, 21 Nov 2020 00:02:08 GMT</pubDate></item><item><title><![CDATA[Reply to read_battery_voltage() Voltage value to Battery Level on Fri, 20 Nov 2020 23:44:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jcaron" aria-label="Profile: jcaron">@<bdi>jcaron</bdi></a> Good info thanks a bunch.  Had a hunch that that was the case.</p>
<p dir="auto">I think I'd be happy with a 0-25%, 25-50%, 50-75%, 100% scale so I might be able to get close to that as you mentioned.  Basically pretty low res estimation would suffice for now.</p>
]]></description><link>https://forum.pycom.io/post/35660</link><guid isPermaLink="true">https://forum.pycom.io/post/35660</guid><dc:creator><![CDATA[barryjump]]></dc:creator><pubDate>Fri, 20 Nov 2020 23:44:36 GMT</pubDate></item><item><title><![CDATA[Reply to read_battery_voltage() Voltage value to Battery Level on Fri, 20 Nov 2020 21:32:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/barryjump" aria-label="Profile: barryjump">@<bdi>barryjump</bdi></a> no, it’s not that simple.</p>
<p dir="auto">First, you should use the chart for the specific battery you are using. Even though batteries with the same chemistry should have similar profiles, it’s not a given that they are identical.</p>
<p dir="auto">Next, battery discharge profiles can vary a lot with temperature and with the actual load (though this depends on the battery type – some are very sensitive to either or both, others much less).</p>
<p dir="auto">Next, you’ll notice that the curve for LiPo batteries is quite steep when close to full charge and to low charge, and very flat in the middle part. It’s so flat that imprecisions in readings (ADC noise, temperature variations...) can result in wild fluctuations in the result.</p>
<p dir="auto">I’m not quite convinced by the values in the table either.</p>
<p dir="auto">You can definitely get a sense of the battery state (e.g. over 4 V means the battery is close to being fully charged).  But it’s difficult to get an accurate and consistent status all along the discharge curve, especially along the pretty long and flat middle section. So you may end up with 3 states: pretty darn full, somewhere in the middle, nearly empty, but the first and last will be pretty short.</p>
<p dir="auto">Of course YMMV depending on the environment (indoors vs outdoors), the specific battery type, the load profile...</p>
]]></description><link>https://forum.pycom.io/post/35655</link><guid isPermaLink="true">https://forum.pycom.io/post/35655</guid><dc:creator><![CDATA[jcaron]]></dc:creator><pubDate>Fri, 20 Nov 2020 21:32:38 GMT</pubDate></item></channel></rss>