Configuration : from nRF52840 to RAK4631 ADC


I have previously worked on Nordic’s nRF52840 as a standalone module and I chose to switch development on the RAK4631 since it embeds the very same chip, to gain leverage on my experience.

However, I have trouble finding the equivalent functions to configure the ADC, and reading posts in this forum does not help. From what I can infer, everything that can be done on nRF52840 (regarding the ADC at least) should be also feasible on RAK4631, but information on this subject is scarce.

Here are my questions :

  1. Is the RAK4631 really using the ADC from nRF52840?
  2. Is there a proper ADC API documentation?
  3. Can the following be configured: Voltage reference, Gain, Sampling rate, Acquisition time, Burst?
  4. If so, how?

Regarding my setup, I am using Arduino IDE to program a RAK4631 mounted on a RAK5005-O through a USB cable.

Thank you for your time!

Best regards,

Welcome to the forum @randall

Yes, the RAK4631 is using the ADC of the nRF52840 and the setup and usage of the ADC is done the same way in Arduino as it is done with other nRF52 boards.
Here is an example how to use the ADC.

Keep in mind, that there are only 2 ADC channels exposed on the RAK4631.
They are named WB_A0 and WB_A1 in the Arduino variants.h file.
WB_A0 is attached to the battery voltage already and cannot be used for other purposes. WB_A1 is available.

You can find more information in our Documentation Center and in our WisBlock example repo on Github

Hello @beegee,

Thank you for your answer! There is still one point that I am not sure to understand. Looking through the GitHub repository for mentions of “Burst” mode or “Sampling rate”, I only find references pointing to the bootloader.

Is it possible to modify the ADC’s behaviour at runtime? I see for example the “nrfx” driver which looks promising. Can it be imported to modify the ADC?

Sorry for the trivial questions!

Best regards,

Hello @randall

The Arduino BSP is based on Adafruits nRF52 BSP and we try to keep it as close to theirs as possible. So regarding ADC functions, it is as it is.

If you look into the file wiring_analog_nRF52.c in the BSP, you can see that the Arduino functions are just wrappers around the nRF52 SDK functions.

Hello @beegee,

Thank you very much, this is what I was looking for!

Best regards,

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.