Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Watermeter Elster V200 PR6P:1

Watermeter Elster V200 PR6P:1

Scheduled Pinned Locked Moved My Project
16 Posts 4 Posters 6.5k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • the cosmic gateT the cosmic gate

    @Yveaux

    I will make a movie to show you the meter / pulse detection (led blinks) etc.
    So you can see that there are luckily more pulses to measure

    YveauxY Offline
    YveauxY Offline
    Yveaux
    Mod
    wrote on last edited by
    #6

    @the-cosmic-gate ok, don't worry, I'll believe you :smirk:
    Probably the meter itself generates more pulse during rotation then.

    http://yveaux.blogspot.nl

    the cosmic gateT 1 Reply Last reply
    0
    • YveauxY Yveaux

      @the-cosmic-gate ok, don't worry, I'll believe you :smirk:
      Probably the meter itself generates more pulse during rotation then.

      the cosmic gateT Offline
      the cosmic gateT Offline
      the cosmic gate
      wrote on last edited by
      #7

      @Yveaux said:

      @the-cosmic-gate ok, don't worry, I'll believe you :smirk:
      Probably the meter itself generates more pulse during rotation then.

      I think so , but with this movie "we" can think about the pulse per L

      There's more than meets the eye

      YveauxY 1 Reply Last reply
      0
      • the cosmic gateT the cosmic gate

        @Yveaux said:

        @the-cosmic-gate ok, don't worry, I'll believe you :smirk:
        Probably the meter itself generates more pulse during rotation then.

        I think so , but with this movie "we" can think about the pulse per L

        YveauxY Offline
        YveauxY Offline
        Yveaux
        Mod
        wrote on last edited by
        #8

        @the-cosmic-gate simply fill a 10 liter bucket and count the pulses. It will give you a rough indication of the pulses per liter.
        Or install your sensor and set pulses per liter initially to 1. Note the starting value of the meter. Then let it count for a few days and note the value again. The number of pulses divided by the increase in liters is the pulses/liter ratio (you probably have to round it to a power of 10)

        http://yveaux.blogspot.nl

        1 Reply Last reply
        0
        • the cosmic gateT Offline
          the cosmic gateT Offline
          the cosmic gate
          wrote on last edited by the cosmic gate
          #9

          @Yveaux
          Seems to be easy 1 pulse every L

          YouTube video

          There's more than meets the eye

          1 Reply Last reply
          0
          • the cosmic gateT Offline
            the cosmic gateT Offline
            the cosmic gate
            wrote on last edited by the cosmic gate
            #10

            So the pulse rule must be

            double ppl = ((double)PULSE_FACTOR)/1
            

            ?

            There's more than meets the eye

            the cosmic gateT 1 Reply Last reply
            0
            • the cosmic gateT the cosmic gate

              So the pulse rule must be

              double ppl = ((double)PULSE_FACTOR)/1
              

              ?

              the cosmic gateT Offline
              the cosmic gateT Offline
              the cosmic gate
              wrote on last edited by
              #11

              @the-cosmic-gate said:

              So the pulse rule must be

              double ppl = ((double)PULSE_FACTOR)/1
              

              ?

              Is this correct when I change this rule as above?

              There's more than meets the eye

              YveauxY 1 Reply Last reply
              0
              • the cosmic gateT the cosmic gate

                @the-cosmic-gate said:

                So the pulse rule must be

                double ppl = ((double)PULSE_FACTOR)/1
                

                ?

                Is this correct when I change this rule as above?

                YveauxY Offline
                YveauxY Offline
                Yveaux
                Mod
                wrote on last edited by
                #12

                @the-cosmic-gate I don't know the sketch, so I don't know.
                Why not just try it?

                http://yveaux.blogspot.nl

                the cosmic gateT 1 Reply Last reply
                0
                • YveauxY Yveaux

                  @the-cosmic-gate I don't know the sketch, so I don't know.
                  Why not just try it?

                  the cosmic gateT Offline
                  the cosmic gateT Offline
                  the cosmic gate
                  wrote on last edited by
                  #13

                  @Yveaux said:

                  @the-cosmic-gate I don't know the sketch, so I don't know.
                  Why not just try it?

                  The sketch would be then:

                  /**
                   * The MySensors Arduino library handles the wireless radio link and protocol
                   * between your home built sensors/actuators and HA controller of choice.
                   * The sensors forms a self healing radio network with optional repeaters. Each
                   * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                   * network topology allowing messages to be routed to nodes.
                   *
                   * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                   * Copyright (C) 2013-2015 Sensnology AB
                   * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                   *
                   * Documentation: http://www.mysensors.org
                   * Support Forum: http://forum.mysensors.org
                   *
                   * This program is free software; you can redistribute it and/or
                   * modify it under the terms of the GNU General Public License
                   * version 2 as published by the Free Software Foundation.
                   *
                   *******************************
                   *
                   * REVISION HISTORY
                   * Version 1.0 - Henrik Ekblad
                   * 
                   * DESCRIPTION
                   * Use this sensor to measure volume and flow of your house watermeter.
                   * You need to set the correct pulsefactor of your meter (pulses per m3).
                   * The sensor starts by fetching current volume reading from gateway (VAR 1).
                   * Reports both volume and flow back to gateway.
                   *
                   * Unfortunately millis() won't increment when the Arduino is in 
                   * sleepmode. So we cannot make this sensor sleep if we also want  
                   * to calculate/report flow.
                   * http://www.mysensors.org/build/pulse_water
                   */
                  
                  #include <SPI.h>
                  #include <MySensor.h>  
                  
                  #define DIGITAL_INPUT_SENSOR 3                  // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
                  #define SENSOR_INTERRUPT DIGITAL_INPUT_SENSOR-2        // Usually the interrupt = pin -2 (on uno/nano anyway)
                  
                  #define PULSE_FACTOR 1000                       // Nummber of blinks per m3 of your meter (One rotation/liter)
                  
                  #define SLEEP_MODE false                        // flowvalue can only be reported when sleep mode is false.
                  
                  #define MAX_FLOW 40                             // Max flow (l/min) value to report. This filters outliers.
                  
                  #define CHILD_ID 1                              // Id of the sensor child
                  
                  unsigned long SEND_FREQUENCY = 20000;           // Minimum time between send (in milliseconds). We don't want to spam the gateway.
                  
                  MySensor gw;
                  MyMessage flowMsg(CHILD_ID,V_FLOW);
                  MyMessage volumeMsg(CHILD_ID,V_VOLUME);
                  MyMessage lastCounterMsg(CHILD_ID,V_VAR1);
                  
                  double ppl = ((double)PULSE_FACTOR)/1        // Pulses per liter
                  
                  volatile unsigned long pulseCount = 0;   
                  volatile unsigned long lastBlink = 0;
                  volatile double flow = 0;  
                  boolean pcReceived = false;
                  unsigned long oldPulseCount = 0;
                  unsigned long newBlink = 0;   
                  double oldflow = 0;
                  double volume =0;                     
                  double oldvolume =0;
                  unsigned long lastSend =0;
                  unsigned long lastPulse =0;
                  
                  void setup()  
                  {  
                    gw.begin(incomingMessage); 
                  
                    // Send the sketch version information to the gateway and Controller
                    gw.sendSketchInfo("Water Meter", "1.2");
                  
                    // Register this device as Waterflow sensor
                    gw.present(CHILD_ID, S_WATER);       
                  
                    pulseCount = oldPulseCount = 0;
                  
                    // Fetch last known pulse count value from gw
                    gw.request(CHILD_ID, V_VAR1);
                  
                    lastSend = lastPulse = millis();
                  
                    attachInterrupt(SENSOR_INTERRUPT, onPulse, RISING);
                  }
                  
                  
                  void loop()     
                  { 
                    gw.process();
                    unsigned long currentTime = millis();
                  	
                      // Only send values at a maximum frequency or woken up from sleep
                    if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY))
                    {
                      lastSend=currentTime;
                      
                      if (!pcReceived) {
                        //Last Pulsecount not yet received from controller, request it again
                        gw.request(CHILD_ID, V_VAR1);
                        return;
                      }
                  
                      if (!SLEEP_MODE && flow != oldflow) {
                        oldflow = flow;
                  
                        Serial.print("l/min:");
                        Serial.println(flow);
                  
                        // Check that we dont get unresonable large flow value. 
                        // could hapen when long wraps or false interrupt triggered
                        if (flow<((unsigned long)MAX_FLOW)) {
                          gw.send(flowMsg.set(flow, 2));                   // Send flow value to gw
                        }  
                      }
                    
                      // No Pulse count received in 2min 
                      if(currentTime - lastPulse > 120000){
                        flow = 0;
                      } 
                  
                      // Pulse count has changed
                      if (pulseCount != oldPulseCount) {
                        oldPulseCount = pulseCount;
                  
                        Serial.print("pulsecount:");
                        Serial.println(pulseCount);
                  
                        gw.send(lastCounterMsg.set(pulseCount));                  // Send  pulsecount value to gw in VAR1
                  
                        double volume = ((double)pulseCount/((double)PULSE_FACTOR));     
                        if (volume != oldvolume) {
                          oldvolume = volume;
                  
                          Serial.print("volume:");
                          Serial.println(volume, 3);
                          
                          gw.send(volumeMsg.set(volume, 3));               // Send volume value to gw
                        } 
                      }
                    }
                    if (SLEEP_MODE) {
                      gw.sleep(SEND_FREQUENCY);
                    }
                  }
                  
                  void incomingMessage(const MyMessage &message) {
                    if (message.type==V_VAR1) {
                      unsigned long gwPulseCount=message.getULong();
                      pulseCount += gwPulseCount;
                      Serial.print("Received last pulse count from gw:");
                      Serial.println(pulseCount);
                      pcReceived = true;
                    }
                  }
                  
                  void onPulse()     
                  {
                    if (!SLEEP_MODE)
                    {
                      unsigned long newBlink = micros();   
                      unsigned long interval = newBlink-lastBlink;
                      
                      if (interval!=0)
                      {
                        lastPulse = millis();
                        if (interval<500000L) {
                          // Sometimes we get interrupt on RISING,  500000 = 0.5sek debounce ( max 120 l/min)
                          return;   
                        }
                        flow = (60000000.0 /interval) / ppl;
                      }
                      lastBlink = newBlink;
                    }
                    pulseCount++; 
                  }
                  

                  There's more than meets the eye

                  YveauxY 1 Reply Last reply
                  0
                  • the cosmic gateT the cosmic gate

                    @Yveaux said:

                    @the-cosmic-gate I don't know the sketch, so I don't know.
                    Why not just try it?

                    The sketch would be then:

                    /**
                     * The MySensors Arduino library handles the wireless radio link and protocol
                     * between your home built sensors/actuators and HA controller of choice.
                     * The sensors forms a self healing radio network with optional repeaters. Each
                     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                     * network topology allowing messages to be routed to nodes.
                     *
                     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                     * Copyright (C) 2013-2015 Sensnology AB
                     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
                     *
                     * Documentation: http://www.mysensors.org
                     * Support Forum: http://forum.mysensors.org
                     *
                     * This program is free software; you can redistribute it and/or
                     * modify it under the terms of the GNU General Public License
                     * version 2 as published by the Free Software Foundation.
                     *
                     *******************************
                     *
                     * REVISION HISTORY
                     * Version 1.0 - Henrik Ekblad
                     * 
                     * DESCRIPTION
                     * Use this sensor to measure volume and flow of your house watermeter.
                     * You need to set the correct pulsefactor of your meter (pulses per m3).
                     * The sensor starts by fetching current volume reading from gateway (VAR 1).
                     * Reports both volume and flow back to gateway.
                     *
                     * Unfortunately millis() won't increment when the Arduino is in 
                     * sleepmode. So we cannot make this sensor sleep if we also want  
                     * to calculate/report flow.
                     * http://www.mysensors.org/build/pulse_water
                     */
                    
                    #include <SPI.h>
                    #include <MySensor.h>  
                    
                    #define DIGITAL_INPUT_SENSOR 3                  // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
                    #define SENSOR_INTERRUPT DIGITAL_INPUT_SENSOR-2        // Usually the interrupt = pin -2 (on uno/nano anyway)
                    
                    #define PULSE_FACTOR 1000                       // Nummber of blinks per m3 of your meter (One rotation/liter)
                    
                    #define SLEEP_MODE false                        // flowvalue can only be reported when sleep mode is false.
                    
                    #define MAX_FLOW 40                             // Max flow (l/min) value to report. This filters outliers.
                    
                    #define CHILD_ID 1                              // Id of the sensor child
                    
                    unsigned long SEND_FREQUENCY = 20000;           // Minimum time between send (in milliseconds). We don't want to spam the gateway.
                    
                    MySensor gw;
                    MyMessage flowMsg(CHILD_ID,V_FLOW);
                    MyMessage volumeMsg(CHILD_ID,V_VOLUME);
                    MyMessage lastCounterMsg(CHILD_ID,V_VAR1);
                    
                    double ppl = ((double)PULSE_FACTOR)/1        // Pulses per liter
                    
                    volatile unsigned long pulseCount = 0;   
                    volatile unsigned long lastBlink = 0;
                    volatile double flow = 0;  
                    boolean pcReceived = false;
                    unsigned long oldPulseCount = 0;
                    unsigned long newBlink = 0;   
                    double oldflow = 0;
                    double volume =0;                     
                    double oldvolume =0;
                    unsigned long lastSend =0;
                    unsigned long lastPulse =0;
                    
                    void setup()  
                    {  
                      gw.begin(incomingMessage); 
                    
                      // Send the sketch version information to the gateway and Controller
                      gw.sendSketchInfo("Water Meter", "1.2");
                    
                      // Register this device as Waterflow sensor
                      gw.present(CHILD_ID, S_WATER);       
                    
                      pulseCount = oldPulseCount = 0;
                    
                      // Fetch last known pulse count value from gw
                      gw.request(CHILD_ID, V_VAR1);
                    
                      lastSend = lastPulse = millis();
                    
                      attachInterrupt(SENSOR_INTERRUPT, onPulse, RISING);
                    }
                    
                    
                    void loop()     
                    { 
                      gw.process();
                      unsigned long currentTime = millis();
                    	
                        // Only send values at a maximum frequency or woken up from sleep
                      if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY))
                      {
                        lastSend=currentTime;
                        
                        if (!pcReceived) {
                          //Last Pulsecount not yet received from controller, request it again
                          gw.request(CHILD_ID, V_VAR1);
                          return;
                        }
                    
                        if (!SLEEP_MODE && flow != oldflow) {
                          oldflow = flow;
                    
                          Serial.print("l/min:");
                          Serial.println(flow);
                    
                          // Check that we dont get unresonable large flow value. 
                          // could hapen when long wraps or false interrupt triggered
                          if (flow<((unsigned long)MAX_FLOW)) {
                            gw.send(flowMsg.set(flow, 2));                   // Send flow value to gw
                          }  
                        }
                      
                        // No Pulse count received in 2min 
                        if(currentTime - lastPulse > 120000){
                          flow = 0;
                        } 
                    
                        // Pulse count has changed
                        if (pulseCount != oldPulseCount) {
                          oldPulseCount = pulseCount;
                    
                          Serial.print("pulsecount:");
                          Serial.println(pulseCount);
                    
                          gw.send(lastCounterMsg.set(pulseCount));                  // Send  pulsecount value to gw in VAR1
                    
                          double volume = ((double)pulseCount/((double)PULSE_FACTOR));     
                          if (volume != oldvolume) {
                            oldvolume = volume;
                    
                            Serial.print("volume:");
                            Serial.println(volume, 3);
                            
                            gw.send(volumeMsg.set(volume, 3));               // Send volume value to gw
                          } 
                        }
                      }
                      if (SLEEP_MODE) {
                        gw.sleep(SEND_FREQUENCY);
                      }
                    }
                    
                    void incomingMessage(const MyMessage &message) {
                      if (message.type==V_VAR1) {
                        unsigned long gwPulseCount=message.getULong();
                        pulseCount += gwPulseCount;
                        Serial.print("Received last pulse count from gw:");
                        Serial.println(pulseCount);
                        pcReceived = true;
                      }
                    }
                    
                    void onPulse()     
                    {
                      if (!SLEEP_MODE)
                      {
                        unsigned long newBlink = micros();   
                        unsigned long interval = newBlink-lastBlink;
                        
                        if (interval!=0)
                        {
                          lastPulse = millis();
                          if (interval<500000L) {
                            // Sometimes we get interrupt on RISING,  500000 = 0.5sek debounce ( max 120 l/min)
                            return;   
                          }
                          flow = (60000000.0 /interval) / ppl;
                        }
                        lastBlink = newBlink;
                      }
                      pulseCount++; 
                    }
                    
                    YveauxY Offline
                    YveauxY Offline
                    Yveaux
                    Mod
                    wrote on last edited by
                    #14

                    @the-cosmic-gate doesn't seem right... Pulse factor states it's the number of pulses per m3, which is 1000. Ppl is pulses per liter, which is 1.
                    Maybe @hek knows how it's meant to be used (be probably wrote the example sketch)

                    http://yveaux.blogspot.nl

                    1 Reply Last reply
                    0
                    • hekH Offline
                      hekH Offline
                      hek
                      Admin
                      wrote on last edited by
                      #15

                      Sorry, I didn't write the water meter sketch. But parts of the power meter example seems to have ended up in it.

                      YveauxY 1 Reply Last reply
                      0
                      • hekH hek

                        Sorry, I didn't write the water meter sketch. But parts of the power meter example seems to have ended up in it.

                        YveauxY Offline
                        YveauxY Offline
                        Yveaux
                        Mod
                        wrote on last edited by
                        #16

                        @hek said:

                        parts of the power meter example seems to have ended up in it.

                        Especially the header :laughing:

                        http://yveaux.blogspot.nl

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        12

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.0k

                        Posts


                        Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • MySensors
                        • OpenHardware.io
                        • Categories
                        • Recent
                        • Tags
                        • Popular