Watermeter pulse sensor S0PCM

try /dev/ttyACM0 (if no other usb-ports are used) or /dev/ttyACM1 (if one usb-port was in use before plugging sensor in)

Min is actualy /dev/serial/by-id/usb-Arduino_LLC_Arduino_Leonardo-if00

Hi I have 4 inputs:

  • 1 Solar panel
  • 2 Kwh meters for Electric car and Jacuzzi
  • 1 water meter

I like to see the (near)realtime usage.

As far as I know the S0pcm module sends the pulses per channel every 10 seconds, so it must be possible to know the current usage or production.

Unfortunately I’m not a python expert, so if anyone could help me with a script which puts the number of pulses per 10 seconds interval in a HA entity it can easily be used to do what I want.

Thank you…

Is there anyone who van give a little push in the richt direction?

Interested in this as well. I have 3 DDS353 kwh meters in my fuse box, 1 for each circuit. Would like to be able to read them with an S0PCM like this and send that data to HA via MQTT using ualex73/docker-s0pcm-reader: S0PCM-Reader (github.com)

Is it worth getting this module and going this route?

I think this project might be a better choice to get our S0 pulses into HA. No expensive cables needed, just an ESP, some wire and a resistor per channel. It looks like it’s about to get merged in ESPHome.

How to count pulse frequency accurately with ESPHome? - Third party integrations / ESPHome - Home Assistant Community (home-assistant.io)

Hi,

I just migrated from Domoticz to Home Assistant (hassio) on Rasparian Pi 4.
Configured most of my hardware and created some Node Red flows.

The on thing i cant figure out is how to get my S0 meter working with Home Assistant. In Domoticz it was 2 clicks and ready. I have read a lot in the forums etc.

Jorei/homeassistant.sensor.cyble

is offline or doesnt exist anymore. I run HASSIO os on Rasparian Pi 4

What steps should i take? I have the 5 port version S0 meter.

If someone could provide me with some info, this would be great!

Thanks and greetings Alex

Hi,

I also migrated from Domoticz and indeed it is a few clicks and S0 works. (3 kWh meters on 5 port usb converter)
By setting up mysensor I get the data in HA but I need some help how to display this in HA.
Alex hope this helps you a bit in the right direction and you or somebody else can help me out in displaying the data.

See below my data
2021-08-29 08:27:30 DEBUG (MainThread) [mysensors.transport] Receiving ID:3781:I:10:M1:0:1427404:M2:0:0:M3:0:48999:M4:0:0:M5:0:772039

2021-08-29 08:27:30 WARNING (MainThread) [mysensors.message] Error decoding message from gateway, bad data received: ID:3781:I:10:M1:0:1427404:M2:0:0:M3:0:48999:M4:0:0:M5:0:772039

2021-08-29 08:27:30 WARNING (MainThread) [mysensors] Not a valid message: not enough values to unpack (expected 5, got 0)

Thanks,
Ronald

Hi Ronald,

I tried several things, but none have a working S0 meter for me. I cannot install a custom docker on HASS.io How do you setup mysensor so the devices occur? Thanks in advaced. Can you add the code? or Config? Have you gotten any further?

Greetings Alex

Can I use this with the Cyble Itron as well?

Ah, I see how it works, I plug the Cyble Itron into that pulse counter. Too bad they don’t sell it at that shop anymore. I ordered one of these instead, I assume it does the same thing.

Hi warrior,

Are you willing to share that code?
The link to the cyble github page seems to be offline.
Thanks!

@meijron @Jorei and everyone else :crazy_face:

I have tried to get the github docker active by using the wget command in the terminal.
But after that I see that I succeeded, but no new folder in file editor of HA so I wouldn’t know how to take my next steps?

-Or do I have to download and upload the configuration example myself?
-Do I have to add text “plaform” somewhere in the main configuration file afterwards?

Did the following but do not get any further in home assistant, or should I not have done it via wget?

Initial Configuration To use the S0PCM-Reader you need to configure it, this can be done in 2 ways: * Start the S0PCM-Reader and the default configuration will be copied into the /config folder * Download the example configuration.yaml with the following command (we use wget for this) into your /config folder:

Seems so: I configured it as such (for measure of car charger):

- platform: serial
  name: "pulse_counter"
  serial_port: /dev/ttyACM0
  baudrate: 9600
  parity: E
  bytesize: 7
  stopbits: 1

sensor:
  - name: "laadpaal_current"
    unit_of_measurement: "kW"
    state: "{{ 3600 / ( ( 10 / (states('sensor.pulse_counter').split(':')[5] | float / 3 )) * 1000 ) }}" # 3600 / (sec per flash * imp/kWh)
  - name: "laadpaal_total"
    unit_of_measurement: "kWh"
    state: "{{ states('sensor.pulse_counter').split(':')[6] | float /3 * 0.001 + ( states('input_number.start_balance_laadpaal') | float ) | round(3)> 
  - name: "laadpaal_total_pulses"
    state: "{{ states('sensor.pulse_counter').split(':')[6] | float / 3 }}"

It currently reads too much so I divide by 3… I have it on a separate usb powered hub. Still tweaking with positioning and cable length. I added an input_helper as starting kWh balance.

I do not know if it is still relevant, but I made my S0PCM-5 module working in HA 2022.6

For readability I’ve split up my configuration files.

In configuration.yaml:

 sensor: !include_dir_merge_list sensors/

In config/sensors/s0pcm5.yaml:>

- platform: serial
  name: s0pcm5
  serial_port: /dev/serial/by-id/usb-Arduino_LLC_Arduino_Leonardo-if00
  baudrate: 9600
  parity: E
  bytesize: 7
  stopbits: 1

- platform: template
  sensors:
    s0pcm5_m1:
      unique_id: s0pcm5_m1
      friendly_name: Office usage
      unit_of_measurement: "kWh"
      value_template: "{{ (states('input_number.m1_offset')| float  + states('sensor.s0pcm5').split(':')[6] | float / 1000 ) | round(2) }}"

The first block is to make the information available in HA. I used the ‘by-id’ name of the serial port, because the enumeration can change if you have more USB/Serial devices connected. I need to think of a solution if more than one Leonardo is connected, but that is something I will address when it happens :slight_smile:

The second block is repeated four times (for m2-m5), because I have a S0PCM-5.
The unique-id gives access to this sensor through the GUI
The uom makes the values available for graphing (I use grafana/influx)
The index [6] is for the M1 value (see a previous post in this thread).
The other indices are [9], [12], ]15] and [18]
I divide the value by 1000 because I want kWh (the counter counts Wh)
I use a helper to get an offset (for syncing the counter in HA with the device)
I round on 2 digits to get the same values as the counter on my devices (youless) shows (provided you have put the right offset value in the corresponding helper)

I do not yet know when the counters will reset (the used counter counts since last startup)

This config gives me 5 sensors with the exact same values as shown on the devices itself.
Next step is to use the utility platform, but I haven’t looked into that, yet.

Hope this helps some people!

Regards,
Marcel

3 Likes

Hi WiWo, thanks for the write up, it got me along my way to get the S0PCM-5 working.

one question, where does the 'input_number.m1_offset' value come from?

It is just a helper (five of them, in fact).

Go to Settings => Devices & Services, and choose the tab ‘Helpers’
Then ‘Create Helper’ and choose a ‘Number’ helper.

I named mine ‘m1_offset’. Once created, you can change the name, but then only the friendly name will change. The sensor will still be ‘input_number.m1_offset’

This input is available on the default dashboard, and can also be added to your own dashboards. Just enter the value there.

FYI: I weekly check my counters in HA with those on the device itself, and they are still in sync.

I am also planning to use one channel for Water Measurement, which is in m3. But the rotator on the meter is one revolution per liter, so I also need a correction here.

Alas, Today I checked again, and apparently I missed quite a few pulses. Going to investigate…

Hi Marcel,

How is your S0PCM implementation in HA holding up? I’m in the process of switching from Domoticz to HA but this S0PCM is holding me down. I use 4 of the 5 channels (Water, 2x PV, EV-charger).

Is the topicstarter in am using the S0pcm over some time without any issues. I am using the docker which is working completely stable.

But;
My readings are most of the times way to high. In a normal day using 500-1000 liter of water, it does not seems to be correct. How does this compare to you guys ? And how do I change it?

Sorry I missed your question. I am using the S0PCM5 for almost a year now. I do miss pulses now and then, so I made a habit of checking the readings on a regular basis. Sometimes the values are in sync for weeks, and suddenly I miss (quite) a few kWh…

Therefore I made a dashboard to correct the meter values easily from my phone. I used the HACS frontend card ‘Numberbox card’, where you can increase (and decrease) a value by pressing a button. The step-size I have put in a helper, because sometimes you want to correct with 0.1, and sometimes with 0.01

I tried the standard input method, but the keypad covers all readings on the phone screen, making the adjustment a big fuzz. With this card you can do it with one hand (in the other i have a flashlight to be able to read the meter values)

If you are interested. let me know and I’ll share all the info

Marcel

PS. Still haven’t water readings added. I need to 3D-print a sensor mount for the water meter, as the induction sensor doesn’t work with my water meter. I’m reverting to a LED/sensor to detect the passing of the mirror. But I have so many other things to do, too…