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. WaterMeter and GazMeter - Reed IRQ False positive

WaterMeter and GazMeter - Reed IRQ False positive

Scheduled Pinned Locked Moved Hardware
4 Posts 3 Posters 1.8k 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.
  • D Offline
    D Offline
    doblanch
    wrote on last edited by doblanch
    #1

    Hello Team,

    I have a concern :-)
    I created 2 sensors. A waterpulse counter based on Reed switch and a Gaz Counter based also on reed switch. For the waterpulse counter, the .ino is the one provided on the mysensors website. My problem is that I have some false positive.
    WhenI just plug the arduino in USB on my MAC, it works. However, If I connect it from a power supply 220V ( vin or USB), I have some issues, and I have some pulse even if there is nothing. For example, I have a soleniod valve, if I switch it ON/OFF, it troubles the Reed IRQ signal and I have a false pulse taking in account...
    So, my question is how to remove the interference. I use the reed switch in pullup, and I applied a 10uF capacitor on the reed switch.
    Should I use a specific powersupply with a filter ???? I'm lost :-( I made some tests during 6 hours without any good result.
    please help...

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

      Have a look at mine, I don't have any false positive with a reed adapted this way:

      https://github.com/empierre/arduino/blob/master/WaterMeterPulseSensor2.ino

      z-wave - Vera -> Domoticz
      rfx - Domoticz <- MyDomoAtHome <- Imperihome
      mysensors -> mysensors-gw -> Domoticz

      1 Reply Last reply
      0
      • D Offline
        D Offline
        doblanch
        wrote on last edited by
        #3

        Hello,

        You code just remove multiple pulse during a short period of time, like a push button.
        My problem is different. I have to remove the first random pulse ! Each pulse is important for me as I use it for my gaz cooker.
        In fact, I found the solution, I remove the IRQ interrupt. The reed switch clode around 250ms. So I test during each loop. If the switch is close, I wait 30ms and test again if switch is close. If it is still close, it means that's not a false postiive and I can count a pulse.
        I have the code since 1 week, and it works properly without any false pulse.
        In fact my solenoide valve is too close from arduino and it make some interference I can't remove with capacitors...
        Here is my code:

         if (state != laststate)
          {  
           delay(30);
            if (state != laststate)
            {  
           delay(30);
            if (state != laststate)
          
          
              {
               if (state == HIGH)
               {
                unsigned long newBlink = micros();   
                unsigned long interval = newBlink-lastBlink;
                lastPulse = millis();
                flow = (60000000.0 /interval) / ppl;
                lastBlink = newBlink;
                pulseCount++; 
                Serial.print("pulseCount:");
                Serial.println(pulseCount); 
                Serial.print("interval:");
                Serial.println(interval/1000); 
                state = laststate;
                flow = (60000000.0 / interval) / ppl;
                alarm_flag = 1;
           //     state1 == true; // un pulse est apparu, on demarre l'alarm
                lastBlink = newBlink;
                alarm1 = 0;
                alarm1_t = millis();
               }
               if (state == LOW)
               {
               state = laststate;
               }
              }   
            }
           }
        
        }```
        1 Reply Last reply
        0
        • B Offline
          B Offline
          BulldogLowell
          Contest Winner
          wrote on last edited by
          #4

          @doblanch said:

          if (state != laststate)
          {
          delay(30);
          if (state != laststate)
          {
          delay(30);
          if (state != laststate)

          why do you have these blocking delay()s? I would focus on non-blocking code for such a device... Are you using an interrupt?

          I think you need to post your entire sketch to get good comments

          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          25

          Online

          12.1k

          Users

          11.2k

          Topics

          113.4k

          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