This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Read and print LM35 voltage in Analog Pin

Hello to everyone.

I'm working with nRF52832 SDK (PCA 10040) and Segger Embedded Studio v4.12, in the Light_switch example for Mesh 3.10.
Right now, I'm able to use the full capacity of the example with the "nRF Mesh" App for Android as provisioner.
Now, I'm trying to add a temperature sensor (LM35 DZ) in the analog input pin P0.03 (A0) to read the Vin.
This sensor has 10 mV/°C as linear resolution, that means (in theory) that, for example, 200mV as input are 20°C (200 mV / 10 mV/°C).
I'm using these functions:

nrf_gpio_cfg_input(3, NRF_GPIO_PIN_NOPULL);
uint32_t pin_state = nrf_gpio_pin_read(3);
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "VAL %d\n", pin_state);

when the Button 1 is pressed. Then, the voltage in P0.03 is supposedly printed in the debug screen. But it doesn't happen.

I've read that I have to initialize the ADC to make it function, but all the examples with the ADC are focused on "Central" and "Peripheral" examples (in simple BLE mode), not in Client-Server in Mesh examples.
So, how can I read this pin as analog input and use the ADC to print the value without trigger an error on libraries, functions or pin configuration because the ADC configuration?

I hope you can help me.
Best regards,
John

Parents Reply Children
Related