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("")
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!