multiplying a value

Hi there,

I have a quick,and I think pretty simple question, but I haven't had any luck with it myself. Suffice to say, I am not super experienced.

I am measuring water volume passing through a flow sensor. I am using the flowmeter library from here (GitHub - sekdiy/FlowMeter: Arduino flow meter library that provides calibrated liquid flow and volume measurement with flow sensors.). Working like a charm, but I would like to be able to serial.print litres per hour instead of litres per minute, as it is currently doing. In previous flow sensor codes that I had tried, I was able to multiply the flow rate by 60 to obtain the litres per hour and then print that, but I am not having any luck amending this code to do that.

I am pretty sure I have just overlooked something and would appreciate a more knowledgable person's eyes on the question.

Thank you for your time.

#include <FlowMeter.h>  // https://github.com/sekdiy/FlowMeter

// connect a flow meter to an interrupt pin (see notes on your Arduino model for pin numbers)
FlowMeter Meter = FlowMeter(2);

// set the measurement update period to 1s (1000 ms)
const unsigned long period = 1000;

// define an 'interrupt service handler' (ISR) for every interrupt pin you use
void MeterISR() {
    // let our flow meter count the pulses
    Meter.count();
}

void setup() {
    // prepare serial communication
    Serial.begin(9600);

    // enable a call to the 'interrupt service handler' (ISR) on every rising edge at the interrupt pin
    // do this setup step for every ISR you have defined, depending on how many interrupts you use
    attachInterrupt(INT0, MeterISR, RISING);

    // sometimes initializing the gear generates some pulses that we should ignore
    Meter.reset();
}

void loop() {
    // wait between output updates
    delay(period);

    // process the (possibly) counted ticks
    Meter.tick(period);

    // output some measurement result
    Serial.println("Currently " + String(Meter.getCurrentFlowrate()) + " l/min, " + String(Meter.getTotalVolume())+ " l total.");

    //
    // any other code can go here
    //
}

I would be inclined to split the line up, and avoid String:

// output some measurement result
Serial.print("Currently " );
Serial.print(Meter.getCurrentFlowrate());
Serial.print(" l/min, ");
Serial.print(Meter.getTotalVolume());
Serial.println(" l total.");

Then insert something like:

Serial.print( (float)Meter.getCurrentFlowrate() * (float)60 ) ;

Steve

Lose the Strings (use c-strings), and multiply your flowrate by sixty.
Life will start to make sense,

Thanks for the tips!
I will try it out tonight and see.

Its funny, because I figured it was doing the same thing as some previous code I was using, but couldn't figure out why I was using a string there.

This advice makes sense.

Have a wonderful day and thanks again!

Adod

Just following up.

It worked like a charm.

Thank you,

Adod