S0 Electricity meter on pulse counter does not work

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
_Cyber_
Normal user
Posts: 99
Joined: 20 Oct 2019, 09:46

S0 Electricity meter on pulse counter does not work

#1 Post by _Cyber_ » 04 May 2022, 08:14

Hi,

have a wemos D1 with latest espeasy build (2022_04_27).
Attached to it and working: An Panasonic EX-26A to collect pulses from a watermeter. I attached it as shown here (https://github.com/Froschie/water-meter ... on-diagram) in the schematics exactly the same way, but on D7 Pin - so there is a parallel 10k-resistor between 3.3V and D7

Now I tried to attach two Electricity meters S0 (https://www.amazon.de/gp/product/B01EFSXU6I) to Pin D6 and D5. Both do not work, there is no count recognized.
The 3.3V line is attached to "+" (or Pin 20) to the Power meter, the "-" (or Pin 21) is attached with a 10k resistor in series - one time to D6, the other to D7.

I have the Pulse Counter Tasks set on position 1 (the working WaterMeter) and position 2 and 3 (the not working Power Meters) (I read this: viewtopic.php?p=46358&sid=e99040789d644 ... 689#p46358 ).

I tried all working modes in the Pulse Counter tasks.

Any ideas what I need to change?

Thanks. :-)

_Cyber_
Normal user
Posts: 99
Joined: 20 Oct 2019, 09:46

Re: S0 Electricity meter on pulse counter does not work

#2 Post by _Cyber_ » 04 May 2022, 11:31

hm, from the manual: Pulse output - OC, 12 ... 27 V / 27 mA (max) / 90 ms

means I need to put 12V on the + I guess.

User avatar
Ath
Normal user
Posts: 1677
Joined: 10 Jun 2018, 12:06
Location: NL

Re: S0 Electricity meter on pulse counter does not work

#3 Post by Ath » 04 May 2022, 11:50

Or, more likely, a level converter? As the ESP probably won't survive that 12V
/Ton

TD-er
Core team member
Posts: 6175
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: S0 Electricity meter on pulse counter does not work

#4 Post by TD-er » 04 May 2022, 12:17

OC means open collector.
So it seems it is the transistor part of an optocoupler.
This means it may indeed pull the voltage on the pin upto the voltage you supply.
Better measure the actual voltage there.

N.B. the transistor side of an optocoupler has a specific direction to conduct current, just like a diode.
So make sure you've not swapped the + and -.
If you did, you may have saved your ESP, so measure first.

_Cyber_
Normal user
Posts: 99
Joined: 20 Oct 2019, 09:46

Re: S0 Electricity meter on pulse counter does not work

#5 Post by _Cyber_ » 04 May 2022, 13:29

can I use there PC817 optocoupler? I have some of https://www.aliexpress.com/item/1005002006610372.html around here

TD-er
Core team member
Posts: 6175
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: S0 Electricity meter on pulse counter does not work

#6 Post by TD-er » 04 May 2022, 13:41

I don't think you need to add another optocoupler.

What you need is something like this: (which by accident also uses the exact same optocoupler as you mentioned)
Image

The left side of the schematic isn't interesting as that's already taken care of.
The right side now shows a resistor which pulls up Vout to the 5V level (or whatever voltage you apply there) when the transistor is open.
When the transistor closes, it will pull Vout to GND.

By adding a second resistor over Vout and GND, you will create a voltage divider.
This second resistor is then "shorted" to GND when the transistor closes.

The max. voltage over GND and Vout is depending on the ratio between both resistors.
Let's assume you have a 1:2 ratio of resistors, like 10k and 4k7.
10k between the "15V" you plan on using and Vout
4k7 between Vout and GND.

The highest voltage over Vout and GND is then roughly 1/3rd of the 15V. = 15V * (4k7 / (10k + 4k7)) = 15 * 0.32 = 4.8V

_Cyber_
Normal user
Posts: 99
Joined: 20 Oct 2019, 09:46

Re: S0 Electricity meter on pulse counter does not work

#7 Post by _Cyber_ » 08 May 2022, 14:43

I tried to understand, i am sure i did not.
I have now changed the s0 input voltage to 12v. before connecting it to gnd i have two resistors placed, 3.3k, 10k, then to ground.
Between the two resistors there is the leg which goes to the gpio.
If i connect only the +12v and gnd (and bridge the two ends where the s0 would be in between) i can measure 2.98v between the gpio-pin and gnd.

Still if i connect everything together the pulse counter (switched to change mode) does only account manually closing the two contacts. If the s0 counter does it is not recognized.

Do i need to put between the gpio and gnd an additional 10k resistor to have it on LOW all the time, until a pulse comes?

Thanks, and sorry if the questions are maybe stupid. :shock:

_Cyber_
Normal user
Posts: 99
Joined: 20 Oct 2019, 09:46

Re: S0 Electricity meter on pulse counter does not work

#8 Post by _Cyber_ » 08 May 2022, 22:41

:? The one on D6 started working after setting debounce from 100 to 0ms
The other did not until moving from D5 to D2 (and also debounce to 0ms)

:? :? :?

TD-er
Core team member
Posts: 6175
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: S0 Electricity meter on pulse counter does not work

#9 Post by TD-er » 09 May 2022, 13:59

OK, debounce change I can understand as the S0 pulse may be shorter than 100 msec.
No idea why that other change was needed.
See: https://espeasy.readthedocs.io/en/lates ... on-esp8266
D2 (GPIO-4) is often used for I2C, so maybe there is some pull-up resistor present which makes the difference?
Or maybe that pin on D5 (GPIO-14) got damaged in earlier tests?

_Cyber_
Normal user
Posts: 99
Joined: 20 Oct 2019, 09:46

Re: S0 Electricity meter on pulse counter does not work

#10 Post by _Cyber_ » 10 May 2022, 06:40

the "working" measurement were wrong one, so pulses seemed not related to the pulses of the S0 counter.

In the meanwhile I have tried to add a 10k between GND and the GPIO to pull the GPIO to low until a pulse triggers. so far it has not counted any more anything, so in a complete, but static not-working state again :(

TD-er
Core team member
Posts: 6175
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: S0 Electricity meter on pulse counter does not work

#11 Post by TD-er » 10 May 2022, 09:32

I re-read your start post, and you mention you have 3V3 connected to the S0. (this is too low)
Can you draw how it is now connected?
See also here for some basic schematics on how to connect the S0 bus: https://sbc-support.com/uploads/tx_srcp ... 1.1_01.pdf

_Cyber_
Normal user
Posts: 99
Joined: 20 Oct 2019, 09:46

Re: S0 Electricity meter on pulse counter does not work

#12 Post by _Cyber_ » 10 May 2022, 11:20

thanks for your time and help!

currently it looks like this:
Circuit.png
Circuit.png (48.7 KiB) Viewed 474 times
Counting the pulses on D7 (GPIO-13) of the EX-26A works.

There are two S0 counters, red and orange. both do not work.
in the green rectangles I measured the voltage divider, so manually closing the "S0" switch and putting +12V and GND as in the schema lets me measure 2.95V between the line which goes to the D5 / D6 pin and GND.
the orange marked 10k resistors I put in to assure to have LOW on D5 / D6. my understanding is that if the 2.95V arrive the pin will get HIGH, if not the resistor puts it to LOW.
without both of the orange marked resistors one of the two S0 counters liked to recognize pulses (never both at the same time!), but they were not correct and also only with debounce time set to 0. with debounce time set to 100 both did never show up something.
this looks also reproducable with manually closing. so currently only D6 "works" if I close manually the two pins (s0+ and S0-). yesterday where I had D5 wired to D4, only D4 did work on manually closing.

in general I do not solder on the device itself, I made a small connector hat where I plug on the cables. the voltage divider are "in the cable", the 10k resistors which are attached between GND and 3.3V or the pin, are on the legs of the downside. so there is no "soldermess". the thicker black is the EX-26A, the 2-pole-connectors are 12V and the 3-pole-connector is D5, D6, D7. a 0.75mm² cable is used to the S0 counters, one time about 1m long, the other about 2m. only the last 15cm where I added the voltage-divider is the thin one.
cables.png
cables.png (327.08 KiB) Viewed 474 times
espeasy devices config:
devices.png
devices.png (33.1 KiB) Viewed 474 times
pulse counter device parameter (tried all mode type, I would expect to need Pulse HIGH - this works on manually closing most relieable):
device-parameters.png
device-parameters.png (29.1 KiB) Viewed 474 times

TD-er
Core team member
Posts: 6175
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: S0 Electricity meter on pulse counter does not work

#13 Post by TD-er » 10 May 2022, 13:16

The extra 10k resistors (orange in your schematic) are not useful and I think they may be the source of your problem. Or at least "may cause issues".

They are parallel to the 3k3 resistor, effectively lowering the resistance of those 3k3 resistors.
The effective resistance is then 2k5 Ohm, thus lowering the voltage over the GPIO pin.
The optocoupler in the S0 may also have some diode in series and thus cause a voltage drop of roughly 1.5V.
This means the voltage over the 10k + 2k5 is not 12V but more like 10.5V.
This makes the voltage over the GPIO pin about 2.1V which may be too low to see a high level.
Even with the orange 10k resistors removed you may only get about 2.6V
If you change those 3k3 resistors to 4k7 you may have about 3.3V

But first try to remove the orange 10k resistors.

_Cyber_
Normal user
Posts: 99
Joined: 20 Oct 2019, 09:46

Re: S0 Electricity meter on pulse counter does not work

#14 Post by _Cyber_ » 11 May 2022, 15:33

thank you for your recommendations.

removed the orange 10k resistors (had already tests done without them) and changed the two 3.3k to 4.7k one.

additionally, as D5 and D6 did not work relieable, changed to D1 and D2.

now I can see it working with about 10% loss of the pulses, on both counters.
do you have suggestions to this too? :-)
Mode Type is to Pulse High and Debounce Time to 2ms

TD-er
Core team member
Posts: 6175
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: S0 Electricity meter on pulse counter does not work

#15 Post by TD-er » 11 May 2022, 19:32

S0 pulse width is minimal 30 msec, so 2 msec debounce should work.
If you're still seeing too many pulses, you may increase it upto roughly 50% of this minimal 30 msec.

There is one thing I don't know for sure and that's what will happen with pulses that happen on both pins at the same time.
For example, what will happen if both pulses are (partially) overlapping? I guess the first one (or the one with lowest task nr) may be counted where the other one may be missing.

_Cyber_
Normal user
Posts: 99
Joined: 20 Oct 2019, 09:46

Re: S0 Electricity meter on pulse counter does not work

#16 Post by _Cyber_ » 12 May 2022, 12:11

having on D1 and D2 on the same time a pulse is very unlikely - there are pulserates of about 30seconds to 3 Minutes on both - so the possibility to fetch the 30ms at the same time is very unlikely.

one of the counters stopped working over night.
after setting it to mode "Change" it works again, I can see now also 2 pulses with 85ms in between.
and I have no idea why it worked before with mode HIGH and stopped working without doing anything.

the other counter still works, although still counts about 10% less

_Cyber_
Normal user
Posts: 99
Joined: 20 Oct 2019, 09:46

Re: S0 Electricity meter on pulse counter does not work

#17 Post by _Cyber_ » 13 May 2022, 09:58

During last night there were no pulses lost with "change" mode and 100ms debounce time. ;) :) :D

TD-er
Core team member
Posts: 6175
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: S0 Electricity meter on pulse counter does not work

#18 Post by TD-er » 13 May 2022, 10:03

Great!
No idea what those 'lost pulses' may be like, but if they are anythink like lost Lego bricks you will only find when stepping on them, then it is best not to loose those pulses :)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest