8 years, 10 months ago.

Water flow sensor

Hej there

I have troubles making this work sensor work, and i can't find any data on this from anyone before. It's a pretty important task that involves a bigger project.

http://www.seeedstudio.com/wiki/index.php?title=G1/2_Water_Flow_sensor

I don't know how to code it - I need it to do the following:

1)Register/count pulses 2)Convert the pulses to litres/min 3) Print the number out 4) restart

Please help!

Any one?

The referenced webpage shows the full details on this sensor but the example code is for the Arduino target board(s). If you are short on time, switch to the Arduino platform and you should be up and running quickly. Otherwise you will need to learn how to convert the Arduino sketch to MBED. A quick summary is that you will need to count the pulses sent by this sensor (internal hall effect = magnetic field triggered) and then perform some math to get an estimate of the water flow. Search the MBED website on how to count pulses on a port pin for example: https://developer.mbed.org/questions/680/Counting-pulses-on-input/

posted by Sanjiv Bhatia 15 Feb 2016

I really honestly dont have any time or competence to do it

is there anyway where i can pay someone to do it?

posted by uinf uinf 15 Feb 2016

2 Answers

8 years, 10 months ago.

1) Need to make sure that the device has an input pin which is 5 Volt tolerant, or you will need to level shift the signal from the sensor

2) The following demonstrates how to use the interrupts on the mbed: https://developer.mbed.org/handbook/InterruptIn

3) The sample code on the wikipage for the sensor should port to the mbed directly.....

Need to know what platform you plan to use.

8 years, 10 months ago.

This is pretty much a translation of that code to work on Mbed.

If using LPC1768, that is 5v tolerant.

Flow Meter test snip

#include "mbed.h"

DigitalOut myled(LED1);
InterruptIn sensor(p5);

Serial pc(USBTX, USBRX);

int NbTopsFan;
int Calc;

void rpm()     //This function increments on the rising edge of the hall effect sensors signal
{ 
  NbTopsFan++;  
} 

int main() {
    
    while(1) {
        
        NbTopsFan = 0;                  //Set NbTops to 0 ready for calculations
        myled=1;
        sensor.rise(&rpm);              //Enables rising edge interrupt
        wait_ms(1000);                  //Wait 1 second and count HALL pulses
        sensor.rise(NULL);              //Disable interrupt
        myled=0;
        
        Calc = (NbTopsFan * 60) / 7.5;  //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour 
        
        pc.printf ("Flow L/hour: %d\r\n",Calc);  //Prints the number calculated above        
    }
}

Nice.

posted by Joel Rosiene 15 Feb 2016

Thank you a lot sir!!

posted by uinf uinf 16 Feb 2016

hi, Paul Staron can please explain to me why 60 and 7.5 value is used in the datasheet it has given Pulse Characteristic: F= 7Q(L/MIN).

posted by Fermedicius Labs 25 Sep 2018