0
\$\begingroup\$

I'm taking a 3.3v output from the NVR video surveilance alarm led. Since this NVR doesen't have alarm output I've removed the alarm LED and used this as input for my ESP8266. Everyting works fine but I can't understand why is the output now inverted i.e. when the alarm is triggered the output is LOW and when it is not triggered it is HIGH. This happenes when I connect GND from NVR to GND on the ESP8266. If GNDs are not connected, trigger works as supposed - HIGH on alarm and LOW on no alarm.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Perhaps the NVR alarm LED's anode went to local + supply voltage, and its cathode was pulled to logic low (through a series resistor) to light up the LED - this is a common technique. If you want independent GNDs between NVR and ESP8266, have you considered using an opto-coupler? \$\endgroup\$
    – glen_geek
    Jun 16, 2022 at 13:11
  • \$\begingroup\$ Thank you for your reply. Yes yes, that could be the issue since the LED has a current limiting resistor (I didn't remove it). If I isolate GNDs will the NVR still trigger ESP8266 input since they will not share common ground ? \$\endgroup\$
    – Marc
    Jun 16, 2022 at 17:58

1 Answer 1

0
\$\begingroup\$

A direct connection from NVR alarm LED driver to ESP8266 digital I/O input is possible only if the GND of one connects to GND of other. It is assumed that both NVR and ESP8266 are powered with a DC supply of similar voltage (+3.3V?):

schematic

simulate this circuit – Schematic created using CircuitLab
If complete isolation between NVR and ESP8266 is desired, an optical coupler is a versatile solution. Its advantages include:

  • Vdd1 can differ from Vdd2
  • GND of NVR is isolated from GND of ESP8266 - no electrical connection exists between NVR and ESP8266.
  • you have the option of sensing logic high or sensing logic low

The disadvantage of opto-coupler is loss of the NVR LED alarm indicator, since the opto-coupler internal LED (which is not visible) replaces it. R1 (assumed 100 ohms) and R4 (also assumed 100 ohms) are the NVR LED's present series resistor. The opto-coupler internal infra-red LED simple replaces the visible LED:

schematic

simulate this circuit

At left, R2 is a pull-down resistor at ESP8266 digital input. When the opto-coupler LED is inactive, R2 pulls to logic low and only goes high when LED current flows.

At right, R3 is a pull-up resistor for ESP8266 digital input. When the opto-coupler LED is inactive, R3 pulls to logic high and only goes low when LED current flows.

\$\endgroup\$
3
  • \$\begingroup\$ Your answer is fantastic ! NVR has a molex output for HDD so I'm using its +5v pin to drive the ESP8266. That way they share grounds. I like your opto coupler explanation, it will help me in my future projects. One more question, I'm driving a flashing 12V 70mA LED lamp from the ESP8266 digital output. I plan to use a BC547B transistor. Digital output is connected to the base of transistor, GND is connected to emitter and collector is connected to gnd of lamp. I'm having trouble calculating the required resistor value from digtal pin to base connection. Do I also need resistor for collector ? \$\endgroup\$
    – Marc
    Jun 16, 2022 at 21:24
  • \$\begingroup\$ Resistor between ESP8266 and transistor base would be in the 1000 ohm ballpark. Can't tell if you need a collector resistor - that LED lamp might include one? \$\endgroup\$
    – glen_geek
    Jun 17, 2022 at 0:02
  • \$\begingroup\$ How can I tell if LED lamp has it ? It is a T10 12v led smd lamp used in cars. \$\endgroup\$
    – Marc
    Jun 17, 2022 at 8:31

Your Answer

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

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