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. General Discussion
  3. Watermeter pulsesensor

Watermeter pulsesensor

Scheduled Pinned Locked Moved General Discussion
7 Posts 2 Posters 2.4k Views 1 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.
  • E Offline
    E Offline
    egbertje
    wrote on last edited by egbertje
    #1

    I have build an sensor with the watermeterpulsesensor sketch with an arduino nano and the TCRT5000 module sensor.
    It works but everytime the value rises with 2 for one rotation of my watermeter. Default /1000 ( 1liter per rotation)
    So again when i get with a mirror and make the sensor go high (green led goes on) the value rises with 1 but when i remove the reflector (green led goes off) also the value rises wth one again.
    So it looks like the code triggers to the up and down going flank together of one pulse.
    Do i have to change something in the code?

    BulldogLowellB 1 Reply Last reply
    0
    • E egbertje

      I have build an sensor with the watermeterpulsesensor sketch with an arduino nano and the TCRT5000 module sensor.
      It works but everytime the value rises with 2 for one rotation of my watermeter. Default /1000 ( 1liter per rotation)
      So again when i get with a mirror and make the sensor go high (green led goes on) the value rises with 1 but when i remove the reflector (green led goes off) also the value rises wth one again.
      So it looks like the code triggers to the up and down going flank together of one pulse.
      Do i have to change something in the code?

      BulldogLowellB Offline
      BulldogLowellB Offline
      BulldogLowell
      Contest Winner
      wrote on last edited by
      #2

      @egbertje

      maybe you re getting some bounce which creates two interrupts...

      you could play around with that here:

      void onPulse()     
      { 
        if (!SLEEP_MODE) {
          unsigned long newBlink = micros();   
          unsigned long interval = newBlink-lastBlink;
      	lastPulse = millis();
          if (interval<500000L) {
            // Sometimes we get interrupt on RISING,  500000 = 0.5sek debounce ( max 120 l/min)<<<<<< HERE
            return;   
          }
          flow = (60000000.0 /interval) / ppl;
          lastBlink = newBlink;
        }
        pulseCount++; 
      }
      
      1 Reply Last reply
      0
      • E Offline
        E Offline
        egbertje
        wrote on last edited by
        #3

        Hi Bulldog,

        I allready played with that value and increased it to 2 or 3 seconds but that does not change my problem.
        I think the problem is that this code sees a pulse and when the pulse is going from zero to high it is 1 count but also when this pulse is going again to zero the count is 2.

        BulldogLowellB 1 Reply Last reply
        0
        • E egbertje

          Hi Bulldog,

          I allready played with that value and increased it to 2 or 3 seconds but that does not change my problem.
          I think the problem is that this code sees a pulse and when the pulse is going from zero to high it is 1 count but also when this pulse is going again to zero the count is 2.

          BulldogLowellB Offline
          BulldogLowellB Offline
          BulldogLowell
          Contest Winner
          wrote on last edited by
          #4

          @egbertje

          try the other edge yet?

          pinMode(2, INPUT_PULLUP); // keep pin from floating
          attachInterrupt(INTERRUPT, onPulse, FALLING);
          
          1 Reply Last reply
          0
          • E Offline
            E Offline
            egbertje
            wrote on last edited by
            #5

            Also this does not work (pinmode3)

            1 Reply Last reply
            0
            • E Offline
              E Offline
              egbertje
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • E Offline
                E Offline
                egbertje
                wrote on last edited by
                #7

                After testing some more i get better result with this setting:
                attachInterrupt(INTERRUPT, onPulse, LOW);

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


                16

                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