Wemos D1 mini and IWM-PL3 water flow meter

Hi to all.

Already lost couple of hours trying to connect IWM-PL3 water flow meter.

Manual to sensor: https://www.aqua-filt.hu/wp-content/uploads/Csatlakozasi_diagramm_PL3-PL4-Output-Connection_v1.2.pdf

connected as below:

Wemos GND to sensor “brown” wire
Wemos D6 (GPIO12) to sensor “white” wire

esphome:
  name: esp8266-wemos-d1-wolny
  friendly_name: ESP8266 Wemos D1 wolny

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: <removed>

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp8266-Wemos-D1-Wolny"
    password: !secret ap_password

web_server:
  port: 80
  version: 3

captive_portal:

sensor:

  - platform: pulse_meter
    name: "Przepływ"
    pin:
      inverted: False
      number: GPIO12
      mode: 
        input: true
        pullup: True
    internal_filter_mode: PULSE
    unit_of_measurement: "l/min."
    accuracy_decimals: 0
    icon: "mdi:waves-arrow-right"
    timeout: 5s

I can not get it running. What do I do wrong ?

You linked a “manual” to sensor. Doesn’t it describe it the other way around…?

So… You knew to find the manual/documentation, yet you’ve been failing to set this sensor up for hours?

The first issue that jumps out in front of me is you’ve chosen to make guesses and waste hours of time instead of just reading the dang documentation that explains how to set it up and use this sensor…

It took me a whopping 5min to find a color coded wiring diagram for your sensor while using Google and in this documentation you linked to, they include a wiring guide/instructions too.

Why are you hooking up wires based solely on guessing and why would you rather waste hours of time trying to fry the sensor instead of just taking 10min to read and look through the documentation that YOU provided for us to read!

You’re not even close to being correct in your wiring nightmare job and it’s hard to even say if you havn’t already done permenant damage to it and if it will even work once it’s wired correctly. Go through and read the documentation and post an updated wiring photo after you find it and then i’ll try to help you. I’m happy to help those who only try and make an effort and I han’t seen that yet here.

Hi

Just noticed your photo of your wiring differs from what you have wrote, photo however looks correct with brown being GND. I have a different sensor on my water meter but it uses the same principle to short the input to GND. The main difference I have on mine is I have set inverted to True, worth a try.

You could also temporarily connect it to a pin configured as a binary sensor see if it goes on/off as water flows.

1 Like

Good catch, I didn’t notice the image didn’t match his description and at least the 2 wires you can actrually trace, those look correct. The manual states that the output voltage will match whatever the voltage is at the sensor and I havn’t heard if that was checked and a logic voltage was verified or not. I’m not 100% sure if he has a common ground between all the components either.

This is why I stressed OP read the user manual they posted a link for. The documentation states it can’ operate using either logic low(NPN) or logic high(PNP) output and which one depends on how OP wires the sensor inputs because the input side is the same way and either one can be used. Instead of trying it and seeing, a volt meter is what needs tried out here, not so much guesses but, using internal pull-ups would strongly suggest OP was trying to set it up for Logic LOW and forgot or didn’t know they need to make that a

inverted: true

Do you recall what the default voltage your meter used when setting yours up? I’m not sure if there is an industry standard voltage, a common voltage , or if they are all over the map and differ from vendor to vendor, IDK.

Slightly different sensor on my meter, mine is an Itron Cyble sensor which from memory like the OP’s stated up to 30v, rather bizarrely and I’m not sure how this works but mine is supposedly not polarity dependent, I think it has an internal 10 year lithium battery. I was more interested in counting total pulses but did use pulse meter, for completeness my code is below.

esphome:
  name: water-meter
  friendly_name: water-meter
  on_boot:
    then:
      - pulse_meter.set_total_pulses:
          id: water_meter_counter
          value: !lambda "return id(total_pulses);"
  on_shutdown:
    then:
      - globals.set:
          id: total_pulses
          value: !lambda 'return id(water_full_total).state * 1000;'

substitutions:
  # The initial meter reading when the sensor is installed, this is used to make the total reading corelate with the actual meter
  # Note value is in litres so 2470000 corresponds to 2470.000 m³
  initial_meter_reading: '2490695'
  
globals:
  # Global variable to store pulse count so it persists across re-boots
  - id: total_pulses
    type: int
    restore_value: yes
    initial_value: ${initial_meter_reading} # If a new ESP is put in and no stored value in flash this should be used.

esp8266:
  board: esp01_1m
  restore_from_flash: true

preferences:
  # Change flash write interval from defaul 60s to 10mins to reduce flash wear
  flash_write_interval: 10min

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "secret"
  
ota:
  - platform: esphome
    password: "secret"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

sensor:
  # Pulse meter used to count meter pulses
  - platform: pulse_meter
    pin:
      number: GPIO14 # D5
      mode: INPUT_PULLUP
      inverted: True
    internal_filter_mode: PULSE
    internal_filter: 10ms
    timeout: 1 min
    name: "Water Meter Flow"
    id: water_meter_counter
    unit_of_measurement: "l/min"
    icon: "mdi:water"
    # Total pulses, note this is the absolute and should match the actual on the meter
    total:
      name: "Water Meter Total"
      id: water_full_total
      unit_of_measurement: "m³"
      accuracy_decimals: 3
      device_class: water
      state_class: total_increasing
      filters:
        # Divide by 1000 to get m3
        - multiply: 0.001
      on_value:
        then:
          - globals.set:
              # Multiply by 1000 to get back to litres
              # Then store in global variable
              id: total_pulses
              value: !lambda "return (int)(x*1000);"
          - number.set: 
              id: NewTotalUpdate
              value: !lambda "return (int)(x*1000);"
  
  # Creates a copy of the total to get (current - day 1 install) to get actual since installation
  # Added so as not to get a big spike of usage day 1 install
  - platform: copy
    source_id: water_full_total
    name: "Accumulated Total"
    filters:
      # Need to get back to litres, subtract day 1 and then convert back to m³
      - multiply: 1000
      - offset: -${initial_meter_reading}
      - multiply: 0.001
          
  - platform: uptime
    name: Uptime Sensor
    id: uptime_seconds

  - platform: wifi_signal
    id: wifi_signal_db
    name: "WiFi Signal Sensor"
    update_interval: 60s
    entity_category: "diagnostic"
  

number:
# Number field used for resetting total
  - platform: template
    name: "Total Update"
    id: NewTotalUpdate
    optimistic: true
    min_value: ${initial_meter_reading}
    max_value: 10000000
    unit_of_measurement: litres
    device_class: water
    icon: mdi:water-sync
    step: 1


    
text_sensor:
#  Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds
  - platform: template
    name: "Device Uptime"
    entity_category: diagnostic
    lambda: |-
      int seconds = (id(uptime_seconds).state);
      int days = seconds / (24 * 3600);
      seconds = seconds % (24 * 3600);
      int hours = seconds / 3600;
      seconds = seconds % 3600;
      int minutes = seconds /  60;
      seconds = seconds % 60;
      if ( days > 3650 ) {
        return { "Starting up" };
      } else if ( days ) {
        return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
      } else if ( hours ) {
        return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
      } else if ( minutes ) {
        return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
      } else {
        return { (String(seconds) +"s").c_str() };
      }
    icon: mdi:clock-start

button:
  - platform: restart
    name: "Restart"

# Reset total button
  - platform: template
    name: "Update Total"
    on_press: 
      then:
        - if:
            condition:
              # Checks for a value greater than initial reading on setup for limited error checking
              # Could be expanded to allow just a percentage change of current if desired
              lambda: 'return id(NewTotalUpdate).state >= ${initial_meter_reading};'
            then:
              - pulse_meter.set_total_pulses:
                  id: water_meter_counter
                  value: !lambda 'return id(NewTotalUpdate).state;' 

Note still a bit in development not convinced it counts accurately yet.

initial text corrected - good point - thx EBME2:slight_smile:

Will give a try this afternoon, thank you for your code !

The maximum voltage is only provided as a reference. The sensor can take up to 30V/100mA to the ground potential provided on its output without causing damage to it.

It will short this output to the provided ground on a pulse.

The internal pull up resistors are around 45kOhm I think, so that would be 3,3V/45.000Ohm = 0,08mA which is safe for the ESP board and the sensor alike.

That is why you have to set the ESP output to pullup and count the zero transitions.

LOL, that was harsh but i laughed.

1 Like