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

Reading Resistance of Photoresistor with ADC NRF52DK

Hi I am using the example code here https://github.com/NordicPlayground/nRF52-ADC-examples/tree/master/nrfx_saadc_simple_low_power_app_timer_multichannel_oversample to use the ADC to read the value of a photoresistor. 

Everything works fine when I use a pull-down resistor of 10K and attach A1 on GND and then connect the other end of the photoresistor to 5V. The adc receives values between 1800-2500 depending whether the sensor is covered.

However, when I use the VDD pin (3.3V instead of 5V) the adc value is stuck at 3300 and does not change if I cover the resistor. Do I need to change the reference voltage value somewhere in the code? Or do I need to switch the pulldown resistor to a higher/lower resistance?

I need to use VDD and 3.3V since I will eventually be powering an external board off of a Lipo. 

Also not sure if this is important but the photoresistor gets up to 300k ohms when fully covered

  • Hi,

    The input range of the SAADC is 0 to VDD, so if the input with 5V supply to the photoresistor is above VDD, you will get false readings/nondeterministic behavior.

    If your photoresistor goes all the way to 300k ohms, the 10k omh pullup may not be large enough to make an impact in the voltage divider between the resistor and the photo resistor. I did a quick test on my desk, and the was able to get a good reading with a 39k resistor together with a photoresistor.

    Did you measure the resistance of the photoresistor when it is not connected, both covered and not?

    Best regards,
    Jørgen

  • Hi,

    Yes I measured the resistance of the photoresistor with a multimeter: <1k when I pointed a flash light on it; ~300k when completely covered.

    Turns out I was accidentally connected to RESET and not GND. That explains a lot.

    Nevertheless, thank you for the tip with the resistor. With a 47k resistor the range I get from the ADC is a lot better.

Related