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
  • Hi John,

    It should be possible to integrate the ADC functionality from the nRF5 SDK to the Mesh SDK, either by integrating the ADC functionality in a mesh example or integrating mesh into an nRF5 SDK project. See this documentation for more info if you have not seen it already.

    If I were you, it may be easier to take a look at the ADC example in the nRF5 SDK first, get it to work with your functionality & then merge the working code from that example into the mesh example.

    Kind Regards,

    Bjørn

  • Hello again, .

    I've been trying to include the nRF5 SDK "SAADC" in the nRF52 SDK for Mesh "Light_switch / Client".
    Like this answer suggests, I add the .c files from SAADC to Light_switch in a different folder (to find them easily) and, then, I added the same paths of header files to the "include paths settings" in Segger.


    When I compile the whole project, it throw me this error:

    (I'm testing one by one every "#include")
    I supposed that nrf_saadc.c file must has many dependencies files, as other .c files have, but I can't make the Segger to search for them. How can I do that? or there's another kind of error that I'm commiting?

Reply
  • Hello again, .

    I've been trying to include the nRF5 SDK "SAADC" in the nRF52 SDK for Mesh "Light_switch / Client".
    Like this answer suggests, I add the .c files from SAADC to Light_switch in a different folder (to find them easily) and, then, I added the same paths of header files to the "include paths settings" in Segger.


    When I compile the whole project, it throw me this error:

    (I'm testing one by one every "#include")
    I supposed that nrf_saadc.c file must has many dependencies files, as other .c files have, but I can't make the Segger to search for them. How can I do that? or there's another kind of error that I'm commiting?

Children
Related