Page 1 of 1

ESP32: 'ADC' object has no attribute 'read_uv'

Posted: Tue Feb 08, 2022 7:07 pm
by fromvega
Hi there,

I just downloaded the latest firmware for the esp32/GENERIC from https://micropython.org/resources/firmw ... -v1.18.bin

I'm trying to run the following ADC example from the docs (https://docs.micropython.org/en/latest/ ... conversion)

Code: Select all

from machine import ADC

adc = ADC(pin)        # create an ADC object acting on a pin
val = adc.read_u16()  # read a raw analog value in the range 0-65535
val = adc.read_uv()   # read an analog value in microvolts
but I'm getting the error:

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'ADC' object has no attribute 'read_uv'
The REPL tells me the only methods available are: read, read_u16, atten and width

What am I missing?

Thank you.

Re: ESP32: 'ADC' object has no attribute 'read_uv'

Posted: Tue Feb 08, 2022 10:35 pm
by fivdi
read_uv (at least for the ESP32) was added after MicroPython 1.18 was released and as such isn't available in 1.18.

The documentation link posted above is https://docs.micropython.org/en/latest/ ... conversion. This is a link to the latest documentation rather than the documentation for 1.18 and it contains documentation for read_uv.

The documentation link for 1.18 is https://docs.micropython.org/en/v1.18/e ... conversion. It contains no documentation for read_uv. It doesn't contain documentation for read_u16 either which is actually available in 1.18.

Re: ESP32: 'ADC' object has no attribute 'read_uv'

Posted: Wed Feb 09, 2022 5:06 pm
by fromvega
Of course... ;) Thank you!