Whats the output from : Optical Utility Meter LED Pulse Sensor

Hi guys

Whats the output from the 3 wires on the : Optical Utility Meter LED Pulse Sensor

I want to connect this sensor directly to a Raspberry Pi, or to a RaspIO Analog-> Digital converter (takes 0-1V input, gives related output)


This is a cross-posting.

Could you link to the cross posted thread @Robert.Wall?

@georgel the output of the pulse sensors is a TTL square wave. Since it’s digital it can be connected directly to a RasPi ADC is not needed. Ideally use an input setup as an interrupt to ensure pulses are not missed.

The sensor can handle 3.3V > 5V VCC.


1 Like

I don’t believe it is, since this thread is asking for info on the output of the pulse counter while the other thread is regarding connecting a CT sensor to a Pi via a ADC. I’ve unlocked the thread.

I counted it as a cross-posting, because the same question was asked in two threads. The whole point of not cross-posting, as I understand it, is to prevent the answer being repeated across multiple threads.

Can you elaborate,

don’t understand what you mean by “Ideally use an input setup as an interrupt to ensure pulses are not missed”


NOTE: the RaspIO AnalogZero board can not handle the CT’s we use to do home monitoring, the board is only DC capable.


I don’t have the data for that board to hand, but if it’s only d.c. capable in the same way that the Atmel 328P ADC input is 0 - 3.3 V only, then you adopt exactly the same solution: Apply a constant bias to the input signal to position it in the middle of the range, then remove that bias in the software.

You should use an Interrupt driven digital input to ensure pulses are not missed. The output of the pulse sensor is a fully digital square wave.

Were you looking for an explanation of interrupt-driven software?



It seems that Glyn did not appreciate that.

Think about the standard energy monitoring sketch. It reads the voltage, it reads the first current, it does some maths on those numbers, and then it does it again, and so on for 200 ms. Then it does some more maths to calculate the average values. Then it does all that again for the 2nd, the 3rd and the 4th currents. Then it sends the answers off to emonCMS. Then it watches the clock for 9 seconds or so and does it all again.

What happens if a 100 ms long pulse comes in? If it comes while it is watching the clock, it will see it. If it comes while it is doing anything else, it will miss it.

Atmel thought about this. They provide an input pin that you can allocate to a special purpose - to “interrupt” whatever the code is doing and go to an “Interrupt Service Routine” to do something different. When that finishes, the main code carries on where it left off.

To make this work, you need 3 things in the sketch:

  1. A specially defined variable that is shared between the main code and the ISR.
    In the standard sketch, it is the pulse count volatile byte pulseCount = 0;
  2. In setup( ) , you link the pin to the ISR: attachInterrupt(pulse_countINT, onPulse, FALLING);
    “onPulse” is the name of the function that runs when a pulse is detected on pin “pulse_countINT”, and “FALLING” means the interrupt happens on the falling edge of the pulse (see the Arduino documentation for the choices for that).
  3. The function to do something when a pulse is detected. The very simplest is
    void onPulse()
    but if you look at the sketch, we do a little more than that to remove the effect of “contact bounce”.

There you have it. Something happens on a special input pin, the normal sketch is interrupted while it does something different, then it goes back to what it was doing - the interrupt drives the flow of the program in a different direction.

will have to read this a couple more times, to unpack and understand :wink:


Glyn ??? hope you still smiling …