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

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
fromvega
Posts: 4
Joined: Mon Aug 30, 2021 12:23 am

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

Post by fromvega » Tue Feb 08, 2022 7:07 pm

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.

fivdi
Posts: 16
Joined: Thu Feb 03, 2022 10:28 pm
Contact:

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

Post by fivdi » Tue Feb 08, 2022 10:35 pm

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.

fromvega
Posts: 4
Joined: Mon Aug 30, 2021 12:23 am

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

Post by fromvega » Wed Feb 09, 2022 5:06 pm

Of course... ;) Thank you!

Post Reply