# Phototransistor at end of long cable - picking up noise

Hi!

I'm trying to build a power use monitor, reading infrared pulses emitted by my electricity meter using a phototransistor. I have a working circuit with phototransistor and pull-up resistor that is working well when I test it on breadboard and soldered to experimental board with a short (~1m) cable.

However, my electricity meter is located in a cabinet outside, so I've run a cable (unshielded 4x0.2mm, using three of the wires) which is about 10 meters long, and in this setup, I seem to get an unstable signal, with the digital input flickering between HIGH and LOW very quickly. If I send infrared pulses to the phototransistor I can see that they get through, but with so much noise that it's impossible to use.

Being a bit new to electronics, I imagine I've hit some kind of standard problem transferring signals over long cables, so I'm looking for an explanation of what's happening, and ideas on how to solve the problem?

Some details:

The phototransistor (LTR3208E) and its pull-up resistor (1MOhm) is at the electricity meter end of the cable, but I've also tried having the pull-up at the arduino end with the same result.

Decrease pull-up resistor value to 100 k , or even 10 kOhm, and try again.

You're right about the probable cause, and the suggestion of changing the pullup value will also lower the impedance and decrease the noise VS signal.

There are 2 or 3 other possible approaches:

• Add a capacitor across the Arduino input to ground to slow down the response. The on-off frequency of the electric meter is probably pretty slow. (Do you know how fast it might be at maximum power??) The capacitor value you would need to experiment with. But I expect .1 uF might be OK.
-- The TIME factor the capacitor adds is calculated as T=R*C so if your pullup resistor was 100K (10 to the 5th power) and the capacitor was .1 MICRO Farads (10 to the minus 7 power) then T=10 to the -2 power or .01 seconds which sounds pretty reasonable.

• What is your cable like? Are the 4 wires separate or are there twisted pairs?? Twisted pair wires pick up much less noise. Try using CAT5 Ethernet cable. Connect one side of the twisted pair to ground at the Arduino only.

• With 4 wires (or 8 with CAT5) you can also run +5V and ground out to the sensing point, and add an additional transistor as a "voltage follower" with a low-value (maybe 1K ) pullup, or even add a comparator like an LM339 with a couple of resistors to set a comparison value. A little more complex but inexpensive.
(A comparator compares two voltages and outputs a strong pulldown when one voltage exceeds the other).

Let us know what you try and what works! We all can learn from these things...

Regards, Terry King
terry@yourduino.com

You could instead try a photodiode and build a simple "current loop" circuit. Or probably better use your existing phototransistor in a current modifying circuit rather than a voltage amplifying circuit. Something like that is usually more noise resistant over long cable runs.

First - thanks to all of you for your constructive replies!

• Lowering the pullup value is tricky in this case, as a lower pullup value seems to decrease the sensitivity of the phototransistor. In breadboard/short cable setup, the lowest pullup I've managed to get a signal with is 47k. that doesn't work with long cable though. I did make an attempt with 220k which seemed to work when testing with an IR remote control, but after happily soldering it together and mounting on electrical meter, I seem to get every second or third pulse - probably due to the IR diode on the electrical meter being weaker, and possibly also due to more noise when a longer piece of the cable was inside the all-metal cupboard where the meter is.

So, I probably need something more robust.

• Regarding on-off frequency, the meter is outputting a 2ms pulse for each Wh being consumed, and it's a 3-phase 400V 25A connection to the grid (more or less regular household connection for being Sweden, a bit on the high side due to house being heated by electrical boiler). So that's 17320W max resistive effect if I understand correctly, which would mean in an hour I could consume 17320Wh, meaning the max number of such pulses per second is 4.8.

• The cable is 4 separate, non-twisted wires. I might try a CAT5, if I find a thin one - I have some constraints when it comes to getting the cable through small holes.

I'll probably give that comparator idea a try. Seems like something I could learn from. I'll be back with results.

I'd switch to using screened cable. Cat 5 should work, but mono audio cable should work just as well provided the total capacitance is less tan 1nF. Connect the inner core to the Arduino pin and the screen to whichever of Vcc and GND you have as the other connection to the phototransistor.

You could also try adding a capacitor in the range 330pF to 1nF from the Arduino pin to ground.

I presume you are polling the input pin sufficiently often so as not to miss the 2ms pulse? If you are polling other analog pins too, then I suggest you read the phototransistor pin twice and discard the first reading.

IMHO, capacitors would not help much, with 2 ms impulse capacitors more likely to suppress useful signal than interference (50 Hz or so) . Better to amplify current from phototransistor at meter side, connecting phototransistor to base - collector additional small signal transistor and setting low value (10 k) pull-up resistor at the arduino side.

Better to amplify current from phototransistor at meter side

Magician is definitely on the right track. Your signal is in microAmps. It's no wonder you have a noise problem. The darlington connection he has suggested will give you a current gain of several hundred. I would put my resistor between the emitter and ground, however, because the increased saturation voltage of the darlington pair may not give you a reliable logic zero value. Try a 1K emitter resistor. The resulting pulse will be from LOW to HIGH in that case.

because the increased saturation voltage of the darlington pair

You don't get increased saturation voltage from a transistor in a darlington pair. It is just the same as if the transistor was by itself.
You do get increased Vbe are you mixing the two up?

are you mixing the two up?

Don't think so.

The saturation voltage of the Darlington pair can never be less than Vbe of the output transistor plus Vce(sat) of the input transistor. Therefore, typically it is about 0.65V above that of a single transistor.

Yay! The transistor trick really did the trick!

I ended up going for EmilyJane's variant, with pull-down resistor. Here's an ugly image showing my final, working, circuit.