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

    I am getting an 'AttributeError: 'ADC' object has no attribute 'vref_to_pin()'' error when I try to use the ADC library in micropython on a lopy4

    Scheduled Pinned Locked Moved LoPy
    2 Posts 2 Posters 206 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.
    • I Offline
      ionhedes
      last edited by

      I am working with a lopy4 module for a contest I am entering. I use the machine.ADC library for getting data from an analog sensor.

      I can use basic functions like ADC.init(), but as you know, before getting data from an ADC pin, you need to calibrate the voltage reference of the used pin.

      As documented on the pycom docs, the process of calibration is based on the ADC.vref_to_pin() attribute. However, when I try to call ADC.vref_to_pin(), it returns an 'AttributeError: 'ADC' object has no attribute 'vref_to_pin'. The same happens when I try to use ADC.vref().

      I must add that the machine library works fine, as I am using the machine.I2C library just fine.

      Here is the basic code I am trying to run:

      import pycom
      import machine
      
      adc = machine.ADC()
      voltage = adc.vref_to_pin('P22')
      print (voltage)
      
      1 Reply Last reply Reply Quote 0
      • E Offline
        Eric Waai
        last edited by Eric Waai

        i think the function does not return any thing. it just connects the internal 1,1 V to a pin

        so voltage does not become anything.

        what software version are you running. if i run

        adc.vref_to_pin('P22')
        

        i get nothing

        if i run

        voltage = adc.vref_to_pin('P22')
        print (voltage)
        

        i get None

        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