Power meter issue (photoresistor)

Hi,
I have bought a photoresistor (http://www.ebay.com/itm/172263214271?euid=2cc8ff89f1f6470f9af7e2124d1f5b49&bu=44256571744&cp=1&sojTags=bu=bu) and got inspired to try to create a power meter as this blog describes http://www.thalin.se/2015/05/power-meter-pulse-logger-with-esp8266.html.

The basic idea is to count led/pulse blinks in the fuse box. 1000 blinks = 1 kw.
I use the digital output pin and triggers on state up. Seems to work great when the fuse box door is open , but if I close it too much or simulates with covering the “background” light it don’t work as expected.
It stops to count the blinks/pulses.

Any idea why? Any help is appreciated.

Hi. You just gave the same link twice. Can you give a link to the "photoresistor"? (There is an icon for inserting links into your post so that others can click on them instead of having to cut & paste.)

The blog you have given the link to shows a photo transistor, which is a different thing to a "photoresistor" by which I think you mean a light-dependent resistor (LDR)?

The code on your link is LUA script. So I assume you have attempted to translate this to Arduino code? Please post that using code tags.

Paul

Thank you for replying. I have fixed the links.
Yes, there is a difference there that I didn't notice, but I thought since it has a digital switching output. And it seems to work okay if there is "enough" light in the room. Is there a logic reason why it doesn't work when its dark and the led is blinking?

I have made small changes to the existing lua script(such as http endpoint etc.) and not translated it to arduino yet.

I see. It is an LDR on a module with a comparator and a pot to adjust the sensitivity. Are you using the analog or digital output?

If using the digital output, you would need to adjust (increase) the sensitivity for the dark conditions. Have you tried that?

Im just using the digital output.
I have tried to adjust the sensitivty without big luck.
There is as do-led that turns on/off when adjusting. I assume this could be to some help.
But it works with the fuse box door open no matter what I adjust it to.

I suggest you put the esp to one side for the moment. On a breadboard, hook up an led with a series resistor (200~300R). Using some long wires, connect 5V or 3.3V, ground and the digital output to the light sensor from the breadboard. The led should blink, repeating the led on the electricity meter. This will give you a quick way to find the appropriate setting for the sensitivity.

It may be that it is not possible to adjust the sensitivity for such low light conditions, or if it is, the PWR led is causing it to trigger all the time.

This is probably the schematic for your sensor...

If so, could test the A0 signal with a multi-meter or analog input to see what the voltage is with the door open and with the door closed. You may need to adjust the pot so that the voltage at 1IN- is just below the "door closed" voltage, but higher than the "door opened" voltage level.

Many electricity meters have an IRLED output that has a short pulse width to extend the life expectancy of the IRLED. It could have a pulse width as short as 2ms and be independent of pulse rate (power). The response of the LDR could be 30ms or slower, which means it's not a good match.

Another thing going against this working well is that LDR's peak sensitivity wavelength is about 560-600 nm, but the IRLED on the meter will be around 850nm-950nm.

A sensor based on photo-transistor or photo-diode matched to IR wavelength would be a better fit.

dlloyd:
This is probably the schematic for your sensor...

Maybe not exactly. That schematic shows an npn phototransistor. The eBay picture on the link in the OP clearly shows an LDR. The circuit is probably very similar otherwise.

dlloyd:
Many electricity meters have an IRLED

An Infra-red led? The led is supposed to be a visual indicator, what would be the point of using light we can't see? I can see the led on my electricity meter, that's definitely red, not IR!

I agree with your suggestion of the trying the analog input. It might be possible to code a sketch that simply spots a sudden increase in light level caused by the flash, rather than relying on a fixed trigger level.

An Infra-red led? The led is supposed to be a visual indicator, what would be the point of using light we can't see? I can see the led on my electricity meter, that's definitely red, not IR!

Well, that's a real fancy meter you have there!

The electricity meters on this side of the pond (Canada, USA) use the IRLED in the optical communication port as dual purpose ... serial programming/reading and energy testing. Out of hundreds of varieties I've tested (residential and commercial type), I've only seen a few with visible red (translucent) led and they were top of the line 0.02% accuracy class, designed for import/export metering.

Here is my meter. Now I look closely at it, there do seem to be two leds showing in the small window on the right hand side. Perhaps that is IR, as you say!
20150920_111408.jpg

Hi,

If you have this circuit, it is only using ONE of the COMPARATORS in the LM393.
D0 is the digital output.
A0 is an input as it goes to IN+, so A0 sets the THRESHOLD level, the pot sets the input SCALE.
So with no A0 potential (IN+) - (IN-)= less than zero, ie gnd.
0 - 2.5 = -2,5Vdc

So you need to supply probably 1/2Vcc or 2,5V to A0 to get it to work.

Tom.... :slight_smile:

Hi Tom ...

I think you mis-read the circuit ( it puzzled me for a moment)

IIN- is connnected to a pot 0..5Vcc
IIN+ is connected to A0, which is also the collector of the phototransistor.

So it ought to work

regards

Allan.

Hi,
Okay… so it has hysteresis.
That is just plain lazy… a gnd or supply line yes, but not a signal line.
2.jpg
So the output A0 is direct to the LDR in this case, so you should with a DMM measuring volts see a change.

No - ther's no hysteresis as there's no feedback from the ouput - just a plain comparator.

regards

Allan.

Hi,again, this is the circuit.
sensor-lm393.jpg

Tom… :slight_smile: