A custom board I bought has a GT36516 photoresistor connected to the centre of two 1M resistors tied between GND and 3v3, so (obviously) always analogReads 0: clearly the designers made a mistake - they didn't want to waste power (so used 1M) but didn't understand that the photoresistor ranges from about 1k in bright light, down to about 50k in the dark - so that 1M to +vcc is useless. (Measures from 0.001v to about 0.03v on my test meter when powered up and hit with a torch)
Is there some way to fix this circuit that's not going to excessively drain my battery?
My gut feeling tells me "no"... but the photoresistor is quite big and should be easy to unsolder and replace with something else - so what might be a suitable replacement to stick between GND and the center of those two 1M resistors that would allow analogue reads to detect the ambient light?
The purpose is for dimming an LCD backlight at night for a custom car data-display and touchscreen controller (the board remains powered by a lipo button battery with ignition off, hence my question).
The two resistors create a voltage source of 1.65 V with a internal resistance of 500kΩ
Is that GT36516 from 1k to 50k ? The datasheet is not very clear about that.
Then yes, it is a design mistake.
You can use a output pin to power the circuit. Remove the two resistors and add a resistor to a pin.
What do you want to measure with the most accuracy ? Dark or light conditions ?
Measure the resistance of the GT36516 at that light and that is also the value for the resistor.
There are "100k" LDRs. I don't know if that will work. The analog input of the ESP32 is not accurate. You could remove the resistor to GND, that will help a little.
It's a car mesh network using bluetooth - all nodes are both sensors and controllers. The one with the touchscreen turns things on and off (external floodlights etc). All updates are OTA. The screen sits on the dash - my lipo button cells made most sense since there's no room there for bigger ones and the board already has lipo bms+charge included.
I most care about dark, which is when the backlight needs pwm - accuracy isn't important - near-enough is fine.
Thanks heaps for the diode suggestion - I'll do some experiments with a bunch of them and see which kind works best for the dusk/dark detection I need.
I use IR LEDs for dark detection, in photovoltaic mode (no resistor, no current draw).
The LED generates a voltage, like a solar panel, which can be measured with an analogue input.
Just connect cathode to ground and anode to an analogue input.
Remove any resistor, and keep wiring short or shielded, to avoid mains hum pickup.
Expect ~50-100mV with low light.
Leo..