How to use A1 and A2 ports with ADC?

Hi,
Sorry for my stupid french question, but i want to use the 3 analog ports on my Arduino nicla Vision board.
no problem with the port A0 (ADC1/PC_4) with this line code :
adc = ADC(“A0”)
But if i want to use A2, this line code :
adc = ADC(“A2”)
OPENMV result is :
ValueError :Pin(F3) doesn’t habe ADC capabilities

Do you know the name of the port A2 and A3 in ADC function please ?
Thank you
TC

Hi, there’s some issue with the driver it looks like for the H7 on using multiple ADCs. It appears folks have been debating this for a while since 2021 and it wasn’t solved.

I just tried the code:

import machine, time

adc = machine.ADC("PF3")

while(True):
    time.sleep_ms(100)
    print((adc.read_u16() / 65535.0) * 3.3)

and

import machine, time

adc = machine.ADC("PC4")

while(True):
    time.sleep_ms(100)
    print((adc.read_u16() / 65535.0) * 3.3)

Work. However, PF13 doesn’t. It appears each of these pins is on a different internal ADC block which is the problem. I’ll raise this issue on our github for Ibrahim to see if it’s fixable.

I think you may have an older firmware. Nicla’s analog pins shouldn’t have any problems.

@Osiris1979

Please use the latest firmware via Tool->Install Development Firmware

and then all three channels will work through the machine module. Then PF13 will work.

import machine, time

adc = machine.ADC("PF13")

while(True):
    time.sleep_ms(100)
    print((adc.read_u16() / 65535.0) * 3.3)

Please avoid using pyb unless absolutely necessary. It’s an obsolete module that is not maintained.

Hi
So many thanks for your help.

you were right.
It was just a firmware update.

For the “from pyb import ADC”, it was the BOARD example from OPENMV source.

import machine, time

adc0 = machine.ADC(“A0”)
adc1 = machine.ADC(“A1”)
adc2 = machine.ADC(“A2”)

while(True):
time.sleep_ms(1000)
print(“ADC 0 = %fv” % ((adc0.read_u16() / 65535.0) * 3.3))
print(“ADC 1 = %fv” % ((adc1.read_u16() / 65535.0) * 3.3))
print(“ADC 2 = %fv” % ((adc2.read_u16() / 65535.0) * 3.3))