Measure Fuel Flow Rates using Particle Photon

March 20,2019

In this solution following parts were used.

A.Water Flow Sensor:

One Inch Water flow sensor used for flow measurement it consists of a plastic valve body water rotor and a hall effect sensor., When water flows through the rotor, rotor rolls. Its speed changes with different rate of flow. The halleffect sensor outputs the corresponding pulse signal. This one is suitable to detect flow in water dispenser or coffee machine.

,

B.Particle Photon Board:

1.Particle photon is a complete IoT (Internet of Things) hardware development kit, it provides everything that we need to build a connected product.

,2. It has powerful 120Mhz ARM Cortex M3 microcontroller with a Broadcom Wi-Fi chip in a tiny thumbnail-sized module. 3. Particle provides access to a free cloud service of the particle cloud.,The Particle Cloud has some great features for building connected projects, including over-the-air firmware updates, an easy-to-use REST API, and firmware development supported by Web and local IDEs.,

Features of Particle Photon:

  • Processor:STM32F205 120M hz ARM>
  • Memory: 1MB flash, 128KB RAM
  • Onboard RGB status LED.
  • ,18 Mixed-signal GPIO and advanced peripherals
  • Open source design
  • Real-time operating system (Free RTOS)
  • Soft AP setup
  • On-board Wi-Fi module
  • Broadcom BCM43362 Wi-Fi chip
  • 802.11b/g/n Wi-Fi
  • C.Jumper Cables & one LED

    I have joined first water sensor's ground and V+ with particle photons ground pin and 3.3v pinrespectively and signal with D2 (digital pin 2) and for LED I have used D1 for +veHere is the code that I have used inside photon board,
     byte statusLed    = D1; 
    byte sensorInterrupt = D2; // 0 = digital pin 2
    byte sensorPin = D2;
    // The hall-effect flow sensor outputs approximately 4.5 pulses per second per litre/minute of flow.
    float calibrationFactor = 4.5;
    volatile byte pulseCount;
    float flowRate;
    unsigned int flowMilliLitres;
    unsigned long totalMilliLitres;
    unsigned long oldTime;
    void setup()
    {
    // Initialize a serial connection for reporting values to the host
    Serial.begin(38400);
    // Set up the status LED line as an output
    pinMode(statusLed, OUTPUT);
    digitalWrite(statusLed, HIGH); // We have an active-low LED attached
    pinMode(sensorPin, INPUT);
    digitalWrite(sensorPin, HIGH);
    pulseCount = 0;
    flowRate = 0.0;
    flowMilliLitres = 0;
    totalMilliLitres = 0;
    oldTime = 0;
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
    }
    void loop()
    {
    if((millis() - oldTime) > 1000) // Only process counters once per second
    {
    detachInterrupt(sensorInterrupt);
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    oldTime = millis();
    flowMilliLitres = (flowRate / 60) * 1000;
    totalMilliLitres += flowMilliLitres;
    unsigned int frac;
    char str[10];
    char str2[10];
    Serial.print('Flow rate: ');
    Serial.print(int(flowRate)); // Print the integer part of the variable
    Serial.print('.'); // Print the decimal point
    frac = (flowRate - int(flowRate)) * 10;
    Serial.print(frac, DEC) ; // Print the fractional part of the variable
    Serial.print('L/min');
    Serial.print(' Current Liquid Flowing: '); // Output separator
    Serial.print(flowMilliLitres);
    Serial.print('mL/Sec');
    sprintf(str, '%d', flowMilliLitres);
    Particle.publish('FlowRatesmlPerSec', str);
    Serial.print(' Output Liquid Quantity: '); // Output separator
    Serial.print(totalMilliLitres);
    Serial.println('mL');
    sprintf(str2, '%d', totalMilliLitres);
    Particle.publish('totalFlowInML', str2);
    }
    }
    void pulseCounter()
    {
    pulseCount++;
    }

    #flow sernsor,#iot,#particle photon