Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    problem measuring battery voltage

    Scheduled Pinned Locked Moved LoPy
    7 Posts 3 Posters 543 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      apo1997
      last edited by

      hello,

      i measure the battery voltage from pin16 using lopy 4/exp Board 3.0r.
      here is a code for demonstration.

      adc = ADC()
      p_bat = adc.channel(pin='P16', attn=ADC.ATTN_11DB)
      
      vol_bat = p_bat.voltage() * 3.05 #factor from voltage divider
      
      

      vol_bat is about 6050 mV everytime i measure it but it should be 4100.
      did someone have the same problem? how can i fix it?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @apo1997
        last edited by

        @apo1997 use another factor than 3.05. This factor is related to the voltage divider on the expansion board. For board V2, 3.05 was about right. For board 3, the factor should be close to 2. Since you also gave to correct for the ADC variation, you can use your own factor. In this case 2.067.

        1 Reply Last reply Reply Quote 1
        • A Offline
          apo1997
          last edited by

          ty :).

          In the official documentation the values of the voltage divider are 155kOhm and 56kOhm for board 3. Can you text me the correct values ?

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @apo1997
            last edited by robert-hh

            @apo1997 There was a thread about it. That told 1M Ohm/1M Ohm.
            Edit: look here: https://forum.pycom.io/topic/3776/adc-use-to-measure-battery-level-vin-level/13

            A 2 Replies Last reply Reply Quote 0
            • A Offline
              apo1997 @robert-hh
              last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • A Offline
                apo1997 @robert-hh
                last edited by

                @robert-hh

                even in this post the most recent answer i found is:
                Pycom Expansion board v3.0: 115 kΩ / 56 kΩ
                Pycom Expansion board v3.1: Undocumented, probably like v3.2? (yes, prooved)
                Pycom Expansion board v3.2: 1 MΩ / 1 MΩ

                So this post is wrong too about the 3.0 version i am using.
                These threads are from 2018. We are living in 2020 in few months and pycom still didnt corecct it in their official documentation, thats weird.

                But ty for your answers, 2.067 is a very precise factor for my application!

                T 1 Reply Last reply Reply Quote 1
                • T Offline
                  trojanc @apo1997
                  last edited by

                  @apo1997 said in problem measuring battery voltage:

                  @robert-hh

                  even in this post the most recent answer i found is:
                  Pycom Expansion board v3.0: 115 kΩ / 56 kΩ
                  Pycom Expansion board v3.1: Undocumented, probably like v3.2? (yes, prooved)
                  Pycom Expansion board v3.2: 1 MΩ / 1 MΩ

                  So this post is wrong too about the 3.0 version i am using.
                  These threads are from 2018. We are living in 2020 in few months and pycom still didnt corecct it in their official documentation, thats weird.

                  But ty for your answers, 2.067 is a very precise factor for my application!

                  Hi, have you even got any offical documentation for the v3.1 of the expansion board? I'm also interested in a circuit diagram of the expansion board. I have strange things happening depending if the board is powered via USB or battery, but I'd really want a circuit diagram to first try and rule out a mistake on my side, before I try and log a "bug"... Also explaining my issue would be much easier if I had the right info...

                  1 Reply Last reply Reply Quote 0

                  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
                  • 1 / 1
                  • First post
                    Last post

                  Pycom on Twitter

                  Pycom