matizzy
Posts: 3
Joined: Mon Mar 31, 2014 1:28 pm

S0 Pulse counter

Mon Mar 31, 2014 1:38 pm

I have a kWh meter that has an S0 pulse output. For the past week I have tried to get the raspberry pi to count the pulses but I am unsuccessful. There isn't much documentation since I got the meter from China.

The limited documentation that it does have says that the output has 3200 impulses per kWh and the pulse length is at least 30ms long. The one part of the documentation that I don't understand is that it just has a line that says 18-27V at 27mA. I'm not sure if this means that I need to put in 18-27V, or, if the output is 18V-27V, or, if it can work at a max of 18-127V.
+
I've tried to connect it in many ways and it doesn't work. I attached one of the GPIO pins with an internal pull-up to the + pin of the meter and I connected the - min of the meter to the ground of the raspberry pi. In terms of software I have a loop that waits for a falling edge and increments a counter by 1 every time it sees the edge and prints the count number.

However nothing works, can anyone provide and tips?

User avatar
Burngate
Posts: 5438
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK
Contact: Website

Re: S0 Pulse counter

Mon Mar 31, 2014 4:41 pm

I wouldn't have connected my Pi to anything without a lot more infomation about what's coming out of it, but since you have, and (I assume) not broken anything, ...

The "line that says 18-27V at 27mA" is fairly meaningless.
It could mean "nothing will happen if you give it less than 18V, and it'll break if you give it more than 27V"
Or maybe "It gives out between 18V and 27V. Don't take more than 27mA or you'll break it"

So measure the pins with your multimeter. If there's no voltage, try Ohms.
Try a 2k resistor and a LED across the pins. Then try connecting a couple of 9v batteries in series (reversing the LED)

Or better, try taking it apart to find out what's feeding those pins

PiGraham
Posts: 3401
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: S0 Pulse counter

Mon Mar 31, 2014 5:41 pm

matizzy wrote:I've tried to connect it in many ways and it doesn't work. I attached one of the GPIO pins with an internal pull-up to the + pin of the meter and I connected the - min of the meter to the ground of the raspberry pi. In terms of software I have a loop that waits for a falling edge and increments a counter by 1 every time it sees the edge and prints the count number.
If your lucky the legend means that the meter output tolerates an external voltage of 18 - 27V (nominal 24V?) and will sink up to 27mA. Nothing happens because you aren't supplying a suitable voltage.

If you are unlucky the meter outputs a poorly regulated ~24V which you have connected to a 3.3V input and destroyed a GPIO input.

Step one is to test your GPIO input, With it configured as input ground the GPIO pin and check that your code, or command line GPIO read detects the changing state.

Check your code does basic pulse counting stand-alone.

If you connect two 9V batteries in series you get 18V. Wire that in series with an 1k ohm resistor and an LED.
Batt+ --> resistor --> LED Anode | LED Cathode --> Meter+ | Meter - --> Batt-

The resistor limits the short cicuit current to 18/1000 = 18 mA, which is within the meter rating.
Hopefully the meter will be low impedance when pulsing and current will flow in the LED lighting it up.
Voltage across the (red) LED will be ~2V and current will be ! 16/1000 = 16mA

Do not connect this circuit to your Pi!

If that works you will need to convert from 18V to 3.3V. Buy an opto-isolator and connect its LED terminals in place of, or series with, the LED in the circuit described above.

Now you should have a stransistor output in the Opto-isolator that you can conect to a GPIO input. Collector pin to GPIO, emitter pin to Pi 0V.

You don't need any electrical connections between the meter and the Pi.

If you can now count pulses from the meter you will need to sort out a permanent power supply. You may find it easier to find 24V supplies. 24 - 2V(LED) - 2V(opto-isolator) = 20V
20V/1000 = 20mA

An opto-isolator something like this should do.

matizzy
Posts: 3
Joined: Mon Mar 31, 2014 1:28 pm

Re: S0 Pulse counter

Mon Mar 31, 2014 8:30 pm

I'll try your suggestions. The reason I thought I didn't need any additional equipment is because this guy bought the same meter and connected it to the raspberry pi like so: http://www.ramge.de/powermonitor/doku.p ... ulse_meter

The only difference in our meters is that his is a 3-wire meter meant for 230v while mine is a 2 wire meant for 120v. I tried wiring mine in the same way to his, but nothing worked. I'm thinking that it is most likely a software issue.

PiGraham
Posts: 3401
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: S0 Pulse counter

Tue Apr 01, 2014 7:50 am

I helps to have full information. Why didn't you include that link in your original post?
Data on that module here http://www.digitale-elektronik.de/shops ... cts_id=220
Pulse output S0, passive opto-isolated, max. 27V / max. 27mA, switchable at max. power 100mW
That tells us what we need to know.

So, I suggest you test the SO pulse output using a multimeter, continuity tester or LED+resistor+battery.
Test your GPIO input with the 200 ohm resistor to GND. If both work independently then connect them together.

matizzy
Posts: 3
Joined: Mon Mar 31, 2014 1:28 pm

Re: S0 Pulse counter

Tue Apr 01, 2014 4:54 pm

Sorry, for not including that link in my original post.

So basically, the configuration that the post had should be safe for the raspberry pi?

Should I use the internal pull-up/pull-down resistors?

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: S0 Pulse counter

Wed Apr 02, 2014 3:11 pm

Hi matizzy,

Do you have a link to the datasheet for the pulse meter that you are using?
The reason that I ask is that different energy meters operate in different fashions, if your meter is a two wire one then it will probably need a different set of connections from the three wire pulse meter in the link you gave.

First step is to get the meter wired up correctly and setup to give the correct pulses.

Then we can setup the Pi to monitor the pulses.
Doug.
Building Management Systems Engineer.

edsub
Posts: 1
Joined: Tue Dec 12, 2017 9:24 pm

Re: S0 Pulse counter

Tue Dec 12, 2017 9:32 pm

Although this is a fairly old thread, but www.smartmeterdashboard.nl sells S0 pulse counter modules (site is in Dutch but via Google translate you will get the info)
They are mentioned by Domoticz that runs on a RPi.

andrethomas
Posts: 1
Joined: Thu Apr 26, 2018 7:47 pm

Re: S0 Pulse counter

Thu Apr 26, 2018 8:02 pm

I know this is an old post, but I found a simple solution to connect a Pi to the SO output

The output side of the SO is quite simple to use and is not to be confused with the optical side of the device (the LED inside the optoisolator)

Configure IO pin on PI to use internal pull-up (so that the pi will pull it high to 3.3V)

This pin can be connected to the + on the SO whilst connecting the other pin of the SO to any of the GND pins on the PI.

What will happen in this scenario is that when the optoisolator (High voltage side of the optical isolator (or LED internally for lack of a better term) turns on it will cause the resistance on the SO side to drop out causing the pin on the PI input pin mentioned above to be pulled down to GND.

The power meter I am using gives 1600 impulses per KWh used so its basically counting the number of pulses received in a given period, multiplying that to match a timeline of one hour and then dividing it into 1600 to get the KWh currently going through the meter.

Lets say I count 10 impulses in a 10 second period, that would translate to 10*6*60 impulses per hour if extrapolated which would mean 10*6*60 = 3600 impulses projected per hour... 3600/1600 = 2.25KWh

From this one can do other math for example lets say I have 220V AC and I want the current (Amperage)

Amps = 2250Watts/220V = 10.23A

Return to “Advanced users”

Who is online

Users browsing this forum: Burngate and 14 guests