🤖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

    General
    1
    2
    787
    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
      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
        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
        • First post
          Last post