4
\$\begingroup\$

I'm looking for a simple hack to minimise current when detecting change in light intensity using photoresistor. I'm using ATTiny85 in deep sleep (power down, ADC disabled, using below 1 microamp) waking by pin change (interrupt pin). After pin change ATTiny executes some operations and goes to sleep again. Device is powered with small battery and the battery should last for a year.

The event that wakes microcontroller is change on pin PB3. PB3 is connected to ground by photoresistor. Everything works as expected. Change in light conditions wakes the microcontroller, and after some actions it goes to sleep again.

The photoresistor, when it is dark, has 1 megohm resistance, so the current is minimal. But when it is sunny, the resistance falls below 10 kilohm, and the PB3 pin leaks above 50 microamps all day, even though the microcontroller is in deep sleep, not doing anything. I'm interested only in pin change, so after it gets sunny, and the low photoresistor resistance triggers PB3 I'd like somehow to block the current flow till the next change.

Is there any simple circuit (possible using capacitor?) to achieve that?

\$\endgroup\$
6
  • 2
    \$\begingroup\$ how is the LDR draining the battery? ... what is the circuit? \$\endgroup\$
    – jsotola
    Jan 7 at 20:55
  • 10
    \$\begingroup\$ Consider using a photodiode/small solar cell to generate a current for the signal instead of using a resistor to shunt it to ground. \$\endgroup\$
    – vir
    Jan 7 at 20:56
  • 1
    \$\begingroup\$ +1 @vir, even a LED can be used as "solar cell" \$\endgroup\$
    – bobflux
    Jan 7 at 21:22
  • 1
    \$\begingroup\$ @vir your comment deserves an update to an answer. It has many interesting possibilities, for example photocell can be wired to power the circuit when it is sunny to extend battery life. If combined with supercap it may even take over entirely, turning battery into a mere backup. \$\endgroup\$
    – Maple
    Jan 7 at 23:17
  • \$\begingroup\$ @Maple I agree but I am currently just on my phone and also unfortunately supercap backup is not my forte. I'm sure someone else on here is though! \$\endgroup\$
    – vir
    Jan 8 at 1:19

1 Answer 1

8
\$\begingroup\$

Sleep on the watchdog timer (or other low power timer) instead and then only power the photodetector at the end of each sleep.

Connect the top of the photoresistor circuit to a GPIO so that you can power the circuit off.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
3
  • \$\begingroup\$ Using periodic waking up each second with watchdog timer could be in fact simpler. I could store previous reading in memory (as I undrestand the variables in memory are retained even during deep sleep) and detect change. What is the correct wiring of input pin to photoresistor for maximum current saving? Right now I have pin connected by phototransistor to GND - is this correct way? \$\endgroup\$
    – PanJanek
    Jan 9 at 8:31
  • 1
    \$\begingroup\$ GPIO2 in this diagram is digital input right? \$\endgroup\$
    – PanJanek
    Jan 9 at 10:09
  • \$\begingroup\$ yes, indeed it is. \$\endgroup\$ Jan 9 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.