FlowSensor-Arduino icon indicating copy to clipboard operation
FlowSensor-Arduino copied to clipboard

How can i have several volume or flow rate variables ?

Open kaertblan opened this issue 2 years ago • 2 comments

My project is to make a flowmeter with different sessions (with a selector to measure the water consumption of different people). I measure the flow of a session and I can switch to another. So I need to have several volume or flow variables! Example volume 1, volume 2 etc.... (with the pulse counter reset to zero each time I change session) Do you know how to do this? Thanks a lot ;)

kaertblan avatar Nov 01 '23 12:11 kaertblan

maybe you can use array to save session volume and you can use Sensor.resetVolume() to set volume to 0, use interrupt to trigger session start and finish.

unsigned long volume[10];
uint8_t session;
bool sessionTrig = false;

void interruptFunc()
{
	if (sessionTrig != true)
		sessionTrig = true;
	else
	{
		session++;
		sessionTrig = false;
	}
}

void loop ()
{
	// use interrupt to trig session
	if (sessionTrig == true)
	{
  		if (millis() - timebefore >= 1000)
  		{
	  		Sensor.read();
			volume[session] = Sensor.getVolume();
	  		Serial.print("Volume (L) : ");
	  		Serial.println(volume[session]);
	  		timebefore = millis();
  		}
	}
}

hafidhh avatar Nov 02 '23 21:11 hafidhh

thanks for your fast reply i think that can be works ! Only the session system works like that if (select_1 == 3) { // If select_1= 3 vol4 = 0.00225 * pulse_freq;

And I don't want to reset the volume because I want to keep seeing it but have multiple volume sessions. For example volume1 = Sensor.getVolume1(); volume2 = Sensor.getVolume2(); volume3 = Sensor.getVolume3(); That is, to have the same commands you've created, but specified per session ( Sensor.getFlowRate1_m()); Sensor.resetVolume1(); Sensor.resetVolume3(); etc....) Thank you

kaertblan avatar Nov 12 '23 12:11 kaertblan