Detect optical pulse from water/gas/elec meters

Hi all

Just a quick question. I'm undertaking a small project to try and 'count' the optical pulses from gas/elec/water meters. Would the Maplin SFH2030/SFH2030F (IR) sensors be sufficient for this? Ideally what I'd like to do is produce either a change to HIGH or LOW voltage whenever a pulse is detected.

Any suggestions/input on the suitability of these sensors and how they might be connected would be greatly appreciated.

Thanks! ;)

Richard.

Hi,

yes, connect the athode to +5V and the anode with a 47k resistor to GND. Connect the junction of the diode and the resistor to an digital or analog input of the Arduino. The digital input works only, if the light puls is intensive enough. Better use the analog input, then you can determin the switching level, hysteresis etc. by yourself.

Mike

I'd go for something like this :

http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=4550767

Its a phototransistor rather than a diode so its more sensitive and being side looking, its a doddle to stick it on your meters with tape. I have a similar one counting blips on a meter with a red LED, with a 100k resistor and on a digital pin using interrupts.

Very interesting and a cheap way to measure consumption from electronic meters for electricity we have in Italy

There is a topic also for meters with reed switch like the methane gas ones. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1244509204/6#6

Hi everyone,

Thanks for your input.

I've had limited success with detecting a 50 or 100ms blink from an LED using these sensors. I've decided to give Pluggy's idea a try and placed an order with RS for some phototransistors instead, hoping that the extra sensitivity will yield better results. The idea of using it with a digital pin, too, is desirable.

Cheers

Richard

Hi

Just a quick follow-up question. For this project, the sensors will need to be approximately 10 metres from the Arduino. As a relative newbie, I'm aware that voltage will drop off over distance but I'm not sure if this will affect the outcome of my project. Is there anything I should be aware of when using the phototransistors over this distance?

Thanks,

Richard.

The one I'm using is around 8 metres from the arduino, since its already an high impedance circuit a few extra ohms in the wiring is immaterial. if you were trying to measure a high speed signal, the capacitance of a long run might come into play, but if your meters are anything like mine they blink somewhat infrequently (at the most once a second in my case, more often than not a lot less frequently ) and the odd micro/milli second delay isn't going to be an issue. I use a single twisted pair I pulled from a length of CAT5E cable.

Is there anything I should be aware of when using the phototransistors over this distance?

Noise: if not properly wired, you're basically setting up a 10-meter antenna that will try to attract electrical noise into your system. And quite possibly succeed.

I would use a twisted-pair cable, like telephone wire or Cat5, and make sure all the unused wires are grounded. Also, use a strong pull-up, instead of a weak one, on the input. Say, 1K, rather than the 10K or so commonly used.

Try to borrow an oscilloscope to check the input to see whether you've killed the noise. If you haven't, you can use the "spare" conductors in the twisted-pair cable to send power out to the sensor (I would use 9-12V, and use a local 78L05 to regulate it down to 5V), and add a balanced line driver designed to overcome noise (like a 75176) to get a solid signal back to the Arduino.

Ran

Well, I'm bugged with the noise in this situation, and trying to find a sollution for weeks.

You say grounding the not used wires in cat5/6 cable, do I have to do that on both ends?

What else can be done to eliminate the noise?

Greetings, Eric

Hi all

Pluggy - as per your suggestion, I tried some phototransistors. I ordered parts #6548031 and #6547993 from rswww.com. I'm having almost no luck at all detecting the light from a blinking LED.

Could you suggest a suitable wiring setup so that I can connect it to a digital input, and maybe get a HIGH or LOW whenever there is a burst sufficient enough?

I tried an analog setup but there doesn't appear to be a big enough difference in readings between no light and bright light, so maybe my circuit's wrong?

What resistor would be a good value to use?

Thanks,

Richard.

Hi all

Just an update. Pluggy - I'm not sure if you're aware, but I've since learned that the part numbers you suggested have their peak sensitivity in the UV range which of course isn't going to give me very good results in the visible range.

I'm trying to find some suitable parts on rswww.com to do what I need.

Thanks

Richard.

The link I posted was for IR (not UV) phototransistors although their range does extend into the visible red end of the spectrum. From your initial post I took it as these were what you were trying to read.

The actual one I have used is

http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=654-7993 (the same one as one you've ordered apparently. )

Since the LED its watching is red. It is wired as the right hand side of this circuit (the LH is for a LED as for a reflective object sensor and can be ignored) with a 100k resistor and the test point is connected to a digital input pin.

It typically reads 4.6 volts with a meter between blinks and drops to just under a volt when the LED flashes. Its just taped onto the glass over the LED with black insulation tape. It is 'handed' and only works one way, there is a small raised pimple on one side (on mine at least) which must be put towards the LED, it was practically blind stuck on the other way round. The collector and emitter are connected to a 8m length of twisted pair pulled from a length of cat5E (it yields another 3 similar pairs ;) ) the resistor is local to the arduino. Its in a 3 phase meter cupboard so it probably isn't the electrically cleanest environment. Depending on your milage, you may get away with a lesser resistor (it decreases the sensitivity of the phototransistor in this instance - the lower the resistor, the brighter the blip needed to sink enough current to drop the voltage) to help if you have a noise problem.

Hi Pluggy

Thanks for replying and for your circuit diagram - I think it's just what I need and I look forward to testing it out tomorrow and letting you know how it goes.

To test, I'll be rigging the Arduino to blink a standard red LED at 5 second intervals (to simulate the pulse from the meter) and attach an interrupt to the pin so I can hopefully blink a green LED at the same time the RED one is detected.

I'll let you know how it goes.

Thanks

Richard.

Let us know how you get on. I had trouble until I discovered the pimple and the one way sensitivity.

You can see the fruit of my labours here :

http://pluggy.is-a-geek.com/majestic.html

The electricity graphs are done by the photo transistor. I'm adding some more stuff today if all goes well.

It has its down sides, I went round there at midnight last night to turn off some lights that somebody had left on.........

Hi Pluggy

I'm trying this now and I'm still having trouble :)

In my test rig, I basically have a red LED pointing directly at the pimple on the phototransistor (the LED connected to a test switch, as in your diagram). Here's my test program:

void setup() {
  attachInterrupt(0, chg, FALLING);
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
}


void loop() {
}

void chg() {
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
}

Pin 13 has a GREEN led attached to it - that's supposed to FLASH whenever I press the switch to flash the RED LED (i.e. the phototransistor has dropped the voltage on digital pin 0). But it just doesn't drop it low enough. Starting to get very frustrated now!

At this point I can't seem to figure out how to wire the phototransistor properly to even test whether it's working: can you perhaps suggest how I might go about checking that?

Thanks

Richard

Just a quick update to say that when attaching a multimeter, I see a voltage of 4.97V arriving at digital pin 0, which drops to ~4.71V when my test LED is on.... which doesn't appear to be a significant enough drop to trigger a LOW reading on the input pin.

I've tried up to a 680k resistor, right down to a 1k - still the same result. I can only conclude I have wired this up epically wrong :)

I have a suspicion that may be at the junction between the collector, test point and 5v.

I've got:

Collector +5V ---- Resistor ---- | --------- Emitter -----> GND Test Point

I think :)

Thanks,

Richard.

You say grounding the not used wires in cat5/6 cable, do I have to do that on both ends?

As counter-intuitive as it might seem (more grounding should be better, right?), you only want to ground the wires at the Arduino end. Ideally, there should be one central point from which which all ground lines in a system radiate. It doesn't always work out that way in practice, but every deviation from the "single ground reference" model is a risk. Usually a small one, but you'll often see posts here from people with mysterious problems that turn out to be ground loops.

In this case, since you're optically coupled to the meter, you don't care at all what "ground" is out there, so you want to avoid any problems that might be caused by trying to reconcile it with "ground" at the Arduino. If your sensor were electrically coupled, you'd need to sort that out, but you'd also need to talk to a real EE, instead of a software guy who's learned electronics on the job from working with real EEs ;)

If you're still picking up noise after grounding the other conductors, try putting a small capacitor (.01 or .1) from the input to ground. That will smooth out some of the noise, just like the filter cap in a power supply.

You should also check on whether your phototransistor is seeing light other than that coming from the meter. If there are fluorescent lights nearby, their flickering light could be turning the phototransistor off and on in a way that looks like you're picking up electrical noise.

Ran

hi

  1. transistor polarity: i would just try both possibilities with a big resistor...

  2. signal shaping: maybe a voltage divider would help to reduce the output voltage? or a bigger resistor between +5V and the transistor? or an opamp? here u find a motion sensor signal processor: http://www.discovercircuits.com/I/infrared3.htm http://www.glolab.com/pirparts/pirmanual.PDF

bye

Hi all

Just to update the thread: using Pluggy's circuit, I am now getting the expected behavior. The problem initially was that the resistor value was wrong, making the phototransistor to sensitive to ambient light. This was evident when I put the sensor in an enclosed box and it worked perfectly. A bit of further experimentation cured the problem.

Now I just have to figure out how to 'count' the 250ms pulses of light for each of the three inputs. I think I'm going to have to implement a degree of debouncing, but other than that -anyone have any suggestions?

Thanks

Richard.

Now I just have to figure out how to 'count' the 250ms pulses of light for each of the three inputs.

1, 2, 3, 4, 5, 6, ... :D