upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Protected Attributes

API for the Water Flow Sensor. More...

Detailed Description

This sensor is used to measure water flow in liters per minute (LPM). It incorporates a Hall Effect sensor. The UPM module defines an interrupt routine to be triggered on each low pulse, keeping count. This device requires a 10K pull-up resistor for the signal line (yellow wire). There is a schematic diagram on the SeeedStudio site (3/2015): http://www.seeedstudio.com/wiki/index.php?title=G1/2_Water_Flow_sensor

However, be careful when wiring this up - the schematic appears to have a bug in it: the lower left connection of the signal line (yellow) to Vcc (red) should not be there. The sensor can work with this connection, but probably not for very long.

wfs.jpg
// Instantiate a Water Flow Sensor on digital pin D2. This must
// be an interrupt capable pin.
upm::WFS flow(2);
// set the flow counter to 0 and start counting
flow.clearFlowCounter();
flow.startFlowCounter();
while (shouldRun) {
// we grab these (millis and flowCount) just for display
// purposes in this example
uint32_t millis = flow.getMillis();
uint32_t flowCount = flow.flowCounter();
float fr = flow.flowRate();
// output milliseconds passed, flow count, and computed flow rate
cout << "Millis: " << millis << " Flow Count: " << flowCount;
cout << " Flow Rate: " << fr << " LPM" << endl;
// best to gather data for at least one second for reasonable
// results.
upm_delay(2);
}
flow.stopFlowCounter();

Public Member Functions

 WFS (int pin)
 
 ~WFS ()
 
uint32_t getMillis ()
 
void initClock ()
 
void clearFlowCounter ()
 
void startFlowCounter ()
 
void stopFlowCounter ()
 
uint32_t flowCounter ()
 
float flowRate ()
 

Protected Attributes

wfs_context m_wfs
 

Constructor & Destructor Documentation

WFS ( int  pin)

Water Flow Sensor constructor

Parameters
pinDigital pin to use

Here is the caller graph for this function:

~WFS ( )

WFS destructor

Here is the call graph for this function:

Member Function Documentation

uint32_t getMillis ( )

Returns the number of milliseconds elapsed since initClock() was last called.

Returns
Elapsed milliseconds

Here is the call graph for this function:

void initClock ( )

Resets the clock

Here is the call graph for this function:

void clearFlowCounter ( )
inline

Resets the flow counter to 0. The flow counter should be stopped via stopFlowCounter() prior to calling this function.

Here is the call graph for this function:

void startFlowCounter ( )

Starts the flow counter

Here is the call graph for this function:

Here is the caller graph for this function:

void stopFlowCounter ( )

Stops the flow counter

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t flowCounter ( )
inline

Gets the flow counter

Returns
Flow counter

Here is the call graph for this function:

float flowRate ( )

Computes the flow rate in liters per minute (LPM). Note, this is for the Grove WFS. If you are using some other WFS, you should compute the flow rate on your own based on the data for your sensor.

Returns
Computed flow rate

Here is the call graph for this function:

Here is the caller graph for this function:

Collaboration diagram for WFS:
Collaboration graph
[legend]

The documentation for this class was generated from the following files: