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

    Using the expansion board 3.0 to read external battery voltage

    Scheduled Pinned Locked Moved Expansion Board
    6 Posts 2 Posters 83 Views 2 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.
    • G Offline
      Graham Blackwell
      last edited by

      Hi all, newbie here.
      Looking to use a Pycom over sigfox, to record a battery voltage on a vehicle in storage, and upload readings to the cloud. Does the expansion board 3.0 have an A/D input that will allow it to read the battery voltage from a vehicle battery?
      Thanks

      robert-hhR G 2 Replies Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @Graham Blackwell
        last edited by

        @Graham-Blackwell The xxPy board have several A/D inputs, which are accessible at t he expansion board. The input range is 0-1V up to 0-3.3V, depending on the attenuation. See. https://docs.pycom.io/tutorials/hardware/adc/
        The voltage of a car battery is in the range up to 15V for a 12V systems and up to 30V for a 24V system. And it may carry higher spikes and noise. So you have to add an external voltage divider and some filtering.

        1 Reply Last reply Reply Quote 3
        • G Offline
          Graham Blackwell @Graham Blackwell
          last edited by

          @Graham-Blackwell thanks Robert. I'll get an expansion board ordered.

          1 Reply Last reply Reply Quote 0
          • G Offline
            Graham Blackwell
            last edited by

            Expansion board has arrived from RS this morning. I'll whip a voltage divider up and get coding :D

            1 Reply Last reply Reply Quote 0
            • G Offline
              Graham Blackwell
              last edited by

              Programming is going well. It now posts data to mysql using JSON, and I'm now attempting to read analogue voltages. Am I right in thinking that Pin 13-18 are the analogue inputs for the WiPy 2.0 on an expansion board 3.0?

              So
              adc = machine.ADC()
              lbatv = adc.channel(pin='P13') #van battery
              vbatv = adc.channel(pin='P14') #leisure battery
              batt1 = vbatv()
              batt2 = lbatv()

              Will return voltages for connections to pin 13 and pin 14? I've not tried connecting the voltage divider until I'm sure that 13 and 14 are the correct analogue input pins

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

                @Graham-Blackwell P13 to P18 are indeed the ADC input pins. As long as you do not set an attenuation, the range is 0.03 - 1V. For setting the attenutaion, used attn keyword argument on the adc.channel call. See: https://docs.pycom.io/firmwareapi/pycom/machine/adc/#class-adc--analog-to-digital-conversion
                With ADC.ATTN_11DB the range is 0.1 - 3.3V. The best linearity is achieved with ADC.ATTN_6DB, which has a range of 0.07 - 2V. Irrespective of the attenuation setting, the safe input range is 0-3.3V. However beyond the range of the ADC input the reading will be 4096.

                To reduce noise, add a small low impedance capacitor between the adc input and GND. 10nF is sufficient. Still the readings are noisy. You may decide to take an average over a set of readings.

                1 Reply Last reply Reply Quote 2

                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