0

I have a wire with a 0-5v current. I want to detect if the current is there or not (HIGH/LOW.)

I'm using an optocoupler to avoid putting too much current into my micro, as it is only a 3.3V micro. I'm nervous about powering this on as one of my other micros stopped working although it's not clear if it could have been the circuit?

enter image description here I could not find my optocoupler in fritzing. This is it: http://www.amazon.com/gp/product/B00CGXK1RG?psc=1&redirect=true&ref_=oh_aui_detailpage_o07_s00

This is my plan.

The microcontroller is a spark/particle core. It the yellow wire connects to the analog/digital pin A6. The screw terminals connect to the wire with the 5v current that I'm trying to detect.

The microcontroller is a spark/particle core 3.3v. It the yellow wire connects to the analog pin A6. The screw terminals connect to the wire with the 5v current that I'm trying to detect.

I based my circuit on this:

enter image description here

But I don't know if it will do the same thing.

enter image description here

futurebird
  • 425
  • 5
  • 15

2 Answers2

5

Wouldn't this be simpler?

3.3v voltage detector

Note: amended answer increases R1 to 10 k.

The 10 k resistor limits current to 0.17 mA. The 3.3 V zener diode clamps the input voltage to 3.3 V (I measured 2.3 V on mine so that is well within spec). The other end of the zener diode goes to the Arduino ground pin.

I originally had R1 as 1 k however if you had a high voltage input (like 20 V) it didn't quite clamp the pin to 3.3 V (more like 3.8 V). This is a bit high for an input pin, so I tried 10 k instead.

This gives:

  • For an input voltage of 5 V -> 2.3 V on the Arduino input
  • For an input voltage of 10 V -> 2.6 V on the Arduino input
  • For an input voltage of 20 V -> 2.9 V on the Arduino input
  • For an input voltage of 30 V -> 3.1 V on the Arduino input

This is all within spec for the Arduino.

Now the question is, will 2.3 V on the input pin register as HIGH? The answer is "yes" because high is considered to be 0.6 * VCC.

3.3 * 0.6 = 1.98

Thus any voltage of 1.98 or above is considered HIGH, and it will successfully read 2.3 V as high.

Nick Gammon
  • 38,901
  • 13
  • 69
  • 125
1

Based on the revised information given above I present a different answer. Use the opto-coupler as shown here:

Your kettle LED will be in series with the optocoupler (note the polarity, not reversed like in your question).

If the LED is on the transistor in the PC817 will conduct and the Arduino pin will be LOW. If the LED is off the transistor will not conduct and the Arduino pin will be HIGH.

enter image description here

Note: The Arduino pin will be the reverse of the kettle LED.

I'm leaving the other answer there because I think it is a reasonable answer to the question of "detect a voltage".

Nick Gammon
  • 38,901
  • 13
  • 69
  • 125