datalogd.plugins.flowsensorcalibration_datafilter module

class datalogd.plugins.flowsensorcalibration_datafilter.FlowSensorCalibrationDataFilter(sinks=[], counter_rate_id='A_0', a=5975, k=0.173734, x0=0, b=0.284333)[source]

Bases: datalogd.DataFilter

Use a pulse counter’s counts per second to compute a liquid flow rate in litres per minute using an experimentally determined calibration function.

A flow sensor has a spinning turbine and outputs pulses due to the flow rate of the liquid. However, the pulse rate will not be directly proportional to the flow rate (each pulse does not correspond to a fixed volume of liquid). A calibration curve can be constructed by measuring the number of pulses emitted over time for a given volume of liquid at a range of different flow rates. A plot of counts per litre versus counts per minute displays the characteristics of the sensor. Fitting the points to a curve of the form \(f(x) = a(1-\exp(-k(x-x_0)^b))\) will provide the required calibration parameters.

The default parameters (a=5975, k=0.173734, x0=0, b=0.284333) convert from counts per second to litres per minute for the YF-S401 flow sensor, and may be compatible with models from the same family such as YF-S402 and YF-S402B. A similar, smaller sensor common in automatic coffee machines, model number FM-HL3012C, was found to have parameters of a=1950, k=0.0965882, x0=0, b=0.721649.

The original count_rate entry in the data will be preserved, with the calculated flow_rate being appended as a new data entry.

Parameters:
  • counter_rate_id – ID field to match to the data.
  • a – Parameter \(a\) in calibration function.
  • k – Parameter \(k\) in calibration function.
  • x0 – Parameter \(x_0\) in calibration function.
  • b – Parameter \(b\) in calibration function.
  • units – New units for the data.
receive(data)[source]

Accept the provided data and compute a flow rate using the calibration function.

Parameters:data – Data to calculate flow rate from.