# Pidog - Reading battery voltage is 5.1 V

**URL:** <https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658>\
**Category:** Robotic kit for Raspberry Pi\
**Created:** [September 12, 2024, 1:01pm UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658 "2024-09-12T13:01:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sia](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sia](https://forum.sunfounder.com/u/sia)\
**Post date:** [September 12, 2024, 1:01pm UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/1 "2024-09-12T13:01:05Z")

</div>

After fully charge the Robo HAT battery, I used  
voltage = utils.get\_battery\_voltage()  
but the voltage that i get in return in unexpected 5.12 V.

Both LED on Robot Hat is ON, so according to documentation:  
2 LEDs on → Greater than 7.6V

```auto
Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from robot_hat import utils
>>> print(utils.get_battery_voltage())
5.13010989010989
>>>

```

Then why I get this value?

---

<div class="post-metadata">

**Author:** ![SunFounder\_Moderator](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SunFounder\_Moderator](https://forum.sunfounder.com/u/SunFounder_Moderator)\
**Post date:** [September 13, 2024, 5:46am UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/2 "2024-09-13T05:46:27Z")

</div>

We conducted tests and verified that the voltage data read matches closely with the actual measured battery voltage. Could you use a multimeter to measure the battery voltage and see what it is?

 ![5cf9a12565c288ff2f8d656016c9d48e](https://canada1.discourse-cdn.com/flex029/uploads/sunfounder/original/1X/8f52bb4ae6bdd4ebe7cb378c7a0a16f9bbed8f03.jpeg)  
 ![image (41)](https://canada1.discourse-cdn.com/flex029/uploads/sunfounder/original/1X/9a2ba0f62e5a9b994e6efa84f88d2846525f7967.png)

---

<div class="post-metadata">

**Author:** ![sia](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sia](https://forum.sunfounder.com/u/sia)\
**Post date:** [September 13, 2024, 7:09am UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/3 "2024-09-13T07:09:23Z")

</div>

> [@sia](#):
>
> `print(utils.get_battery_voltage())`

Hi, thank you for checking that. Yes, my direct measurement of battery confirms 7.9 (almost 8V) - but python method call says 5.35V

 ![battery-read-direct](https://canada1.discourse-cdn.com/flex029/uploads/sunfounder/original/1X/3a88ac011a3b95ea5a799f0223758325c911bb18.jpeg)  
 ![battery-read-2](https://canada1.discourse-cdn.com/flex029/uploads/sunfounder/original/1X/86a3ed95e448ee2ef37a422dd75f18ecfd7b7495.jpeg)

---

<div class="post-metadata">

**Author:** ![SunFounder\_Moderator](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SunFounder\_Moderator](https://forum.sunfounder.com/u/SunFounder_Moderator)\
**Post date:** [September 18, 2024, 1:59am UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/4 "2024-09-18T01:59:55Z")

</div>

Are you having trouble running the Python example using Putty? Is there any error message?

Please provide a screenshot of the error message so we can analyze and resolve the issue.

We do not recommend using Thonny to run the example code. Thonny does not have superuser privileges, and our code needs to be executed with sudo.

Thonny cannot add sudo to execute the code.

---

<div class="post-metadata">

**Author:** ![sia](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sia](https://forum.sunfounder.com/u/sia)\
**Post date:** [September 18, 2024, 7:46pm UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/5 "2024-09-18T19:46:56Z")

</div>

Hi, I do not use Thonny. I use Windows Power Shell and use SSH to connect to Raspberry Pi and execute the commend. There are no errors. Its only wrong reading of Voltage. I get wrong value when run the code in python console or if i execute a script using sudo. In both cases I get wrong reading on battery voltage in compare to reality.

---

<div class="post-metadata">

**Author:** ![SunFounder\_Moderator](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SunFounder\_Moderator](https://forum.sunfounder.com/u/SunFounder_Moderator)\
**Post date:** [September 19, 2024, 3:50am UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/6 "2024-09-19T03:50:10Z")

</div>

Please use a multimeter to measure the resistance of R6 on the robot hat. The two points represent the voltage divider for the battery resistance. One side measures the battery voltage, while the other side measures one-third of the battery voltage. Please analyze the measurement data for us. See the image.

 ![45b6b6e638ca8311fae427cc02dab29a (2)](https://canada1.discourse-cdn.com/flex029/uploads/sunfounder/original/1X/b41055ce6fa6eb3b3bffca030279ac7ff77fa41e.jpeg)  
 ![b4f61e738d1c638527891503f6887dc5 (1)](https://canada1.discourse-cdn.com/flex029/uploads/sunfounder/original/1X/2b792290c6b0ca2f3c1d1739cf48c113a05f0516.jpeg)

---

<div class="post-metadata">

**Author:** ![sia](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sia](https://forum.sunfounder.com/u/sia)\
**Post date:** [September 19, 2024, 7:14pm UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/7 "2024-09-19T19:14:28Z")

</div>

Yes. One side of R6 is 8.05 V and the other side of R6 is 2.69 V

---

<div class="post-metadata">

**Author:** ![SunFounder\_Moderator](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SunFounder\_Moderator](https://forum.sunfounder.com/u/SunFounder_Moderator)\
**Post date:** [September 20, 2024, 3:49am UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/8 "2024-09-20T03:49:16Z")

</div>

What you mean is that the voltage on one side of R6 is 8.05 V, and on the other side, it’s 2.69 V. When measuring the battery terminal voltage, it is also around 8.05 V. The hardware measurements are consistent, but there is a discrepancy in the software voltage readings, correct?

Have you modified your code? Our testing software is functioning properly, as you can see from the screenshots we provided.

We recommend that you reinstall the system and then install all the library codes for the product. After that, check if the software voltage readings match the actual measurements.

---

<div class="post-metadata">

**Author:** ![sia](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sia](https://forum.sunfounder.com/u/sia)\
**Post date:** [September 20, 2024, 5:22pm UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/9 "2024-09-20T17:22:13Z")

</div>

Yes correct.

I once did reinstall the libraries to be sure but I will do it again. It could be something in software level. Thank you

---

<div class="post-metadata">

**Author:** ![jonhurdibm](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.sunfounder.com/jonhurdibm/32/1053_2.png) [@jonhurdibm](https://forum.sunfounder.com/u/jonhurdibm)\
**Post date:** [December 4, 2024, 6:57pm UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/10 "2024-12-04T18:57:11Z")

</div>

Where on the hat can I prob to measure the battery voltage?

---

<div class="post-metadata">

**Author:** ![SunFounder\_Moderator](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SunFounder\_Moderator](https://forum.sunfounder.com/u/SunFounder_Moderator)\
**Post date:** [December 5, 2024, 3:33am UTC](https://forum.sunfounder.com/t/pidog-reading-battery-voltage-is-5-1-v/1658/11 "2024-12-05T03:33:28Z")

</div>

Jonhurdibm：you can refer to the images in previous replies, where this is demonstrated.
