Optical pulse counter operating voltage

Having recently posted on both the First try with EmonPi - Pulsecount stuck at 1 - #10 by pb66 and Directly connecting to Optical Pulse Counter with RPi? - #60 by pb66 threads a question has cropped up that I think needs some clarification.

What voltage should the optical sensor be operating at for an emonpi?

I’m aware that the sensor itself can operate at both 3.3v and 5v, I have used it at both voltages without an issue, however when using it at 5v it has been with a 5v safe designed board.

When the pulse sensor is used with an emonTx it is powered at 3.3v and the potential 0v to 3.3v swing depending on light level is perfectly safe.

The pin 2 of the RJ45 on an emonPi is 5v not 3.3v like the emonTx, therefore the sensor is powered at 5v and can potentially swing between 0v and 5v, is this safe for the ATmega328p running at 3.3v on the emonPi? and if it is safe, can it return unreliable results?

In the first of the 2 links at the top of this post the pulse conters on board LED is flashing, but there is no pulse being registered, is it at all possible that the 5v based hi-lo change is not being detected by the 3.3v based MCU? I understand the output of the sensor is not digital “logic” but in fact analogue, but what I’m asking here is whether the same led pulse would be detected equally by a emonTx connected optical sensor and a emonpi connected optical sensor? I expect the thresholds will differ as the sensor is outputting a different level for the same light pattern/intensity, whilst the emon?? input sensitivity is the same.

We know from the emonTx v2 pcb error that the ds18b20 one-wire input works fine at 5v with a 3.3v device, but that IS a digital output.

@Robert.Wall’s tests in the second link show he has seen


so if the optical sensor LED is lit, we can assume the output voltage is well above the “acceptable ‘high’ state” for a 5v MCU, what does that mean to the emonpi’s 3.3v MCU?

I have some vague recollection from the old forum of someone using a sweet wrapper or a bit of floppy disc to get their optical sensor working, is that because they are limiting the light brightness to use just a smaller output voltage range perhaps?

I’ll try to figure out how to do some comparative tests. It could be tricky, as alignment of the optical sensor is fairly critical.