Hello Nordic team,
For the (POC), I configured ADC channel 1 and interfaced a potentiometer to pin P1.14. The ADC was set up to read the potentiometer's raw value.
As part of "Exercise 1 – Interfacing with ADC using Zephyr API", we configured and initialized the ADC, and invoked it within the
main()
function.We also added a function call to read the ADC value, as demonstrated in the following code snippet:
To analyze the ADC readings, we considered two scenarios:
1) As shown in the code below, we called the readValue()
function within the while(1)
loop in main.cpp
.
2) The
readValue()
function is called every second using a timer, which is initialized through the SensorTimerHandler
in the AppTask::Init()
function. This function also initializes the Matter stack.
Based on the two code snippets above, we examined the ADC raw data values under the following scenarios:
A) Without initializing the Matter stack, the value is read within the while(1)
loop in main.cpp
.
B) Initializing the Matter stack, the value is read using a timer.
- Scenario A-1 readings:
- Scenario B-1 readings:
- Scenario A-2 readings:
- Scenario B-2 readings:
In the above, we observe readings from two scenarios, where A/B refer to the test conditions (as described earlier), and 1/2 refer to the corresponding reading numbers.
Scenario A-1: With the potentiometer set to a specific value, the ADC reading was approximately 1111.
Scenario B-1: Using the same potentiometer setting, the ADC reading was 4092.Scenario A-2: At a different potentiometer setting, the ADC reading was approximately 241.
Scenario B-2: With the same setting, the ADC reading was around 2600.We can see a significant difference in the readings between the two scenarios.
We would like to understand why the readings appear incorrect when the Matter stack is initialized.Looking forward to your insights.
Thanks & Regards,
Pratik Panchal