Voltage and sensor puzzle

I want to read a signal line that is 5.66v when on, and 2.00v when off.

What would be a simple way to read this line from a 3.3v Arduino?

Speed is not an issue.


To be read as a digital input signal, one way would be to use a comparator op-amp using a say 2.5 volt reference on the - input.

If speed is not a issue then you could just apply the signal to a two resistor voltage divider (using two equal size resistors, say 5k ohms each) and measure it with a analog input pin, then use code to convert the measured value to a true or false value.


Well I would use a transistor and feed the base through a voltage divider. Arrange the voltage divider so that you get 0.5V on the low voltage of 2V at the base. Then that will ensure the transistor is off. When 5.66V is applied the base goes above 0.7V an turns the transistor on. You need a pull up on the collector but the internal one will do.

I like to use opto isolators.... Slight overkill, probably, but simple things work best for my simple mind!

Optoisolator explained:


A dual (two gate) device can be had for $1. You also need a resistor.


The main problem with using an opto is that the input voltage has to be enough to drive the LED. Often sensors can't supply this much current, but as he hasn't mentioned what sensor he is using we can't tell.

Thanks for your replies. The “sensor” is really a hack; I tapped into a garage-door monitor’s LED wire and found that line. I don’t know how much current I can draw from it.

Grumpy-Mike, I think I will try your transistor solution, since I have some 2N3904s lying around. But what value to select for the base resistor has me stymied:

  • Can I treat the upper resistor of the voltage divider as the base resistor at the high voltage output, ignoring the lower resistor and the connection to ground?

  • What base current would I try for, given that I am concerned with getting a high/low reading at the collector when tied to the pullup, rather than current per se? I have a feeling the answer is more rule-of-thumb than calculation, but I am a newbie on these matters and only know what the textbooks say about transistors.


I have a feeling the answer is more rule-of-thumb than calculation, but I am a newbie on these matters and only know what the textbooks say about transistors.

You might consider using a three terminal pot for the base voltage divider and just adjust the wiper until the turn on/off switch point is between the signals on and off voltages. You can then measure the pots two ohm values and use fixed resistors if you want. Who needs math when a simple variable adjustment will do the job. :wink:


Lefty - but my confusion is really about the absolute value of the resistors. From what I understand (which is not much) a voltage divider depends on the relative values of the resistors.

But the value of the upper resistor will determine the base current & whether the transistor goes poof, doesn't it?

I.e., if I was using a pot to get an empirical value, would I start with a 1k pot? 10k? 100k?

I would try a 10k one as you don't require much collector current for this situation. If the collector is going to wire to a digial input pin that has it's internal pull up enable (say 40k-50k ohms), very little collector current is going to flow even when the transistor turns on fully, so there is not much base current required (remember that a npn transistor is a current amplifier) What is being attempted is to find the adjustable base voltage that does not exceed the forward voltage drop of the emitter/base junction when the input signal is at it's LOW voltage. And when the signal is at it's HIGH voltage value we just have to insure that there is enough base resistance (using either fixed resistors or a pot) such that the then forward biased emitter/base junction does not exceed the maximum base current specification.

Success! I used a 100k pot (well, actually an 84k pot - which is what Radio Shack sells as a 100k pot). It was easy to adjust the pot and find the threshold where the high signal would turn the transistor on enough to register as a LOW on the Arduino pin.

The transistor brought the Arduino pin low at about 67 uA of base current, which yielded 90 uA of collector current. Interestingly (for me), at the lower base voltage the base current was 24 uA with no collector current. I was surprised to measure any base current at that voltage (VBE about 0.3v).

Thanks for the help guys!