Hello , I would like some assistance with my simple project , I am using scales for some fluid . I am measuring the weight using the HX711 device. I am having trouble trying to work out how I can detect flow rate as the fluid has a tube that varies in flow rate and can not have a flow meter attached. is there someone who can help with some formula or some steps I can work out how I can add flow rate either using the raw info from the scales in the project loss weight vs time as I am not sure if able in implement pulse as in time v loss .
Serial.print("read: \t\t");
Serial.println(scale.read()); // print a raw reading from the ADC
Serial.print("read: \t\t");
Serial.println(scale.read()); // print a raw reading from the ADC
Serial.println("Readings:");
// Read the initial weight
previousWeight = scale.get_units();
}
void loop() {
Serial.print("one reading:\t");
Serial.println(scale.read());
// For caluculating loss
// Read the current weight
weight = scale.get_units();
// Check if the weight is increasing
if (weight > previousWeight) {
isIncreasing = true;
} else if (weight < previousWeight) {
if (isIncreasing) {
// If it was increasing before, reset the total loss and change the state
totalLoss = 0;
isIncreasing = false;
} else {
// If the weight is not increasing, calculate the weight loss
totalLoss += (previousWeight - weight);
}
}
// Print the loss of weight
Serial.print(" kg\tTotal Weight Loss:\t ");
Serial.print(totalLoss);
// Update the previous weight
previousWeight = weight;
delay(5000);
}
/**
*basic weight system
this sketch will only read raw values
things to change is the pin outs.
*
**/
#include <Arduino.h>
#include "HX711.h"
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 17;
const int LOADCELL_SCK_PIN = 16;
// VARIABLES
// Variables for weight measurement
float weight = 0;
float previousWeight = 0;
float totalLoss = 0;
bool isIncreasing = false;
HX711 scale;
void setup() {
Serial.begin(57600);
Serial.println("HX711 Demo");
Serial.println("Initializing the scale");
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
Serial.print("read: \t\t");
Serial.println(scale.read()); // print a raw reading from the ADC
Serial.print("read: \t\t");
Serial.println(scale.read()); // print a raw reading from the ADC
Serial.println("Readings:");
// Read the initial weight
previousWeight = scale.get_units();
}
void loop() {
Serial.print("one reading:\t");
Serial.println(scale.read());
// For caluculating loss
// Read the current weight
weight = scale.get_units();
// Check if the weight is increasing
if (weight > previousWeight) {
isIncreasing = true;
} else if (weight < previousWeight) {
if (isIncreasing) {
// If it was increasing before, reset the total loss and change the state
totalLoss = 0;
isIncreasing = false;
} else {
// If the weight is not increasing, calculate the weight loss
totalLoss += (previousWeight - weight);
}
}
// Print the loss of weight
Serial.print(" kg\tTotal Weight Loss:\t ");
Serial.print(totalLoss);
// Update the previous weight
previousWeight = weight;
delay(5000);
}