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

enter image description here

Now I would ask:

  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.

  • \$\begingroup\$ 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. \$\endgroup\$ – Wouter van Ooijen Jan 31 '17 at 12:14
  • \$\begingroup\$ 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. \$\endgroup\$ – Noisemaker Jan 31 '17 at 12:21
  • \$\begingroup\$ 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. \$\endgroup\$ – Wouter van Ooijen Jan 31 '17 at 12:47
  • \$\begingroup\$ 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.) \$\endgroup\$ – Noisemaker Jan 31 '17 at 13:23
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – 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.

A LP339 quad comparator (Ti's version) is spec'd at 60ua typical, 100ua worst case. Link: http://www.ti.com/lit/ds/symlink/lp339-n.pdf

Linear Technology has a 0.3uA (typical/quiescent) single comparator, but costs quite a bit more than the LP339. http://www.linear.com/product/LTC1540


I think this will be difficult. Be aware that the LDR (a broadband device) will also pick up ambient light - ask yourself how much the overall light level at the LDR changes when the LED is on. I have a feeling - not much (unless the LDR is right on top of the LED, but then why not make an electrical connection?) Also be aware that, even if you tune things so that you can just about pick up the LED flash - in ten minutes, when ambient light levels change, it won't work anymore.

You probably need to rethink this at the system level, in terms of sensors. What are you trying to achieve? Why are you trying to do it this way? Could you (for instance) use a matched infrared LED/detector (tuned to a specific wavelength)? Or some other method?

There may be issues with your opamp circuit, but you need to start off with a sensor that actually gives a signal you have a chance of detecting before you deal with that.


I wouldn't say that a photo-resistor is a broadband device. Quite the contrary if memory serves. More sensitivity and a faster slew rate would be obtained using a photo-diode or photo-transistor.

I can think of some servo-circuit using negative feedback for automatic biasing of the sensor-resistor divider - but that would potentially lead to high current consumption, high load on the sensor, and if the output signal is a rectangle (rail to rail clipped), the filtered DC product would be depending on duty cycle, much more than the sensor's quiescent current = the servo probably wouldn't work right...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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