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. Hardware
  3. Water meter : grey scale sensor

Water meter : grey scale sensor

Scheduled Pinned Locked Moved Hardware
8 Posts 5 Posters 7.3k 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.
  • epierreE Offline
    epierreE Offline
    epierre
    Hero Member
    wrote on last edited by epierre
    #1

    Hello,

    A friend of mine has a Sensus Residia Jet water meter, which can work through Z-wave with a "Secure SWM301 Water Meter Sensor".

    Only one domotic box support it but not the other at this time, so I tried to make it work with mysensors..

    I have found a way based on "DFRobot Analog Grayscale Sensor V2" that works !

    The sensor: http://www.dfrobot.com/index.php?route=product/product&product_id=81

    Simply scotch the sensor on the counter so that it detects the wheel (no magnet or visual signal on this counter... the zwave sensors uses VLF induction with two tors).

    IMG_20150630_172731.jpg

    /*
     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.
    
     Sensor on pin analog 0
     
     DFRobot Analog Grayscale Sensor V2
     Watermeter sensus Residia Jet
     
     http://www.dfrobot.com/index.php?route=product/product&product_id=81
    
    Contribution: Hek, adapted by epierre to greyscale sensor water meter
      License: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
    
    
    */
    
    #include <MySensor.h>  
    #include <SPI.h>
    
    #define ANALOG_INPUT_SENSOR 0                   // The analog input you attached your sensor. 
    #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 filetrs outliers.
    #define INTERRUPT DIGITAL_INPUT_SENSOR-2        // Usually the interrupt = pin -2 (on uno/nano anyway)
    #define CHILD_ID 5                              // Id of the sensor child
    unsigned long SEND_FREQUENCY = 20000;           // Minimum time between send (in seconds). We don't want to spam the gateway.
    
    MySensor gw;
    MyMessage flowMsg(CHILD_ID,V_FLOW);
    MyMessage volumeMsg(CHILD_ID,V_VOLUME);
    MyMessage pcMsg(CHILD_ID,V_VAR1);
     
    double ppl = ((double)PULSE_FACTOR)/1000;        // 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;                     
    double oldvolume;
    unsigned long lastSend;
    unsigned long lastPulse;
    unsigned long currentTime;
    boolean metric;
    long lastDebounce = 0;
    long debounceDelay = 500;    // Ignore bounces under 1/2 second
    int oldval =0;
    int val=0;
    
    
    void setup()  
    {  
      gw.begin(incomingMessage); 
      
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Water Meter", "1.0 greyscale");
    
      // Register this device as Waterflow sensor
      gw.present(CHILD_ID, S_WATER);       
    
      // Fetch last known pulse count value from gw
       gw.request(CHILD_ID, V_VAR1);
    
      //Serial.print("Last pulse count from gw:");
      //Serial.println(pulseCount);
      //  attachInterrupt(INTERRUPT, onPulse, RISING);
      lastSend = millis();
      
      //led blinking
      pinMode(13, OUTPUT);
    }
    
    
    void loop()     
    { 
      gw.process();
      currentTime = millis();
    
      val=analogRead(0);
      //Serial.println(val);
      if ((oldval <100) and (val >100)) {
        pulseCount++;
        oldval=val;
      } else {
            oldval=val;
      }
      delay(100);	
        // Only send values at a maximum frequency or woken up from sleep
      bool sendTime = currentTime - lastSend > SEND_FREQUENCY;
      
        // Pulse count has changed
        if (pulseCount != oldPulseCount) {
          gw.send(pcMsg.set(pulseCount));                  // Send  volumevalue to gw VAR1
          double volume = ((double)pulseCount/((double)PULSE_FACTOR));     
          oldPulseCount = pulseCount;
          if (volume != oldvolume) {
            gw.send(volumeMsg.set(volume, 3));               // Send volume value to gw
            //Serial.print("V=");
            //Serial.println(volume);
            oldvolume = volume;
          } 
        }
        lastSend = currentTime;
        if (sendTime && !pcReceived) {
        // No count received. Try requesting it again
        gw.request(CHILD_ID, V_VAR1);
        lastSend=currentTime;
        }
      
      
    }
    
    
    void incomingMessage(const MyMessage &message) {
      if (message.type==V_VAR1) {  
        pulseCount = oldPulseCount = message.getLong();
        Serial.print("Received last pulse count from gw:");
        Serial.println(pulseCount);
        pcReceived = true;
      }
    }
    
    

    Here a picture of the emitter, a Nano with high range antennae in a box !
    IMG_20150701_143623.jpg

    z-wave - Vera -&gt; Domoticz
    rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
    mysensors -&gt; mysensors-gw -&gt; Domoticz

    RJ_MakeR 1 Reply Last reply
    2
    • epierreE epierre

      Hello,

      A friend of mine has a Sensus Residia Jet water meter, which can work through Z-wave with a "Secure SWM301 Water Meter Sensor".

      Only one domotic box support it but not the other at this time, so I tried to make it work with mysensors..

      I have found a way based on "DFRobot Analog Grayscale Sensor V2" that works !

      The sensor: http://www.dfrobot.com/index.php?route=product/product&product_id=81

      Simply scotch the sensor on the counter so that it detects the wheel (no magnet or visual signal on this counter... the zwave sensors uses VLF induction with two tors).

      IMG_20150630_172731.jpg

      /*
       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.
      
       Sensor on pin analog 0
       
       DFRobot Analog Grayscale Sensor V2
       Watermeter sensus Residia Jet
       
       http://www.dfrobot.com/index.php?route=product/product&product_id=81
      
      Contribution: Hek, adapted by epierre to greyscale sensor water meter
        License: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
      
      
      */
      
      #include <MySensor.h>  
      #include <SPI.h>
      
      #define ANALOG_INPUT_SENSOR 0                   // The analog input you attached your sensor. 
      #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 filetrs outliers.
      #define INTERRUPT DIGITAL_INPUT_SENSOR-2        // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 5                              // Id of the sensor child
      unsigned long SEND_FREQUENCY = 20000;           // Minimum time between send (in seconds). We don't want to spam the gateway.
      
      MySensor gw;
      MyMessage flowMsg(CHILD_ID,V_FLOW);
      MyMessage volumeMsg(CHILD_ID,V_VOLUME);
      MyMessage pcMsg(CHILD_ID,V_VAR1);
       
      double ppl = ((double)PULSE_FACTOR)/1000;        // 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;                     
      double oldvolume;
      unsigned long lastSend;
      unsigned long lastPulse;
      unsigned long currentTime;
      boolean metric;
      long lastDebounce = 0;
      long debounceDelay = 500;    // Ignore bounces under 1/2 second
      int oldval =0;
      int val=0;
      
      
      void setup()  
      {  
        gw.begin(incomingMessage); 
        
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Water Meter", "1.0 greyscale");
      
        // Register this device as Waterflow sensor
        gw.present(CHILD_ID, S_WATER);       
      
        // Fetch last known pulse count value from gw
         gw.request(CHILD_ID, V_VAR1);
      
        //Serial.print("Last pulse count from gw:");
        //Serial.println(pulseCount);
        //  attachInterrupt(INTERRUPT, onPulse, RISING);
        lastSend = millis();
        
        //led blinking
        pinMode(13, OUTPUT);
      }
      
      
      void loop()     
      { 
        gw.process();
        currentTime = millis();
      
        val=analogRead(0);
        //Serial.println(val);
        if ((oldval <100) and (val >100)) {
          pulseCount++;
          oldval=val;
        } else {
              oldval=val;
        }
        delay(100);	
          // Only send values at a maximum frequency or woken up from sleep
        bool sendTime = currentTime - lastSend > SEND_FREQUENCY;
        
          // Pulse count has changed
          if (pulseCount != oldPulseCount) {
            gw.send(pcMsg.set(pulseCount));                  // Send  volumevalue to gw VAR1
            double volume = ((double)pulseCount/((double)PULSE_FACTOR));     
            oldPulseCount = pulseCount;
            if (volume != oldvolume) {
              gw.send(volumeMsg.set(volume, 3));               // Send volume value to gw
              //Serial.print("V=");
              //Serial.println(volume);
              oldvolume = volume;
            } 
          }
          lastSend = currentTime;
          if (sendTime && !pcReceived) {
          // No count received. Try requesting it again
          gw.request(CHILD_ID, V_VAR1);
          lastSend=currentTime;
          }
        
        
      }
      
      
      void incomingMessage(const MyMessage &message) {
        if (message.type==V_VAR1) {  
          pulseCount = oldPulseCount = message.getLong();
          Serial.print("Received last pulse count from gw:");
          Serial.println(pulseCount);
          pcReceived = true;
        }
      }
      
      

      Here a picture of the emitter, a Nano with high range antennae in a box !
      IMG_20150701_143623.jpg

      RJ_MakeR Offline
      RJ_MakeR Offline
      RJ_Make
      Hero Member
      wrote on last edited by
      #2

      @epierre Pretty Cool..

      RJ_Make

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pme999
        wrote on last edited by
        #3

        Hello. I'm very interested by your system to replace SWM301 with arduino nano and grey scale sensor. I'm new in arduino world and a little bit lost to succeed. I'm usine VERA as controller. Can you send me schematic for connexions of radio, grey scale sensor and the sketchs need to be included. I tried a serial gateway sketch, which seems to be uploaded but when I try to upload your sketch I have this error :

        WARNING: Spurious .ci folder in 'MySensors' library
        WARNING: Spurious .mystools folder in 'MySensors' library
        In file included from /Users/patriceagnesmetairie1 1/Documents/Arduino/sketch_compteur_eau/sketch_compteur_eau.ino:20:0:
        /Users/patriceagnesmetairie1 1/Documents/Arduino/libraries/MySensors-master/MySensors.h:405:2: error: #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
        #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless.
        ^
        exit status 1

        can you help me ?
        Thanks a lot
        Patrice

        1 Reply Last reply
        0
        • epierreE Offline
          epierreE Offline
          epierre
          Hero Member
          wrote on last edited by
          #4

          Hello,

          I've dropped this approch to use the CNY70 ir on this water meter.

          I did that for a friend that has not the mysensors gateway (range issue) so I made it with a Particle Photon using a wifi extender, but it is quite straightforward reading the pulse up and down.

          z-wave - Vera -&gt; Domoticz
          rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
          mysensors -&gt; mysensors-gw -&gt; Domoticz

          1 Reply Last reply
          0
          • epierreE Offline
            epierreE Offline
            epierre
            Hero Member
            wrote on last edited by
            #5

            here is a link with the schematics (so simple !):https://easydomoticz.com/forum/viewtopic.php?f=17&t=1737&start=70

            z-wave - Vera -&gt; Domoticz
            rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
            mysensors -&gt; mysensors-gw -&gt; Domoticz

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kimot
              wrote on last edited by
              #6

              And why you do not remove a half of plastic cover above rotating sensor wheel to put sensor closer?

              1 Reply Last reply
              0
              • epierreE Offline
                epierreE Offline
                epierre
                Hero Member
                wrote on last edited by
                #7

                it you remove plastic it is not water proof anymore, and greyscale was not precise enough....
                CNY70 has reflexion protection which is much better

                z-wave - Vera -&gt; Domoticz
                rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
                mysensors -&gt; mysensors-gw -&gt; Domoticz

                zboblamontZ 1 Reply Last reply
                0
                • epierreE epierre

                  it you remove plastic it is not water proof anymore, and greyscale was not precise enough....
                  CNY70 has reflexion protection which is much better

                  zboblamontZ Offline
                  zboblamontZ Offline
                  zboblamont
                  wrote on last edited by
                  #8

                  @epierre Plus presumably it can be universally applied whether a wet or dry register?

                  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.1k

                  Posts


                  Copyright 2025 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