bobsbeer
Well-Known Member
This thread is about an idea to use pressure sensors to measure volume in the HLT and Boiler with a Arduino controller. My idea is similar to the Flow Controller thread but using a different approach to volume measurement. This isn't my idea, as it is a method adopted by BrewTroller to take measurements in their system. But as I don't have a BrewTroller I wanted to emulate the measuring system and incorporate this into a slightly simpler system. This post might get quite long so bear with me.
As I see it the reading of the sensor is the same as that of Analog In example on the Arduino Forum
so to change this to read litres instead of a percentage:
Would be:
It does need editing but posted so I didn't lose it. But please chip in if you can help.
As I see it the reading of the sensor is the same as that of Analog In example on the Arduino Forum
so to change this to read litres instead of a percentage:
Code:
sensorValue = analogRead( TANK_SENSOR_PIN ); //
constrainedValue = constrain( sensorValue, TANK_EMPTY_SETTING, TANK_FULL_SETTING );
tankLevel = map( constrainedValue, TANK_EMPTY_SETTING, TANK_FULL_SETTING, 0, 100 ); //change these values to tank lt volume
Would be:
Code:
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the pressure sensor is attached to
[b]const int analogOutPin = 9; // Analog output pin that the LCD is attached to[/b]
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
constrainedValue = constrain( sensorValue, TANK_EMPTY_SETTING, TANK_FULL_SETTING )
tankLevel = map( constrainedValue, TANK_EMPTY_SETTING, TANK_FULL_SETTING, 1, 30) //
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop()
{
// read the analog in value:
sensorValue = analogRead( TANK_SENSOR_PIN ); // map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 30); // change the analog out value: Where 30 is max volume
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}
It does need editing but posted so I didn't lose it. But please chip in if you can help.