Sign inSign up

ualex73/s0pcm-reader

By ualex73

Updated over 3 years ago

S0PCM-Reader to read from a S0PCM-5/S0PCM-2 and send the total and daily counters via MQTT.

Image
0

10K+

ualex73/s0pcm-reader repository overview

S0PCM-Reader

This is the Docker setup for the S0PCM-Reader application. This small Python application reads the pulse counters of a S0PCM-2 or S0PCM-5 and send the total and daily counters via MQTT to your favorite domotica application like Home Assistant. The S0PCM-2 or 5 are the S0 Pulse Counter Module sold by http://www.smartmeterdashboard.nl

I myself use it to count my water meter usage.

The Docker image is available for the following architectures:

  • amd64 - For regulair Intel/AMD systems (default)
  • arm32v6 - For Raspberry Pi 1/2
  • arm64v8 - For Raspberry Pi 3 and up

Pulse vs liter vs m3

I use the S0PCM-Reader to measure my water meter and normally in the Netherlands the water usage is measurement in m3 and not in liters. Only this S0PCM-Reader isn't really aware of liters vs m3, because it counts the pulses. So it is important for you to check how your e.g. water meter is counting the usage, my Itron water meter send 1 pulse per liter of water. This then means the 'measurement.yaml' file, which stores the total and daily counters, all should be in liters and not in m3.

The conversion from m3 to liter is easy, because you can just multiple it by 1000. E.g. 770,123 m3 is 770123 liter.

alt text

Configuration / Measurement File

The configuration and measurement file options are described on the GitHub repository: https://github.com/ualex73/docker-s0pcm-reader

Configure your initial meter reader

After you have downloaded and started the S0PCM-Reader, you need to configure your total pulse count to allow the S0PCM-Reader to relay the correct total count. Follow the following procedure:

  • Stop the S0PCM-Reader container
  • Open the <config>/measurement.yaml file
  • Check which input you use, e.g. for input 'M1' modify the following:
1:
    total: 370689

The 370689 is liters, which is 370m3

  • Save the file
  • Start the S0PCM-Reader container

MQTT Message

The totals and day counters will be published with the following topics:

<basetopic>/1/today
<basetopic>/1/yesterday
<basetopic>/2/total
<basetopic>/2/today
<basetopic>/2/yesterday
<basetopic>/X/total
<basetopic>/X/today
<basetopic>/X/yesterday

The <basetopic> you can configure in the mqtt section of the configuration file, the default is 's0pcm-reader'. The X is the input number, the name is configurable in the measurement file.

Volumes

/config - The location where the configuration, measurements and logging are stored.

Run

Launch the S0PCM-Reader docker container with the following command:

docker run [-d] \
    --name=s0pcm \
    -v /etc/localtime:/etc/localtime:ro \
    -v /docker/config:/config \
    --device /dev/ttyACM0:/dev/ttyACM0 \
    ualex73/s0pcm-reader:latest

Docker-compose.yaml Example

version: '3'

services:

  s0pcm:
    container_name: s0pcm
    image: ualex73/s0pcm-reader:latest
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /docker/s0pcm:/config
      - /dev:/dev
    devices:
      - /dev/serial/by-id/usb-Arduino_LLC_Arduino_Leonardo-if00:/dev/serial/by-id/usb-Arduino_LLC_Arduino_Leonardo-if00

Tag summary

Content type

Image

Digest

sha256:4ecc48961

Size

27.6 MB

Last updated

over 3 years ago

docker pull ualex73/s0pcm-reader