Skip to content

NRF52840: ADC is 8 bits, how to set to 12 bits? #6572

Open
@JPFrancoia

Description

@JPFrancoia

Hi,

I have been playing with the latest version of micropython on the nrf52840 USB dongle. The temperature over bluetooth example works perfectly for me (as a proof that micropython is properly flashed on the board).

I wanted to try and read some values from the ADC pins. I wired the pin 0.29 to a potentiometer, and initialized an ADC object:

from machine import ADC
adc = ADC(5)
adc.value()

However, I could only get values between 0 and 255 (0 when the potentiometer was turned to the minimum, 255 when turned to the maximum). This obviously means the ADC has an 8-bits resolution

The specs of the board tell us we can use 8, 10, 12 and even 14 bits of resolution (with oversampling): https://infocenter.nordicsemi.com/pdf/nRF52840_PS_v1.0.pdf

I wasn't able to find a method in the ADC class to set the resolution of the ADC. Is it possible in the current state of micropython for the nrf boards?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests, new feature implementationsport-nrf

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions