Skip to content

2.0.0 - do we undo the mcu temperature ADC changeover? #253

@ladyada

Description

@ladyada

i think after mcu temperature is read the MUX isnt cleared or something because analog reads have a max range change?

see demo, try commenting out mcu temp print out, note analog voltage changes. with temp read, voltage never gets above 0.21 (4096 raw). using trinket but temp read is correct!

import board
from analogio import AnalogOut, AnalogIn
import time
import microcontroller

# Analog input on D0
analog1in = AnalogIn(board.D0)

######################### HELPERS ##############################

# Helper to convert analog input to voltage
def getVoltage(pin):
    return (pin.value * 3.3) / 65536

######################### MAIN LOOP ##############################

while True:
  #print("\nTemp: %0.1f *C" % microcontroller.cpu.temperature, end="")

  # Read analog voltage on D0
  print("\tD0: %0.2f V" % getVoltage(analog1in), end="")

  time.sleep(0.01) # make bigger to slow down
  print("")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions