Installing a cheap water flow meter with attached Raspberry Pi ZeroW

Поделиться
HTML-код
  • Опубликовано: 21 янв 2025

Комментарии • 62

  • @qatrahqatraty8184
    @qatrahqatraty8184 4 года назад

    Hello, this version of raspberry pi zero can work on three water sensor at the same time

  • @dave-in-nj9393
    @dave-in-nj9393 4 года назад

    nice, simple and great that you offered the code.

  • @tinkerer3954
    @tinkerer3954 Год назад

    what was the frequency per liter conversion for you. or the pulse to liter convertion

    • @ravraid
      @ravraid  Год назад

      Unfortunately, I don't think I ever did a detailed measurement since my application is pretty crude. I just used a rough threshold to indicate when water was flowing so it could email me that I should take a look.

  • @davidcooper5390
    @davidcooper5390 2 года назад

    I am interested in the code, I am working on Design project with a small group and would love to see this code to test it with my system.

    • @ravraid
      @ravraid  2 года назад

      Sure. You can find the code at GitHub (see the link in the video description) or, I also pasted the code into a reply to another comment. It should be just below.

  • @ennaiarindhal3141
    @ennaiarindhal3141 4 года назад

    Bro can read 2 flow sensors data in raspberry pi 4

    • @ravraid
      @ravraid  4 года назад

      If you’re asking if it is possible to read two sensors with a RPI 4, I think that should be no problem. The code is pretty efficient and shouldn’t load the Pi so two sensors should possible. Give it a try!

    • @ennaiarindhal3141
      @ennaiarindhal3141 4 года назад

      😁 Thanks,, coding??

    • @ravraid
      @ravraid  4 года назад

      @@ennaiarindhal3141 Yes, there will be coding :). You’ll need to specify a second GPIO since you’ll have a second sensor attached to it. Then, you’ll need to duplicate the code that reads from that sensor and processes it. If you have questions about specific lines of the code, feel free to post them.

    • @ennaiarindhal3141
      @ennaiarindhal3141 4 года назад

      🤗Thank you

  • @Tom-bu6ec
    @Tom-bu6ec 4 года назад

    Good video! How can I use two sensors for cold and hot water? Is it possible?

    • @ravraid
      @ravraid  4 года назад

      Mmm - my only concern would be whether these cheap flow sensors can handle hot water. I see some cheap brass ones on Amazon that might work but the reviews are low due to the threading. Pipe threads are a black art but I think a brass valve (assuming all the parts that touch water are brass) would be better for hot water.

  • @ennaiarindhal3141
    @ennaiarindhal3141 4 года назад

    Bro.. Can share flow sensor data from raspberry pi 4 to mysql database????

    • @ravraid
      @ravraid  4 года назад

      I haven't done that but it should be straightforward once you've setup mysql on the Pi. There are lots of Pi mysql examples out there.

    • @ennaiarindhal3141
      @ennaiarindhal3141 4 года назад

      Thanks bro

  • @Patriciarqu
    @Patriciarqu 4 года назад +1

    Can you share the code please?

    • @ravraid
      @ravraid  4 года назад

      Yep, it is all included in the comment below.

    • @manusharma3212
      @manusharma3212 4 года назад

      @@ravraid I went through all the comments, but couldn't find the code. Why not post it in the description of the video?

    • @ravraid
      @ravraid  4 года назад +1

      @@manusharma3212 I see the code in a comment from 1 year ago but regardless, here it is:
      #!/usr/bin/env python
      # Simple script to monitor a cheap water flow sensor attached to gpio 4. The script counts pulses over an interval and then
      # checks if the count exceeds a limit. If it does, it sends an email.
      # This script uses some of the pigpio code for doing the counts.
      # ravraid 1/31/19
      import time, datetime
      from smtplib import SMTP_SSL as SMTP
      from email.MIMEText import MIMEText
      import pigpio
      intervalTime = 15 # in seconds
      triggerMin = 50 # limit in pulse counts - adjust to detect small leaks
      SMTPserver = 'smtp.gmail.com'
      sender = 'FOO@BLAH.COM'
      destination = ['FOO@BLAH.COM']
      USERNAME = "FOO@BLAH.COM"
      PASSWORD = "MYPASSWORD"
      subject = ""
      waterFlow = 0
      flowGpio = 4
      text_subtype = 'plain'
      def sendMail(content):
      try:
      msg = MIMEText(content, text_subtype)
      msg['Subject']= subject
      msg['From'] = sender # some SMTP servers will do this automatically, not all
      conn = SMTP(SMTPserver)
      conn.set_debuglevel(False)
      conn.login(USERNAME, PASSWORD)
      try:
      conn.sendmail(sender, destination, msg.as_string())
      finally:
      conn.close()
      except Exception, exc:
      sys.exit( "mail failed; %s" % str(exc) ) # give a error message
      pi = pigpio.pi()
      pi.set_mode(flowGpio, pigpio.INPUT)
      pi.set_pull_up_down(flowGpio, pigpio.PUD_DOWN)
      flowCallback = pi.callback(flowGpio, pigpio.FALLING_EDGE)
      old_count = 0
      triggerTime = datetime.datetime.today() - datetime.timedelta(weeks=1) # Initialize it to more than a day ago
      while True:
      time.sleep(intervalTime)
      count = flowCallback.tally()
      waterFlow = count - old_count
      #print("counted {} pulses".format(waterFlow))
      yesterday = datetime.datetime.today() - datetime.timedelta(days=1)
      # Only send at most one message per day so check if the last trigger was more than 24hours ago
      if ( (waterFlow > triggerMin) & (triggerTime < yesterday) ):
      triggerTime = datetime.datetime.today()
      print "Note: Sending mail.."
      subject= "Waterflow over limit: " + str(waterFlow)
      message= "Limit is: " + str(triggerMin) + " and water flow is: " + str(waterFlow) + '
      '
      message = message + '

      ' + "Sent from rpiZero1 waterFlowMeter.py" + '
      '
      sendMail(message)
      old_count = count
      pi.stop()

    • @ennaiarindhal3141
      @ennaiarindhal3141 4 года назад

      In this description code is python or any other

    • @mohamedabdelfattah8627
      @mohamedabdelfattah8627 3 года назад

      @@ennaiarindhal3141 Python

  • @woodrowcollins1975
    @woodrowcollins1975 5 лет назад

    This is a rather neat little idea, by chance is there any kind of understanding to the number of pulses to flow rate (either from the manufacturer or your own experience)? I'm interesting in building something very similar but would like to understand how to convert the findings of a device like this one to an actual flow rate.

    • @ravraid
      @ravraid  5 лет назад

      I didn’t calibrate it since my needs aren’t critical but I did notice that there was a comment on the Amazon page (from alexw) saying he measured the rate to be 796 pulses/liter but it sounded like it might not be all that consistent and, of course, there could be unit-to-unit variances as well. If you wanted to take the time you could pretty easily rig up a funnel to flow through the meter and pour a measured amount of water through while reading the pulses. If you do that 10-20 times you should get a good feel for the precision and accuracy of the measurements.

  • @Famyto72
    @Famyto72 3 года назад

    Nice project.

  • @yonathankristianto8824
    @yonathankristianto8824 5 лет назад

    do you have python code for hall effect flow meter sensor using wemos d1 r1 mini sir?

    • @ravraid
      @ravraid  5 лет назад

      Sorry, no, but that looks like a fun little controller.

  • @leonviviers5140
    @leonviviers5140 6 лет назад

    Hi could you kindly please share the code for pulse count?

    • @ravraid
      @ravraid  6 лет назад

      Sorry I missed this message. As I noted above, I'll do some clean up and post it here.

  • @royramirez3343
    @royramirez3343 5 лет назад

    Excellent video!

  • @BC-yd6dl
    @BC-yd6dl 4 года назад

    I would definitely be interested in the code. Is it interrupt driven? Or do you poll the pin?

  • @mashfiqrizvee2537
    @mashfiqrizvee2537 5 лет назад

    Really great content sir. Can i use the flow meter to calculate total volume of the water passing through ?

    • @ravraid
      @ravraid  5 лет назад +1

      Certainly the count from the sensor is an indicator of the water flow but I can’t vouch for its accuracy. My guess is that it will be reasonably accurate in a certain flow range. You could set it up in a test rig and put a known amount through several times to see if you get consistent results.

    • @mashfiqrizvee2537
      @mashfiqrizvee2537 5 лет назад

      @@ravraid sir last question. Please answer if possible. Can i use this sensor to measure the flow of diesel flowing through a pipe? If not. Do you know how can i do it? I really need to know the answer. God bless you sir.

    • @mashfiqrizvee2537
      @mashfiqrizvee2537 5 лет назад

      Is there any other sensor that i can use? Sir please i need the answer badly.

    • @ravraid
      @ravraid  5 лет назад +1

      This sensor is mostly made of plastic so I would be concerned that diesel fuel would corrode it. I’m sure if you google flow meter you can find more robust units than this one but they will also be more expensive. However, certainly a unit like this can measure flow rates of a fluid - the question is just what kind of precision and accuracy you require.

    • @mashfiqrizvee2537
      @mashfiqrizvee2537 5 лет назад

      @@ravraid THANK YOU FOR THE REPLY SIR!!

  • @davidnewton3064
    @davidnewton3064 6 лет назад

    The specs listed for this sensor, fl-408, is a bit confusing. It says voltage: 3.5vdc-24vdc. Below that it says Working Voltage: 5-24vdc. Just about every site on the web has that description. Well which is it? I see you are using this sensor without any logic level shifting; using the default 3.3v logic directly from the pi. I would assume that means you've confirmed it will work consistently and provide accurate measurements at that voltage?
    Im about to wire up my yf-s201 sensor with a voltage divider but if this one will work directly from the pi Ill order a few.

    • @ravraid
      @ravraid  6 лет назад

      I did confirm that it worked consistently at 3.3V using a power supply before I hooked it up to the Pi but I never check the accuracy of the flow rate since my needs are pretty crude - i.e. I just need to know if it goes beyond a limit. Now that I think of it, it would be pretty easy with the Pi attached to compare the counts while funneling a fixed amount of water through it repeatedly. However, if you really want accuracy, that would need to be checked at various temperatures. On the other hand, it’s a cheap device so I wouldn’t expect it to be very robust over time. I just hope it doesn’t leak!

    • @ravraid
      @ravraid  5 лет назад +1

      I check the flow meter with a 3.3v supply before using it but I can't say it was a rigorous experiment. I just checked relatively low and high flow rates several times to make sure I got consistent results but not necessarily accurate results. I just need the meter as a very general indicator so flow accuracy isn't important. Obviously, you could us the 5v rail on the RPi if you wanted to be true to the datasheet.

  • @bobhammell6308
    @bobhammell6308 5 лет назад +1

    Thanks for sharing this vid, I'm looking to build a similar project myself. It looks like you hook it up to the 3.3V pin. The specs on some of these flow meters say it takes 5V to run. Is there a reason you went with 3.3V? Looks like it didn't cause any issue for you.

    • @ravraid
      @ravraid  5 лет назад

      No particular reason and yes, you could just run it off of the RPi 5v rail. I think that would work fine as well.

  • @michaels8297
    @michaels8297 5 лет назад

    Can you post the code?

    • @ravraid
      @ravraid  5 лет назад

      I posted the code in my comments awhile back. I see it there so I assume you should be able to see it as well. Take a look…

    • @stuarttener6194
      @stuarttener6194 4 года назад

      Great video.
      Is there some chance you might be able to post the code soon? I saw you said you posted it, but it is not there. Did you remove it? Why would you do that if you posted it originally?
      Thanks!

  • @wagnergabriel8728
    @wagnergabriel8728 3 года назад

    sensacional, obrigado pela explicação

  • @rajat_verma91
    @rajat_verma91 4 года назад

    Is it still working, or broke down? I am planning to do a similar implementation. But doubt full on Durability of the product.

    • @ravraid
      @ravraid  4 года назад +2

      I check it about every 6 months and it all seems to be working

  • @Johs4490
    @Johs4490 4 года назад

    Thanks for the good short explanation , I'm making a little projekt for my garden irrigation, i want to use a YF-B5 waterflow sensor (hall effect sensor) as a "watchdog" , to avoid a big waterbill after a sommerholliday, can you please post a link to your Phyton script ? THX in advance :-)

    • @ravraid
      @ravraid  4 года назад +1

      I've been pasting the code into replies but it seems as though folks are not able to see it. I've now put it on github: github.com/ravra/waterFlowMeter

  • @rafaelmolinyawe5716
    @rafaelmolinyawe5716 6 лет назад +1

    Hello good sir, I was wondering if you can provide the python code to help me interfacing my flow meter with the raspberry pi. Thank you so much for your good content.

    • @ravraid
      @ravraid  6 лет назад

      Sure, I should probably clean it up a bit but then I will post it here - it isn't much code.

    • @samuelharrison4626
      @samuelharrison4626 4 года назад

      @@ravraid any luck posting this code?

    • @ravraid
      @ravraid  4 года назад +2

      I've posted the code in replies a few times now and I'm not sure why others are not able to see it. I can't post it in the video description as it gives errors due to certain brackets not being allowed. Regardless, here is the code:
      #!/usr/bin/env python
      # Simple script to monitor a cheap water flow sensor attached to gpio 4. The script counts pulses over an interval and then
      # checks if the count exceeds a limit. If it does, it sends an email.
      # This script uses some of the pigpio code for doing the counts.
      # ravraid 1/31/19
      import time, datetime
      from smtplib import SMTP_SSL as SMTP
      from email.MIMEText import MIMEText
      import pigpio
      intervalTime = 15 # in seconds
      triggerMin = 50 # limit in pulse counts - adjust to detect small leaks
      SMTPserver = 'smtp.gmail.com'
      sender = 'FOO@BLAH.COM'
      destination = ['FOO@BLAH.COM']
      USERNAME = "FOO@BLAH.COM"
      PASSWORD = "MYPASSWORD"
      subject = ""
      waterFlow = 0
      flowGpio = 4
      text_subtype = 'plain'
      def sendMail(content):
      try:
      msg = MIMEText(content, text_subtype)
      msg['Subject']= subject
      msg['From'] = sender # some SMTP servers will do this automatically, not all
      conn = SMTP(SMTPserver)
      conn.set_debuglevel(False)
      conn.login(USERNAME, PASSWORD)
      try:
      conn.sendmail(sender, destination, msg.as_string())
      finally:
      conn.close()
      except Exception, exc:
      sys.exit( "mail failed; %s" % str(exc) ) # give a error message
      pi = pigpio.pi()
      pi.set_mode(flowGpio, pigpio.INPUT)
      pi.set_pull_up_down(flowGpio, pigpio.PUD_DOWN)
      flowCallback = pi.callback(flowGpio, pigpio.FALLING_EDGE)
      old_count = 0
      triggerTime = datetime.datetime.today() - datetime.timedelta(weeks=1) # Initialize it to more than a day ago
      while True:
      time.sleep(intervalTime)
      count = flowCallback.tally()
      waterFlow = count - old_count
      #print("counted {} pulses".format(waterFlow))
      yesterday = datetime.datetime.today() - datetime.timedelta(days=1)
      # Only send at most one message per day so check if the last trigger was more than 24hours ago
      if ( (waterFlow > triggerMin) & (triggerTime < yesterday) ):
      triggerTime = datetime.datetime.today()
      print "Note: Sending mail.."
      subject= "Waterflow over limit: " + str(waterFlow)
      message= "Limit is: " + str(triggerMin) + " and water flow is: " + str(waterFlow) + '
      '
      message = message + '

      ' + "Sent from rpiZero1 waterFlowMeter.py" + '
      '
      sendMail(message)
      old_count = count
      pi.stop()

    • @mohamedabdelfattah8627
      @mohamedabdelfattah8627 3 года назад

      @@ravraid Appreciation for all your valuable efforts.

  • @ravraid
    @ravraid  6 лет назад +5

    #!/usr/bin/env python
    # Simple script to monitor a cheap water flow sensor attached to gpio 4. The script counts pulses over an interval and then
    # checks if the count exceeds a limit. If it does, it sends an email.
    # This script uses some of the pigpio code for doing the counts.
    # ravraid 1/31/19
    import time, datetime
    from smtplib import SMTP_SSL as SMTP
    from email.MIMEText import MIMEText
    import pigpio
    intervalTime = 15 # in seconds
    triggerMin = 50 # limit in pulse counts - adjust to detect small leaks
    SMTPserver = 'smtp.gmail.com'
    sender = 'FOO@BLAH.COM'
    destination = ['FOO@BLAH.COM']
    USERNAME = "FOO@BLAH.COM"
    PASSWORD = "MYPASSWORD"
    subject = ""
    waterFlow = 0
    flowGpio = 4
    text_subtype = 'plain'
    def sendMail(content):
    try:
    msg = MIMEText(content, text_subtype)
    msg['Subject']= subject
    msg['From'] = sender # some SMTP servers will do this automatically, not all
    conn = SMTP(SMTPserver)
    conn.set_debuglevel(False)
    conn.login(USERNAME, PASSWORD)
    try:
    conn.sendmail(sender, destination, msg.as_string())
    finally:
    conn.close()
    except Exception, exc:
    sys.exit( "mail failed; %s" % str(exc) ) # give a error message
    pi = pigpio.pi()
    pi.set_mode(flowGpio, pigpio.INPUT)
    pi.set_pull_up_down(flowGpio, pigpio.PUD_DOWN)
    flowCallback = pi.callback(flowGpio, pigpio.FALLING_EDGE)
    old_count = 0
    triggerTime = datetime.datetime.today() - datetime.timedelta(weeks=1) # Initialize it to more than a day ago
    while True:
    time.sleep(intervalTime)
    count = flowCallback.tally()
    waterFlow = count - old_count
    #print("counted {} pulses".format(waterFlow))
    yesterday = datetime.datetime.today() - datetime.timedelta(days=1)
    # Only send at most one message per day so check if the last trigger was more than 24hours ago
    if ( (waterFlow > triggerMin) & (triggerTime < yesterday) ):
    triggerTime = datetime.datetime.today()
    print "Note: Sending mail.."
    subject= "Waterflow over limit: " + str(waterFlow)
    message= "Limit is: " + str(triggerMin) + " and water flow is: " + str(waterFlow) + '
    '
    message = message + '

    ' + "Sent from rpiZero1 waterFlowMeter.py" + '
    '
    sendMail(message)
    old_count = count
    pi.stop()