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

Voltage divider/thermistor: GPIO high, ADC read, get temperature, GPIO low

Hello,

I have a voltage divider/thermistor circuit where R1 is an NTC thermistor of 100kOhm at 25°C. R2 is 100kOhm right now.

I took peripheral_saadc example for SDK15 and modified it to get the temperature readings in saadc_callback(); Temperature conversion algorithm is equal to the ones used in:

learn.adafruit.com/.../using-a-thermistor

www.jameco.com/.../temperature-measurement-ntc-thermistors.html

https://devzone.nordicsemi.com/f/nordic-q-a/14583/nrf52832-saadc-sampling

The current during my normal measurement should not exceed ~0.4mA (102kOhm over 3.6V) and I was thinking to use a GPIO as the Vin for the divider circuit.

I would like to: Set GPIO high -> get ADC value -> Clear GPIO -> Calculate temperature - > repeat minimum every 1 second;

How to do it? I am able to power the voltage divider from GPIO but I am unsure where should I make the switch? I cannot make it in the saadc_callback() because if I understand correctly, ADC conversion is already done at that point. Switching GPIO high needs to occur probably some time before ADC sample...

Parents
  • Problem solved. The trick was to place a small delay after the ADC measurement and then clear the GPIO. If the delay was placed after toggling GPIO high, taking the measurement and toggling low, the measurements were wrong. I could place in there a 1000us delay without any success while 10us after sampling is enough.

    I guess placing the delay after the ADC sampling made sure that the samples were taken before unpowering the sensor but I can not prove the fact as I do not have an oscilloscope at hand.

    If anybody has a good explanation before closing this thread, it would be nice. How does delay help to get the measurement? Isn't the processor "not doing anything" during the delay?

    void saadc_thermistor_get_adc(){
        ret_code_t err_code;
        nrf_gpio_pin_set(PIN);
        err_code = nrf_drv_saadc_sample();
        APP_ERROR_CHECK(err_code);
        nrf_delay_us(10);
        nrf_gpio_pin_clear(PIN);
    }

Reply
  • Problem solved. The trick was to place a small delay after the ADC measurement and then clear the GPIO. If the delay was placed after toggling GPIO high, taking the measurement and toggling low, the measurements were wrong. I could place in there a 1000us delay without any success while 10us after sampling is enough.

    I guess placing the delay after the ADC sampling made sure that the samples were taken before unpowering the sensor but I can not prove the fact as I do not have an oscilloscope at hand.

    If anybody has a good explanation before closing this thread, it would be nice. How does delay help to get the measurement? Isn't the processor "not doing anything" during the delay?

    void saadc_thermistor_get_adc(){
        ret_code_t err_code;
        nrf_gpio_pin_set(PIN);
        err_code = nrf_drv_saadc_sample();
        APP_ERROR_CHECK(err_code);
        nrf_delay_us(10);
        nrf_gpio_pin_clear(PIN);
    }

Children
Related