🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Core 2 ADC always min or max values

    Scheduled Pinned Locked Moved General
    2 Posts 1 Posters 1.6k Views
    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.
    • J Offline
      jkeyser
      last edited by jkeyser

      I have a Core 2 and the M5GO BOTTOM2.

      Attached to port B on the battery is a circuit that outputs a voltage between 0-3.3v. The output of the circuit is attached to GPIO 36. When plugged in, adc.read() always returns 4095, and when unplugged reads 0. It should be reading 1.5v (measured with multimeter). Any ideas what could be going wrong?

      from m5stack import *
      from m5stack_ui import *
      from uiflow import *
      import machine
      import time
      
      screen = M5Screen()
      screen.clean_screen()
      screen.set_screen_bg_color(0xFFFFFF)
      
      v = None
      
      label0 = M5Label('label0', x=77, y=74, color=0x000, font=FONT_MONT_14, parent=None)
      
      adc0 = machine.ADC(36)
      adc0.atten(machine.ADC.ATTN_0DB)
      adc0.width(machine.ADC.WIDTH_12BIT)
      while True:
        v = adc0.read()
        label0.set_text(str(v))
        wait_ms(5)
      
      
      
      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jkeyser @jkeyser
        last edited by

        @jkeyser
        never mind, changing gain fixed it

        adc0.atten(machine.ADC.ATTN_11DB)
        
        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
        • First post
          Last post