# ESP8266 detect LED flash with photoresistor Schmitt trigger?

I made some experiments with ESP8266 to detect when an external LED is on or off (I need to log this activity). This is the test-circuit I used till now:

simulate this circuit – Schematic created using CircuitLab

I have a lot of programming experience, but every time I need to deal with the electronics circuits I have some difficulties, so the above schematic may be wrong. All resistor values are empirically calculated. I used a wave generator (5Hz) to simulate LED flashes, and on the oscilloscope I get:

• LED on: ~3.22V on (-) OAMP pin
• LED off: ~1V on (-) OAMP pin
• On (+) OAMP pin I set ~2V

1. How can I improve this schematic?
2. How to reduce power consumption?
3. Does exist a better OAMP (instead of LM358) specifically designed for low power circuits?

Here there're some glabal tech spec:

• VDD: 3.3V
• Max led frequency: 2Hz
• low power consumption
• I need to measure the time interval between two pulses to detect system (which LED belongs to) state. For example: 1sec between two pulses mean state A, 0.2sec between two pulses mean state B, etc..

NOTE: in the final circuit I cannot interfere with LED and its circuit, I can only watch its light.

• AFAIK the ESP8266 has an A/D input, why don't you use that to read the LDR / 10k input directly? You can calculate a running average, and decide whether the LED is on by comparing the current imput to the average. Add some hysteresis and delay to suppress inteferences. – Wouter van Ooijen Jan 31 '17 at 12:14
• I think about that, but to save power I'm planning to use the HIGH/LOW output from OAMP to wake up the ESP8266, then sleep again. – Noisemaker Jan 31 '17 at 12:21
• Are you sure that's worth the trouble (= extra circuitry)? I guess you are just counting, not doing accurate timing measurements? You could wake the ESP at 10 Hz and poll the A/D. – Wouter van Ooijen Jan 31 '17 at 12:47
• Uh, I miss that in tech spec, I will add. I need to count pulses and measure the time interval between them. The led frequency is variable, so I need to measure period to know the system state according to led pulses (eg. 1sec between 2 pulses mean state A, 0.2sec between two pulses mean state B, etc.) – Noisemaker Jan 31 '17 at 13:23
• I can't understand the title: what you are implementing in the schematics is not a schmitt trigger: there is no positive feedback. It's a regular comparator. – next-hack Aug 24 '17 at 7:43

how to reduce power consumption? does exist a better OAMP (instead of LM358) specifically designed for low power circuits? Since you are using an op amp as a comparator, a comparator is all that is needed and will save power. Search around to find a comparator that fits your needs, the following are a few examples.

The TI version of the LM358, is spec'd at 0.7ma typical/1.2ma worst case quiescent power supply current.